Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of context images for 2D tasks #3122

Merged
merged 52 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
5837b7d
Updated server-side code
Apr 20, 2021
3acc247
Initial client implementation
Apr 20, 2021
67af2bb
Updated notification reducer
Apr 20, 2021
be283f9
Merge branch 'develop' into bs/context_image_2d
Apr 20, 2021
856c532
Request context image only when it is possible
Apr 21, 2021
1e11c46
Minor refactoring
Apr 21, 2021
9145202
Merged develop
Apr 21, 2021
c8bc27a
Changes in manifest file
Apr 21, 2021
d4b0a28
Aborted some changes
Apr 21, 2021
6d055c5
External filtration
Apr 21, 2021
9849555
Minor fixes, updated version
Apr 21, 2021
6419114
Modified context window
Apr 22, 2021
0a3d977
Updated styles
Apr 22, 2021
18141d7
Removed unused import
Apr 22, 2021
1bb873b
Fixed video tasks creating
Apr 22, 2021
61feacf
Fixed tests
Apr 22, 2021
c417076
Updated version & changelog
Apr 23, 2021
aaecfb2
Removed extra comments
Apr 23, 2021
c34856c
Manifest for 3D
Apr 23, 2021
508069e
Removed old code
Apr 23, 2021
a859e86
Some fix
Apr 23, 2021
cf14823
Setup code to create different tasks with context images
Apr 23, 2021
b8c3e9f
Updated comments
Apr 23, 2021
ea8dfd8
Removed extra comment
Apr 23, 2021
90bf777
Removed unused import
Apr 23, 2021
737ebc3
Removed extra code
Apr 23, 2021
e8f113e
Fixed CHANGELOG.md (remarklint issues)
Apr 23, 2021
5b9f57c
Merged develop
Apr 23, 2021
e3ac571
Merge branch 'develop' into bs/context_image_2d
Apr 23, 2021
dd32262
Merged develop
May 4, 2021
fc309be
Merged origin
May 4, 2021
594c714
Merge branch 'develop' into bs/context_image_2d
May 6, 2021
806faa5
Fixed glob patterns, fixed minor issues
May 6, 2021
d6a140d
Used another component API, updated styles a bit
May 6, 2021
d6d5bcc
Updated check of glob expressions
May 6, 2021
fb7878f
Merge branch 'develop' into bs/context_image_2d
May 7, 2021
08a99bd
Merged develop
May 12, 2021
ebdccb2
Redesigned method of getting context images
May 12, 2021
499c038
Added sorting, using rsplit, fixed velodyne format
May 12, 2021
8dea4a6
Merge branch 'develop' into bs/context_image_2d
May 13, 2021
0004414
Merge branch 'develop' into bs/context_image_2d
May 14, 2021
10e18ab
Some code rewritten in more optimal way
May 14, 2021
3f05093
Some refactoring
May 14, 2021
5aca62e
A couple of typos fixed
May 14, 2021
3beec9b
Fixed some issues
May 14, 2021
d71c5b1
Return empty dict when no images passed
May 14, 2021
6b41c65
Made functions internal
May 14, 2021
c91ced5
Fix svg image handler
Marishka17 May 18, 2021
a851b4b
Merge remote-tracking branch 'origin/develop' into bs/context_image_2d
May 18, 2021
4b57b7a
Updated the CHANGELOG file.
May 18, 2021
6e4d59b
Fixed filtration
May 18, 2021
eb2454d
Fixed filtration
May 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

-
- Support of context images for 2D image tasks (<https://github.com/openvinotoolkit/cvat/pull/3122>)

### Changed

-
- Updated manifest format, added meta with related images (<https://github.com/openvinotoolkit/cvat/pull/3122>)

### Deprecated

Expand Down Expand Up @@ -111,7 +111,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed filters select overflow (<https://github.com/openvinotoolkit/cvat/pull/2614>)
- Fixed tasks in project auto annotation (<https://github.com/openvinotoolkit/cvat/pull/2725>)
- Cuboids are missed in annotations statistics (<https://github.com/openvinotoolkit/cvat/pull/2704>)
- The list of files attached to the task is not displayed (<https://github.com/openvinotoolkit/cvat/pul
- The list of files attached to the task is not displayed (<https://github.com/openvinotoolkit/cvat/pull/2706>)
- A couple of css-related issues (top bar disappear, wrong arrow position on collapse elements) (<https://github.com/openvinotoolkit/cvat/pull/2736>)
- Issue with point region doesn't work in Firefox (<https://github.com/openvinotoolkit/cvat/pull/2727>)
- Fixed cuboid perspective change (<https://github.com/openvinotoolkit/cvat/pull/2733>)
Expand Down
2 changes: 1 addition & 1 deletion cvat-core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cvat-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-core",
"version": "3.12.1",
"version": "3.13.0",
"description": "Part of Computer Vision Tool which presents an interface for client-side integration",
"main": "babel.config.js",
"scripts": {
Expand Down
22 changes: 21 additions & 1 deletion cvat-core/src/frames.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@
*/
class FrameData {
constructor({
width, height, name, taskID, frameNumber, startFrame, stopFrame, decodeForward,
width,
height,
name,
taskID,
frameNumber,
startFrame,
stopFrame,
decodeForward,
has_related_context: hasRelatedContext,
}) {
Object.defineProperties(
this,
Expand Down Expand Up @@ -72,6 +80,18 @@
value: frameNumber,
writable: false,
},
/**
* True if some context images are associated with this frame
* @name hasRelatedContext
* @type {boolean}
* @memberof module:API.cvat.classes.FrameData
* @readonly
* @instance
*/
hasRelatedContext: {
value: hasRelatedContext,
writable: false,
},
startFrame: {
value: startFrame,
writable: false,
Expand Down
6 changes: 1 addition & 5 deletions cvat-core/src/server-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -756,11 +756,7 @@
},
);
} catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code;
throw new ServerError(
`Could not get Image Context of the frame for the task ${tid} from the server`,
code,
);
throw generateError(errorData);
}

return response.data;
Expand Down
2 changes: 1 addition & 1 deletion cvat-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cvat-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-ui",
"version": "1.19.1",
"version": "1.20.0",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
Expand Down
33 changes: 15 additions & 18 deletions cvat-ui/src/actions/annotation-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ export enum AnnotationActionTypes {
GET_PREDICTIONS_SUCCESS = 'GET_PREDICTIONS_SUCCESS',
HIDE_SHOW_CONTEXT_IMAGE = 'HIDE_SHOW_CONTEXT_IMAGE',
GET_CONTEXT_IMAGE = 'GET_CONTEXT_IMAGE',
GET_CONTEXT_IMAGE_SUCCESS = 'GET_CONTEXT_IMAGE_SUCCESS',
GET_CONTEXT_IMAGE_FAILED = 'GET_CONTEXT_IMAGE_FAILED',
}

export function saveLogsAsync(): ThunkAction {
Expand Down Expand Up @@ -715,6 +717,7 @@ export function changeFrameAsync(toFrame: number, fillBuffer?: boolean, frameSte
number: state.annotation.player.frame.number,
data: state.annotation.player.frame.data,
filename: state.annotation.player.frame.filename,
hasRelatedContext: state.annotation.player.frame.hasRelatedContext,
delay: state.annotation.player.frame.delay,
changeTime: state.annotation.player.frame.changeTime,
states: state.annotation.annotations.states,
Expand Down Expand Up @@ -766,6 +769,7 @@ export function changeFrameAsync(toFrame: number, fillBuffer?: boolean, frameSte
number: toFrame,
data,
filename: data.filename,
hasRelatedContext: data.hasRelatedContext,
states,
minZ,
maxZ,
Expand Down Expand Up @@ -1031,6 +1035,7 @@ export function getJobAsync(tid: number, jid: number, initialFrame: number, init
states,
frameNumber,
frameFilename: frameData.filename,
frameHasRelatedContext: frameData.hasRelatedContext,
frameData,
colors,
filters,
Expand Down Expand Up @@ -1636,31 +1641,23 @@ export function getContextImage(): ThunkAction {
return async (dispatch: ActionCreator<Dispatch>): Promise<void> => {
const state: CombinedState = getStore().getState();
const { instance: job } = state.annotation.job;
const { frame, contextImage } = state.annotation.player;
const { number: frameNumber } = state.annotation.player.frame;

try {
const context = await job.frames.contextImage(job.task.id, frame.number);
const loaded = true;
const contextImageHide = contextImage.hidden;
dispatch({
type: AnnotationActionTypes.GET_CONTEXT_IMAGE,
payload: {
context,
loaded,
contextImageHide,
},
payload: {},
});

const contextImageData = await job.frames.contextImage(job.task.id, frameNumber);
dispatch({
type: AnnotationActionTypes.GET_CONTEXT_IMAGE_SUCCESS,
payload: { contextImageData },
});
} catch (error) {
const context = '';
const loaded = true;
const contextImageHide = contextImage.hidden;
dispatch({
type: AnnotationActionTypes.GET_CONTEXT_IMAGE,
payload: {
context,
loaded,
contextImageHide,
},
type: AnnotationActionTypes.GET_CONTEXT_IMAGE_FAILED,
payload: { error },
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import getCore from 'cvat-core-wrapper';
import consts from 'consts';
import CVATTooltip from 'components/common/cvat-tooltip';
import ImageSetupsContent from './image-setups-content';
import ContextImage from '../standard-workspace/context-image/context-image';

const cvat = getCore();

Expand Down Expand Up @@ -773,12 +774,12 @@ export default class CanvasWrapperComponent extends React.PureComponent<Props> {
maxZLayer,
curZLayer,
minZLayer,
onSwitchZLayer,
onAddZLayer,
keyMap,
switchableAutomaticBordering,
automaticBordering,
onSwitchAutomaticBordering,
onSwitchZLayer,
onAddZLayer,
} = this.props;

const preventDefault = (event: KeyboardEvent | undefined): void => {
Expand Down Expand Up @@ -817,6 +818,8 @@ export default class CanvasWrapperComponent extends React.PureComponent<Props> {
}}
/>

<ContextImage />

<Dropdown trigger='click' placement='topCenter' overlay={<ImageSetupsContent />}>
<UpOutlined className='cvat-canvas-image-setups-trigger' />
</Dropdown>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,16 @@ import { Workspace } from 'reducers/interfaces';
import {
CAMERA_ACTION, Canvas3d, MouseInteraction, ViewType,
} from 'cvat-canvas3d-wrapper';
import ContextImage from '../standard3D-workspace/context-image/context-image';
import CVATTooltip from '../../common/cvat-tooltip';
import ContextImage from 'components/annotation-page/standard-workspace/context-image/context-image';
import CVATTooltip from 'components/common/cvat-tooltip';

interface Props {
canvasInstance: Canvas3d;
jobInstance: any;
frameData: any;
curZLayer: number;
contextImageHide: boolean;
loaded: boolean;
data: string;
annotations: any[];
onSetupCanvas: () => void;
getContextImage(): void;
onResetCanvas(): void;
workspace: Workspace;
animateID: any;
Expand Down Expand Up @@ -119,9 +115,7 @@ const CanvasWrapperComponent = (props: Props): ReactElement => {
const sideView = useRef<HTMLDivElement | null>(null);
const frontView = useRef<HTMLDivElement | null>(null);

const {
frameData, contextImageHide, getContextImage, loaded, data, annotations, curZLayer,
} = props;
const { frameData, annotations, curZLayer } = props;

const onCanvasSetup = (): void => {
const { onSetupCanvas } = props;
Expand Down Expand Up @@ -345,13 +339,7 @@ const CanvasWrapperComponent = (props: Props): ReactElement => {

return (
<Layout.Content className='cvat-canvas3d-fullsize' id='canvas3d-container'>
<ContextImage
frame={frameData}
contextImageHide={contextImageHide}
getContextImage={getContextImage}
loaded={loaded}
data={data}
/>
<ContextImage />
<ResizableBox
className='cvat-resizable'
width={Infinity}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright (C) 2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

import React, { useEffect, useState } from 'react';
import { notification } from 'antd';
import { useDispatch, useSelector } from 'react-redux';
import { QuestionCircleOutlined, ShrinkOutlined } from '@ant-design/icons';
import Spin from 'antd/lib/spin';
import Image from 'antd/lib/image';

import { CombinedState } from 'reducers/interfaces';
import { hideShowContextImage, getContextImage } from 'actions/annotation-actions';
import CVATTooltip from 'components/common/cvat-tooltip';

export default function ContextImage(): JSX.Element | null {
const dispatch = useDispatch();
const { number: frame, hasRelatedContext } = useSelector((state: CombinedState) => state.annotation.player.frame);
const { data: contextImageData, hidden: contextImageHidden, fetching: contextImageFetching } = useSelector(
(state: CombinedState) => state.annotation.player.contextImage,
);
const [requested, setRequested] = useState(false);

useEffect(() => {
if (requested) {
setRequested(false);
}
}, [frame]);

useEffect(() => {
if (hasRelatedContext && !contextImageHidden && !requested) {
dispatch(getContextImage());
setRequested(true);
}
}, [contextImageHidden, requested, hasRelatedContext]);

if (!hasRelatedContext) {
return null;
}

return (
<div className='cvat-context-image-wrapper' {...(contextImageHidden ? { style: { width: '32px' } } : {})}>
<div className='cvat-context-image-wrapper-header' />
bsekachev marked this conversation as resolved.
Show resolved Hide resolved
{contextImageFetching ? <Spin size='small' /> : null}
{contextImageHidden ? (
<CVATTooltip title='A context image is available'>
<QuestionCircleOutlined
className='cvat-context-image-switcher'
onClick={() => dispatch(hideShowContextImage(false))}
/>
</CVATTooltip>
) : (
<>
<ShrinkOutlined
className='cvat-context-image-switcher'
onClick={() => dispatch(hideShowContextImage(true))}
/>
<Image
{...(contextImageData ? { src: contextImageData } : {})}
onError={() => {
notification.error({
message: 'Could not display context image',
description: `Source is ${
contextImageData === null ? 'empty' : contextImageData.slice(0, 100)
}`,
});
}}
className='cvat-context-image'
/>
</>
)}
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function ExtraControlsControl(): JSX.Element {
>
<SmallDashOutlined
style={{ visibility: hasChildren ? 'visible' : 'hidden' }}
className='cvat-extra-controls-control'
className='cvat-extra-controls-control cvat-antd-icon-control'
/>
</Popover>
);
Expand Down
Loading