Implemented propagate backward (#5355)

<!-- Raised an issue to propose your change
(https://github.com/cvat-ai/cvat/issues).
It helps to avoid duplication of efforts from multiple independent
contributors.
Discuss your ideas with maintainers to be sure that changes will be
approved and merged.
Read the
[CONTRIBUTION](https://github.com/cvat-ai/cvat/blob/develop/CONTRIBUTING.md)
guide. -->

<!-- Provide a general summary of your changes in the Title above -->

### Motivation and context
Resolved #2998

<img width="428" alt="image"
src="https://user-images.githubusercontent.com/40690378/203806586-1367477b-cfff-46f1-947b-d0292cd6f02e.png">


### How has this been tested?
<!-- Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc. -->

### Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply.
If an item isn't applicable by a reason then ~~explicitly
strikethrough~~ the whole
line. If you don't do that github will show an incorrect process for the
pull request.
If you're unsure about any of these, don't hesitate to ask. We're here
to help! -->
- [x] I submit my changes into the `develop` branch
- [x] I have added a description of my changes into
[CHANGELOG](https://github.com/cvat-ai/cvat/blob/develop/CHANGELOG.md)
file
- [ ] I have updated the [documentation](
https://github.com/cvat-ai/cvat/blob/develop/README.md#documentation)
accordingly
- [x] I have added tests to cover my changes
- [x] I have linked related issues ([read github docs](

https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))
- [x] I have increased versions of npm packages if it is necessary
([cvat-canvas](https://github.com/cvat-ai/cvat/tree/develop/cvat-canvas#versioning),

[cvat-core](https://github.com/cvat-ai/cvat/tree/develop/cvat-core#versioning),
[cvat-data](https://github.com/cvat-ai/cvat/tree/develop/cvat-data#versioning)
and
[cvat-ui](https://github.com/cvat-ai/cvat/tree/develop/cvat-ui#versioning))

### License

- [x] I submit _my code changes_ under the same [MIT License](
https://github.com/cvat-ai/cvat/blob/develop/LICENSE) that covers the
project.
  Feel free to contact the maintainers if that's a concern.
main
Boris Sekachev 3 years ago committed by GitHub
parent 2ecd8c7b0c
commit 460df331e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -20,6 +20,7 @@ from online detectors & interactors) (<https://github.com/opencv/cvat/pull/4543>
- Added Webhooks (<https://github.com/opencv/cvat/pull/4863>) - Added Webhooks (<https://github.com/opencv/cvat/pull/4863>)
- Authentication with social accounts google & github (<https://github.com/opencv/cvat/pull/5147>, <https://github.com/opencv/cvat/pull/5181>, <https://github.com/opencv/cvat/pull/5295>) - Authentication with social accounts google & github (<https://github.com/opencv/cvat/pull/5147>, <https://github.com/opencv/cvat/pull/5181>, <https://github.com/opencv/cvat/pull/5295>)
- REST API tests to export job datasets & annotations and validate their structure (<https://github.com/opencv/cvat/pull/5160>) - REST API tests to export job datasets & annotations and validate their structure (<https://github.com/opencv/cvat/pull/5160>)
- Propagation backward on UI (<https://github.com/opencv/cvat/pull/5355>)
### Changed ### Changed
- `api/docs`, `api/swagger`, `api/schema`, `server/about` endpoints now allow unauthorized access (<https://github.com/opencv/cvat/pull/4928>, <https://github.com/opencv/cvat/pull/4935>) - `api/docs`, `api/swagger`, `api/schema`, `server/about` endpoints now allow unauthorized access (<https://github.com/opencv/cvat/pull/4928>, <https://github.com/opencv/cvat/pull/4935>)

@ -1,6 +1,6 @@
{ {
"name": "cvat-ui", "name": "cvat-ui",
"version": "1.44.1", "version": "1.44.2",
"description": "CVAT single-page application", "description": "CVAT single-page application",
"main": "src/index.tsx", "main": "src/index.tsx",
"scripts": { "scripts": {

@ -160,10 +160,9 @@ export enum AnnotationActionTypes {
REMOVE_OBJECT = 'REMOVE_OBJECT', REMOVE_OBJECT = 'REMOVE_OBJECT',
REMOVE_OBJECT_SUCCESS = 'REMOVE_OBJECT_SUCCESS', REMOVE_OBJECT_SUCCESS = 'REMOVE_OBJECT_SUCCESS',
REMOVE_OBJECT_FAILED = 'REMOVE_OBJECT_FAILED', REMOVE_OBJECT_FAILED = 'REMOVE_OBJECT_FAILED',
PROPAGATE_OBJECT = 'PROPAGATE_OBJECT',
PROPAGATE_OBJECT_SUCCESS = 'PROPAGATE_OBJECT_SUCCESS', PROPAGATE_OBJECT_SUCCESS = 'PROPAGATE_OBJECT_SUCCESS',
PROPAGATE_OBJECT_FAILED = 'PROPAGATE_OBJECT_FAILED', PROPAGATE_OBJECT_FAILED = 'PROPAGATE_OBJECT_FAILED',
CHANGE_PROPAGATE_FRAMES = 'CHANGE_PROPAGATE_FRAMES', SWITCH_PROPAGATE_VISIBILITY = 'SWITCH_PROPAGATE_VISIBILITY',
SWITCH_SHOWING_STATISTICS = 'SWITCH_SHOWING_STATISTICS', SWITCH_SHOWING_STATISTICS = 'SWITCH_SHOWING_STATISTICS',
SWITCH_SHOWING_FILTERS = 'SWITCH_SHOWING_FILTERS', SWITCH_SHOWING_FILTERS = 'SWITCH_SHOWING_FILTERS',
COLLECT_STATISTICS = 'COLLECT_STATISTICS', COLLECT_STATISTICS = 'COLLECT_STATISTICS',
@ -404,9 +403,32 @@ export function showFilters(visible: boolean): AnyAction {
}; };
} }
export function propagateObjectAsync(sessionInstance: any, objectState: any, from: number, to: number): ThunkAction { export function switchPropagateVisibility(visible: boolean): AnyAction {
return async (dispatch: ActionCreator<Dispatch>): Promise<void> => { return {
type: AnnotationActionTypes.SWITCH_PROPAGATE_VISIBILITY,
payload: { visible },
};
}
export function propagateObjectAsync(from: number, to: number): ThunkAction {
return async (dispatch: ActionCreator<Dispatch>, getState): Promise<void> => {
const state = getState();
const {
job: {
instance: sessionInstance,
},
annotations: {
activatedStateID,
states: objectStates,
},
} = state.annotation;
try { try {
const objectState = objectStates.find((_state: any) => _state.clientID === activatedStateID);
if (!objectState) {
throw new Error('There is not an activated object state to be propagated');
}
const getCopyFromState = (_objectState: any): any => ({ const getCopyFromState = (_objectState: any): any => ({
attributes: _objectState.attributes, attributes: _objectState.attributes,
points: _objectState.shapeType === 'skeleton' ? null : _objectState.points, points: _objectState.shapeType === 'skeleton' ? null : _objectState.points,
@ -423,9 +445,10 @@ export function propagateObjectAsync(sessionInstance: any, objectState: any, fro
}); });
const copy = getCopyFromState(objectState); const copy = getCopyFromState(objectState);
await sessionInstance.logger.log(LogType.propagateObject, { count: to - from + 1 }); await sessionInstance.logger.log(LogType.propagateObject, { count: Math.abs(to - from) });
const states = []; const states = [];
for (let frame = from; frame <= to; frame++) { const sign = Math.sign(to - from);
for (let frame = from + sign; sign > 0 ? frame <= to : frame >= to; frame += sign) {
copy.frame = frame; copy.frame = frame;
copy.elements.forEach((element: any) => { element.frame = frame; }); copy.elements.forEach((element: any) => { element.frame = frame; });
const newState = new cvat.classes.ObjectState(copy); const newState = new cvat.classes.ObjectState(copy);
@ -437,40 +460,17 @@ export function propagateObjectAsync(sessionInstance: any, objectState: any, fro
dispatch({ dispatch({
type: AnnotationActionTypes.PROPAGATE_OBJECT_SUCCESS, type: AnnotationActionTypes.PROPAGATE_OBJECT_SUCCESS,
payload: { payload: { history },
objectState,
history,
},
}); });
} catch (error) { } catch (error) {
dispatch({ dispatch({
type: AnnotationActionTypes.PROPAGATE_OBJECT_FAILED, type: AnnotationActionTypes.PROPAGATE_OBJECT_FAILED,
payload: { payload: { error },
error,
},
}); });
} }
}; };
} }
export function propagateObject(objectState: any | null): AnyAction {
return {
type: AnnotationActionTypes.PROPAGATE_OBJECT,
payload: {
objectState,
},
};
}
export function changePropagateFrames(frames: number): AnyAction {
return {
type: AnnotationActionTypes.CHANGE_PROPAGATE_FRAMES,
payload: {
frames,
},
};
}
export function removeObjectAsync(sessionInstance: any, objectState: any, force: boolean): ThunkAction { export function removeObjectAsync(sessionInstance: any, objectState: any, force: boolean): ThunkAction {
return async (dispatch: ActionCreator<Dispatch>): Promise<void> => { return async (dispatch: ActionCreator<Dispatch>): Promise<void> => {
try { try {
@ -661,6 +661,13 @@ export function getPredictionsAsync(): ThunkAction {
}; };
} }
export function confirmCanvasReady(): AnyAction {
return {
type: AnnotationActionTypes.CONFIRM_CANVAS_READY,
payload: {},
};
}
export function changeFrameAsync( export function changeFrameAsync(
toFrame: number, toFrame: number,
fillBuffer?: boolean, fillBuffer?: boolean,
@ -670,6 +677,14 @@ export function changeFrameAsync(
return async (dispatch: ActionCreator<Dispatch>, getState: () => CombinedState): Promise<void> => { return async (dispatch: ActionCreator<Dispatch>, getState: () => CombinedState): Promise<void> => {
const state: CombinedState = getState(); const state: CombinedState = getState();
const { instance: job } = state.annotation.job; const { instance: job } = state.annotation.job;
const {
propagate: {
visible: propagateVisible,
},
statistics: {
visible: statisticsVisible,
},
} = state.annotation;
const { filters, frame, showAllInterpolationTracks } = receiveAnnotationsParameters(); const { filters, frame, showAllInterpolationTracks } = receiveAnnotationsParameters();
try { try {
@ -677,9 +692,9 @@ export function changeFrameAsync(
throw Error(`Required frame ${toFrame} is out of the current job`); throw Error(`Required frame ${toFrame} is out of the current job`);
} }
const abortAction = (): AnyAction => { const abortAction = (): void => {
const currentState = getState(); const currentState = getState();
return ({ dispatch({
type: AnnotationActionTypes.CHANGE_FRAME_SUCCESS, type: AnnotationActionTypes.CHANGE_FRAME_SUCCESS,
payload: { payload: {
number: currentState.annotation.player.frame.number, number: currentState.annotation.player.frame.number,
@ -694,6 +709,8 @@ export function changeFrameAsync(
curZ: currentState.annotation.annotations.zLayer.cur, curZ: currentState.annotation.annotations.zLayer.cur,
}, },
}); });
dispatch(confirmCanvasReady());
}; };
dispatch({ dispatch({
@ -702,17 +719,17 @@ export function changeFrameAsync(
}); });
if (toFrame === frame && !forceUpdate) { if (toFrame === frame && !forceUpdate) {
dispatch(abortAction()); abortAction();
return; return;
} }
const data = await job.frames.get(toFrame, fillBuffer, frameStep); const data = await job.frames.get(toFrame, fillBuffer, frameStep);
const states = await job.annotations.get(toFrame, showAllInterpolationTracks, filters); const states = await job.annotations.get(toFrame, showAllInterpolationTracks, filters);
if (!isAbleToChangeFrame()) { if (!isAbleToChangeFrame() || statisticsVisible || propagateVisible) {
// while doing async actions above, canvas can become used by a user in another way // while doing async actions above, canvas can become used by a user in another way
// so, we need an additional check and if it is used, we do not update state // so, we need an additional check and if it is used, we do not update state
dispatch(abortAction()); abortAction();
return; return;
} }
@ -933,13 +950,6 @@ export function resetCanvas(): AnyAction {
}; };
} }
export function confirmCanvasReady(): AnyAction {
return {
type: AnnotationActionTypes.CONFIRM_CANVAS_READY,
payload: {},
};
}
export function closeJob(): ThunkAction { export function closeJob(): ThunkAction {
return async (dispatch: ActionCreator<Dispatch>): Promise<void> => { return async (dispatch: ActionCreator<Dispatch>): Promise<void> => {
const { jobInstance } = receiveAnnotationsParameters(); const { jobInstance } = receiveAnnotationsParameters();

@ -1,82 +1,155 @@
// Copyright (C) 2020-2022 Intel Corporation // Copyright (C) 2020-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
import React from 'react'; import React, { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import Modal from 'antd/lib/modal'; import Modal from 'antd/lib/modal';
import InputNumber from 'antd/lib/input-number'; import InputNumber from 'antd/lib/input-number';
import Text from 'antd/lib/typography/Text'; import Text from 'antd/lib/typography/Text';
import Radio, { RadioChangeEvent } from 'antd/lib/radio';
import { Row, Col } from 'antd/lib/grid';
import Slider from 'antd/lib/slider';
import { clamp } from 'utils/math'; import { clamp } from 'utils/math';
import { ArrowLeftOutlined, ArrowRightOutlined } from '@ant-design/icons';
import { propagateObjectAsync, switchPropagateVisibility } from 'actions/annotation-actions';
import { CombinedState } from 'reducers';
interface Props { export enum PropagateDirection {
visible: boolean; FORWARD = 'forward',
propagateFrames: number; BACKWARD = 'backward',
propagateUpToFrame: number;
stopFrame: number;
frameNumber: number;
propagateObject(): void;
cancel(): void;
changePropagateFrames(value: number): void;
changeUpToFrame(value: number): void;
} }
export default function PropagateConfirmComponent(props: Props): JSX.Element { function PropagateConfirmComponent(): JSX.Element {
const { const dispatch = useDispatch();
visible, const visible = useSelector((state: CombinedState) => state.annotation.propagate.visible);
propagateFrames, const frameNumber = useSelector((state: CombinedState) => state.annotation.player.frame.number);
propagateUpToFrame, const startFrame = useSelector((state: CombinedState) => state.annotation.job.instance.startFrame);
stopFrame, const stopFrame = useSelector((state: CombinedState) => state.annotation.job.instance.stopFrame);
frameNumber, const [targetFrame, setTargetFrame] = useState<number>(frameNumber);
propagateObject,
changePropagateFrames, const propagateFrames = Math.abs(targetFrame - frameNumber);
changeUpToFrame, const propagateDirection = targetFrame >= frameNumber ? PropagateDirection.FORWARD : PropagateDirection.BACKWARD;
cancel,
} = props;
const minPropagateFrames = 1; useEffect(() => {
const propagateForwardAvailable = stopFrame - frameNumber >= 1;
const propagateBackwardAvailable = frameNumber - startFrame >= 1;
if (propagateForwardAvailable) {
setTargetFrame(stopFrame);
} else if (propagateBackwardAvailable) {
setTargetFrame(startFrame);
}
}, [visible]);
const updateTargetFrame = (direction: PropagateDirection, _propagateFrames: number): void => {
if (direction === PropagateDirection.FORWARD) {
setTargetFrame(clamp(frameNumber + _propagateFrames, startFrame, stopFrame));
} else {
setTargetFrame(clamp(frameNumber - _propagateFrames, startFrame, stopFrame));
}
};
return ( return (
<Modal <Modal
okType='primary' okType='primary'
okText='Yes' okText='Yes'
cancelText='Cancel' cancelText='Cancel'
onOk={propagateObject} onOk={() => {
onCancel={cancel} dispatch(propagateObjectAsync(frameNumber, targetFrame))
.then(() => dispatch(switchPropagateVisibility(false)));
}}
onCancel={() => dispatch(switchPropagateVisibility(false))}
title='Confirm propagation' title='Confirm propagation'
visible={visible} visible={visible}
destroyOnClose
okButtonProps={{ disabled: !propagateFrames }}
> >
<div className='cvat-propagate-confirm'> <div className='cvat-propagate-confirm'>
<Text>Do you want to make a copy of the object on</Text> <Row>
<InputNumber <Col>
className='cvat-propagate-confirm-object-on-frames' <Text>Please, specify a direction</Text>
size='small' </Col>
min={minPropagateFrames} <Col offset={1}>
value={propagateFrames} <Radio.Group
onChange={(value: number | undefined | string) => { size='small'
if (typeof value !== 'undefined') { value={propagateDirection}
changePropagateFrames( onChange={(e: RadioChangeEvent) => updateTargetFrame(e.target.value, propagateFrames)}
Math.floor(clamp(+value, minPropagateFrames, Number.MAX_SAFE_INTEGER)), >
); <Radio.Button disabled={frameNumber === startFrame} value={PropagateDirection.BACKWARD}>
} <ArrowLeftOutlined />
}} </Radio.Button>
/> <Radio.Button disabled={frameNumber === stopFrame} value={PropagateDirection.FORWARD}>
{propagateFrames > 1 ? <Text> frames </Text> : <Text> frame </Text>} <ArrowRightOutlined />
<Text>up to the </Text> </Radio.Button>
<InputNumber </Radio.Group>
className='cvat-propagate-confirm-object-up-to-frame' </Col>
size='small' </Row>
value={propagateUpToFrame} <Row>
min={frameNumber + 1} <Col>How many copies do you want to create?</Col>
max={stopFrame} <Col offset={1}>
onChange={(value: number | undefined | string) => { <InputNumber
if (typeof value !== 'undefined') { className='cvat-propagate-confirm-object-on-frames'
changeUpToFrame(Math.floor(clamp(+value, frameNumber + 1, stopFrame))); size='small'
} min={0}
}} value={propagateFrames}
/> onChange={(value: number) => {
<Text>frame</Text> if (typeof value !== 'undefined') {
updateTargetFrame(propagateDirection, +value);
}
}}
/>
</Col>
</Row>
<hr />
<Row className='cvat-propagate-up-to-wrapper'>
<Col span={24}>
<Text>Or specify a range where copies will be created </Text>
</Col>
<Col className='cvat-propagate-slider-wrapper' span={12} offset={1}>
<Slider
range
min={startFrame}
max={stopFrame}
marks={frameNumber !== targetFrame ? {
[frameNumber]: 'FROM',
[targetFrame]: 'TO',
} : undefined}
onChange={([value1, value2]: [number, number]) => {
const value = value1 === frameNumber || value1 === targetFrame ? value2 : value1;
if (value < frameNumber) {
setTargetFrame(clamp(value, startFrame, frameNumber));
} else {
setTargetFrame(clamp(value, frameNumber, stopFrame));
}
}}
value={[frameNumber, targetFrame] as [number, number]}
/>
</Col>
<Col span={4}>
<InputNumber
size='small'
className='cvat-propagate-confirm-up-to-input'
min={startFrame}
max={stopFrame}
value={targetFrame}
onChange={(value: number) => {
if (typeof value !== 'undefined') {
if (value > frameNumber) {
setTargetFrame(clamp(+value, frameNumber, stopFrame));
} else if (value < frameNumber) {
setTargetFrame(clamp(+value, startFrame, frameNumber));
} else {
setTargetFrame(frameNumber);
}
}
}}
/>
</Col>
</Row>
</div> </div>
</Modal> </Modal>
); );
} }
export default React.memo(PropagateConfirmComponent);

@ -1,4 +1,5 @@
// Copyright (C) 2020-2022 Intel Corporation // Copyright (C) 2020-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporations
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -8,13 +9,13 @@ import Layout from 'antd/lib/layout';
import CanvasWrapperContainer from 'containers/annotation-page/canvas/canvas-wrapper'; import CanvasWrapperContainer from 'containers/annotation-page/canvas/canvas-wrapper';
import ControlsSideBarContainer from 'containers/annotation-page/standard-workspace/controls-side-bar/controls-side-bar'; import ControlsSideBarContainer from 'containers/annotation-page/standard-workspace/controls-side-bar/controls-side-bar';
import PropagateConfirmContainer from 'containers/annotation-page/standard-workspace/propagate-confirm';
import CanvasContextMenuContainer from 'containers/annotation-page/canvas/canvas-context-menu'; import CanvasContextMenuContainer from 'containers/annotation-page/canvas/canvas-context-menu';
import ObjectsListContainer from 'containers/annotation-page/standard-workspace/objects-side-bar/objects-list'; import ObjectsListContainer from 'containers/annotation-page/standard-workspace/objects-side-bar/objects-list';
import ObjectSideBarComponent from 'components/annotation-page/standard-workspace/objects-side-bar/objects-side-bar'; import ObjectSideBarComponent from 'components/annotation-page/standard-workspace/objects-side-bar/objects-side-bar';
import CanvasPointContextMenuComponent from 'components/annotation-page/canvas/canvas-point-context-menu'; import CanvasPointContextMenuComponent from 'components/annotation-page/canvas/canvas-point-context-menu';
import IssueAggregatorComponent from 'components/annotation-page/review/issues-aggregator'; import IssueAggregatorComponent from 'components/annotation-page/review/issues-aggregator';
import RemoveConfirmComponent from 'components/annotation-page/standard-workspace/remove-confirm'; import RemoveConfirmComponent from 'components/annotation-page/standard-workspace/remove-confirm';
import PropagateConfirmComponent from 'components/annotation-page/standard-workspace/propagate-confirm';
export default function StandardWorkspaceComponent(): JSX.Element { export default function StandardWorkspaceComponent(): JSX.Element {
return ( return (
@ -22,7 +23,7 @@ export default function StandardWorkspaceComponent(): JSX.Element {
<ControlsSideBarContainer /> <ControlsSideBarContainer />
<CanvasWrapperContainer /> <CanvasWrapperContainer />
<ObjectSideBarComponent objectsList={<ObjectsListContainer />} /> <ObjectSideBarComponent objectsList={<ObjectsListContainer />} />
<PropagateConfirmContainer /> <PropagateConfirmComponent />
<CanvasContextMenuContainer /> <CanvasContextMenuContainer />
<CanvasPointContextMenuComponent /> <CanvasPointContextMenuComponent />
<IssueAggregatorComponent /> <IssueAggregatorComponent />

@ -1,4 +1,5 @@
// Copyright (C) 2020-2022 Intel Corporation // Copyright (C) 2020-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -333,9 +334,23 @@
} }
.cvat-propagate-confirm { .cvat-propagate-confirm {
> .ant-input-number { > .ant-row {
width: 70px; align-items: flex-start;
margin: 0 5px; margin-bottom: $grid-unit-size * 2;
}
.ant-input-number {
margin-left: $grid-unit-size;
margin-right: $grid-unit-size;
width: $grid-unit-size * 7;
}
.cvat-propagate-slider-wrapper {
height: $grid-unit-size;
}
.cvat-propagate-up-to-wrapper > div:first-child {
margin-bottom: $grid-unit-size;
} }
} }

@ -10,10 +10,10 @@ import CanvasWrapperContainer from 'containers/annotation-page/canvas/canvas-wra
import ControlsSideBarContainer from 'containers/annotation-page/standard3D-workspace/controls-side-bar/controls-side-bar'; import ControlsSideBarContainer from 'containers/annotation-page/standard3D-workspace/controls-side-bar/controls-side-bar';
import ObjectSideBarComponent from 'components/annotation-page/standard-workspace/objects-side-bar/objects-side-bar'; import ObjectSideBarComponent from 'components/annotation-page/standard-workspace/objects-side-bar/objects-side-bar';
import ObjectsListContainer from 'containers/annotation-page/standard-workspace/objects-side-bar/objects-list'; import ObjectsListContainer from 'containers/annotation-page/standard-workspace/objects-side-bar/objects-list';
import PropagateConfirmContainer from 'containers/annotation-page/standard-workspace/propagate-confirm';
import CanvasContextMenuContainer from 'containers/annotation-page/canvas/canvas-context-menu'; import CanvasContextMenuContainer from 'containers/annotation-page/canvas/canvas-context-menu';
import CanvasPointContextMenuComponent from 'components/annotation-page/canvas/canvas-point-context-menu'; import CanvasPointContextMenuComponent from 'components/annotation-page/canvas/canvas-point-context-menu';
import RemoveConfirmComponent from 'components/annotation-page/standard-workspace/remove-confirm'; import RemoveConfirmComponent from 'components/annotation-page/standard-workspace/remove-confirm';
import PropagateConfirmComponent from 'components/annotation-page/standard-workspace/propagate-confirm';
export default function StandardWorkspace3DComponent(): JSX.Element { export default function StandardWorkspace3DComponent(): JSX.Element {
return ( return (
@ -21,7 +21,7 @@ export default function StandardWorkspace3DComponent(): JSX.Element {
<ControlsSideBarContainer /> <ControlsSideBarContainer />
<CanvasWrapperContainer /> <CanvasWrapperContainer />
<ObjectSideBarComponent objectsList={<ObjectsListContainer />} /> <ObjectSideBarComponent objectsList={<ObjectsListContainer />} />
<PropagateConfirmContainer /> <PropagateConfirmComponent />
<CanvasContextMenuContainer /> <CanvasContextMenuContainer />
<CanvasPointContextMenuComponent /> <CanvasPointContextMenuComponent />
<RemoveConfirmComponent /> <RemoveConfirmComponent />

@ -14,7 +14,7 @@ import {
pasteShapeAsync, pasteShapeAsync,
copyShape as copyShapeAction, copyShape as copyShapeAction,
activateObject as activateObjectAction, activateObject as activateObjectAction,
propagateObject as propagateObjectAction, switchPropagateVisibility as switchPropagateVisibilityAction,
removeObject as removeObjectAction, removeObject as removeObjectAction,
} from 'actions/annotation-actions'; } from 'actions/annotation-actions';
import { import {
@ -56,7 +56,7 @@ interface DispatchToProps {
activateObject: (activatedStateID: number | null, activatedElementID: number | null) => void; activateObject: (activatedStateID: number | null, activatedElementID: number | null) => void;
removeObject: (objectState: any) => void; removeObject: (objectState: any) => void;
copyShape: (objectState: any) => void; copyShape: (objectState: any) => void;
propagateObject: (objectState: any) => void; switchPropagateVisibility: (visible: boolean) => void;
changeGroupColor(group: number, color: string): void; changeGroupColor(group: number, color: string): void;
} }
@ -118,8 +118,8 @@ function mapDispatchToProps(dispatch: any): DispatchToProps {
dispatch(copyShapeAction(objectState)); dispatch(copyShapeAction(objectState));
dispatch(pasteShapeAsync()); dispatch(pasteShapeAsync());
}, },
propagateObject(objectState: any): void { switchPropagateVisibility(visible: boolean): void {
dispatch(propagateObjectAction(objectState)); dispatch(switchPropagateVisibilityAction(visible));
}, },
changeGroupColor(group: number, color: string): void { changeGroupColor(group: number, color: string): void {
dispatch(changeGroupColorAsync(group, color)); dispatch(changeGroupColorAsync(group, color));
@ -137,9 +137,9 @@ class ObjectItemContainer extends React.PureComponent<Props> {
}; };
private propagate = (): void => { private propagate = (): void => {
const { objectState, readonly, propagateObject } = this.props; const { switchPropagateVisibility, readonly } = this.props;
if (!readonly) { if (!readonly) {
propagateObject(objectState); switchPropagateVisibility(true);
} }
}; };

@ -16,7 +16,7 @@ import {
collapseObjectItems, collapseObjectItems,
changeGroupColorAsync, changeGroupColorAsync,
copyShape as copyShapeAction, copyShape as copyShapeAction,
propagateObject as propagateObjectAction, switchPropagateVisibility as switchPropagateVisibilityAction,
removeObject as removeObjectAction, removeObject as removeObjectAction,
} from 'actions/annotation-actions'; } from 'actions/annotation-actions';
import isAbleToChangeFrame from 'utils/is-able-to-change-frame'; import isAbleToChangeFrame from 'utils/is-able-to-change-frame';
@ -53,7 +53,7 @@ interface DispatchToProps {
collapseStates(states: any[], value: boolean): void; collapseStates(states: any[], value: boolean): void;
removeObject: (objectState: any, force: boolean) => void; removeObject: (objectState: any, force: boolean) => void;
copyShape: (objectState: any) => void; copyShape: (objectState: any) => void;
propagateObject: (objectState: any) => void; switchPropagateVisibility: (visible: boolean) => void;
changeFrame(frame: number): void; changeFrame(frame: number): void;
changeGroupColor(group: number, color: string): void; changeGroupColor(group: number, color: string): void;
} }
@ -135,8 +135,8 @@ function mapDispatchToProps(dispatch: any): DispatchToProps {
copyShape(objectState: ObjectState): void { copyShape(objectState: ObjectState): void {
dispatch(copyShapeAction(objectState)); dispatch(copyShapeAction(objectState));
}, },
propagateObject(objectState: ObjectState): void { switchPropagateVisibility(visible: boolean): void {
dispatch(propagateObjectAction(objectState)); dispatch(switchPropagateVisibilityAction(visible));
}, },
changeFrame(frame: number): void { changeFrame(frame: number): void {
dispatch(changeFrameAsync(frame)); dispatch(changeFrameAsync(frame));
@ -280,7 +280,7 @@ class ObjectsListContainer extends React.PureComponent<Props, State> {
changeGroupColor, changeGroupColor,
removeObject, removeObject,
copyShape, copyShape,
propagateObject, switchPropagateVisibility,
changeFrame, changeFrame,
} = this.props; } = this.props;
const { objectStates, sortedStatesID, statesOrdering } = this.state; const { objectStates, sortedStatesID, statesOrdering } = this.state;
@ -448,7 +448,7 @@ class ObjectsListContainer extends React.PureComponent<Props, State> {
preventDefault(event); preventDefault(event);
const state = activatedState(); const state = activatedState();
if (state && !readonly) { if (state && !readonly) {
propagateObject(state); switchPropagateVisibility(true);
} }
}, },
NEXT_KEY_FRAME: (event: KeyboardEvent | undefined) => { NEXT_KEY_FRAME: (event: KeyboardEvent | undefined) => {

@ -1,114 +0,0 @@
// Copyright (C) 2020-2022 Intel Corporation
//
// SPDX-License-Identifier: MIT
import React from 'react';
import { connect } from 'react-redux';
import {
propagateObject as propagateObjectAction,
changePropagateFrames as changePropagateFramesAction,
propagateObjectAsync,
} from 'actions/annotation-actions';
import { CombinedState } from 'reducers';
import PropagateConfirmComponent from 'components/annotation-page/standard-workspace/propagate-confirm';
interface StateToProps {
objectState: any | null;
frameNumber: number;
stopFrame: number;
propagateFrames: number;
jobInstance: any;
}
interface DispatchToProps {
cancel(): void;
propagateObject(sessionInstance: any, objectState: any, from: number, to: number): void;
changePropagateFrames(frames: number): void;
}
function mapStateToProps(state: CombinedState): StateToProps {
const {
annotation: {
propagate: { objectState, frames: propagateFrames },
job: {
instance: { stopFrame },
instance: jobInstance,
},
player: {
frame: { number: frameNumber },
},
},
} = state;
return {
objectState,
frameNumber,
stopFrame,
propagateFrames,
jobInstance,
};
}
function mapDispatchToProps(dispatch: any): DispatchToProps {
return {
propagateObject(sessionInstance: any, objectState: any, from: number, to: number): void {
dispatch(propagateObjectAsync(sessionInstance, objectState, from, to));
},
changePropagateFrames(frames: number): void {
dispatch(changePropagateFramesAction(frames));
},
cancel(): void {
dispatch(propagateObjectAction(null));
},
};
}
type Props = StateToProps & DispatchToProps;
class PropagateConfirmContainer extends React.PureComponent<Props> {
private propagateObject = (): void => {
const {
propagateObject, objectState, propagateFrames, frameNumber, stopFrame, jobInstance,
} = this.props;
const propagateUpToFrame = Math.min(frameNumber + propagateFrames, stopFrame);
propagateObject(jobInstance, objectState, frameNumber + 1, propagateUpToFrame);
};
private changePropagateFrames = (value: number): void => {
const { changePropagateFrames } = this.props;
changePropagateFrames(value);
};
private changeUpToFrame = (value: number): void => {
const { stopFrame, frameNumber, changePropagateFrames } = this.props;
const propagateFrames = Math.max(0, Math.min(stopFrame, value)) - frameNumber;
changePropagateFrames(propagateFrames);
};
public render(): JSX.Element {
const {
frameNumber, stopFrame, propagateFrames, cancel, objectState,
} = this.props;
const propagateUpToFrame = Math.min(frameNumber + propagateFrames, stopFrame);
return (
<PropagateConfirmComponent
visible={objectState !== null}
propagateUpToFrame={propagateUpToFrame}
stopFrame={stopFrame}
frameNumber={frameNumber}
propagateFrames={propagateUpToFrame - frameNumber}
propagateObject={this.propagateObject}
changePropagateFrames={this.changePropagateFrames}
changeUpToFrame={this.changeUpToFrame}
cancel={cancel}
/>
);
}
}
export default connect(mapStateToProps, mapDispatchToProps)(PropagateConfirmContainer);

@ -108,10 +108,6 @@ const defaultState: AnnotationState = {
cur: 0, cur: 0,
}, },
}, },
propagate: {
objectState: null,
frames: 50,
},
remove: { remove: {
objectState: null, objectState: null,
force: false, force: false,
@ -121,6 +117,9 @@ const defaultState: AnnotationState = {
collecting: false, collecting: false,
data: null, data: null,
}, },
propagate: {
visible: false,
},
colors: [], colors: [],
sidebarCollapsed: false, sidebarCollapsed: false,
appearanceCollapsed: false, appearanceCollapsed: false,
@ -830,16 +829,6 @@ export default (state = defaultState, action: AnyAction): AnnotationState => {
}, },
}; };
} }
case AnnotationActionTypes.PROPAGATE_OBJECT: {
const { objectState } = action.payload;
return {
...state,
propagate: {
...state.propagate,
objectState,
},
};
}
case AnnotationActionTypes.PROPAGATE_OBJECT_SUCCESS: { case AnnotationActionTypes.PROPAGATE_OBJECT_SUCCESS: {
const { history } = action.payload; const { history } = action.payload;
return { return {
@ -848,20 +837,14 @@ export default (state = defaultState, action: AnyAction): AnnotationState => {
...state.annotations, ...state.annotations,
history, history,
}, },
propagate: {
...state.propagate,
objectState: null,
},
}; };
} }
case AnnotationActionTypes.CHANGE_PROPAGATE_FRAMES: { case AnnotationActionTypes.SWITCH_PROPAGATE_VISIBILITY: {
const { frames } = action.payload; const { visible } = action.payload;
return { return {
...state, ...state,
propagate: { propagate: {
...state.propagate, visible,
frames,
}, },
}; };
} }

@ -720,10 +720,6 @@ export interface AnnotationState {
cur: number; cur: number;
}; };
}; };
propagate: {
objectState: any | null;
frames: number;
};
remove: { remove: {
objectState: any; objectState: any;
force: boolean; force: boolean;
@ -733,6 +729,9 @@ export interface AnnotationState {
visible: boolean; visible: boolean;
data: any; data: any;
}; };
propagate: {
visible: boolean;
};
colors: any[]; colors: any[];
filtersPanelVisible: boolean; filtersPanelVisible: boolean;
sidebarCollapsed: boolean; sidebarCollapsed: boolean;

@ -1,4 +1,5 @@
// Copyright (C) 2021-2022 Intel Corporation // Copyright (C) 2021-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -17,8 +18,6 @@ context('Object propagate.', () => {
secondX: 350, secondX: 350,
secondY: 450, secondY: 450,
}; };
const propagateOnOneFrame = 1;
const propagateOnTwoFrames = 2;
function startPropagation() { function startPropagation() {
cy.get('#cvat-objects-sidebar-state-item-1').find('[aria-label="more"]').trigger('mouseover'); cy.get('#cvat-objects-sidebar-state-item-1').find('[aria-label="more"]').trigger('mouseover');
@ -27,61 +26,88 @@ context('Object propagate.', () => {
}); });
} }
function setupUpToFrame(value) {
cy.get('.cvat-propagate-confirm-up-to-input')
.find('input')
.clear()
.type(value)
.blur()
.should('have.value', value);
}
function setupPropagateFrames(value) {
cy.get('.cvat-propagate-confirm-object-on-frames') // Change value in the "copy of the object on frame" field
.find('input')
.clear()
.type(value)
.blur()
.should('have.value', value);
}
before(() => { before(() => {
cy.openTaskJob(taskName); cy.openTaskJob(taskName);
});
beforeEach(() => {
cy.removeAnnotations();
cy.goCheckFrameNumber(0);
cy.createCuboid(createCuboidShape2Points); cy.createCuboid(createCuboidShape2Points);
}); });
describe(`Testing case "${caseId}"`, () => { describe(`Testing case "${caseId}"`, () => {
it('On the 1st frame propagate object on 1 frame.', () => { it('On the 1st frame propagate object on 1 frame.', () => {
const FROM_FRAME = 0;
const PROPAGATE_FRAMES = 1;
startPropagation(); startPropagation();
cy.get('.cvat-propagate-confirm-object-on-frames') // Change value in the "copy of the object on frame" field setupPropagateFrames(PROPAGATE_FRAMES);
.find('input') cy.get('.cvat-propagate-confirm-up-to-input') // Value of "up to the frame" field should be same
.clear()
.should('have.value', 1);
cy.get('.cvat-propagate-confirm-object-up-to-frame') // Value of "up to the frame" field should be same
.find('input') .find('input')
.should('have.attr', 'value', propagateOnOneFrame); .should('have.attr', 'value', FROM_FRAME + PROPAGATE_FRAMES);
cy.contains('button', 'Yes').click(); cy.contains('button', 'Yes').click();
});
it('On the 1st and 2nd frames, the number of objects is equal to 1. On the 3rd frame is 0.', () => { for (let i = FROM_FRAME; i <= FROM_FRAME + PROPAGATE_FRAMES; i++) {
cy.get('.cvat_canvas_shape_cuboid').then(($cuboidCountFirstFrame) => { cy.goCheckFrameNumber(i);
cy.goCheckFrameNumber(1); // Go to 2nd frame cy.get('.cvat_canvas_shape_cuboid').should('have.length', 1);
cy.get('.cvat_canvas_shape_cuboid').then(($cuboidCountSecondFrame) => { }
expect($cuboidCountFirstFrame.length).to.be.equal($cuboidCountSecondFrame.length); cy.goCheckFrameNumber(FROM_FRAME + PROPAGATE_FRAMES + 1);
});
});
cy.goCheckFrameNumber(2); // Go to 3rd frame
cy.get('.cvat_canvas_shape_cuboid').should('not.exist'); cy.get('.cvat_canvas_shape_cuboid').should('not.exist');
cy.get('.cvat-player-first-button').click();
}); });
it('From the 1st frame propagate again on 2 frames.', () => { it('From the 1st frame propagate again on 2 frames.', () => {
const FROM_FRAME = 0;
const PROPAGATE_FRAMES = 2;
startPropagation(); startPropagation();
cy.get('.cvat-propagate-confirm-object-up-to-frame') // Change value in the "up to the frame" field setupUpToFrame(FROM_FRAME + PROPAGATE_FRAMES);
.find('input')
.clear()
.type(propagateOnTwoFrames)
.should('have.attr', 'value', propagateOnTwoFrames);
cy.get('.cvat-propagate-confirm-object-on-frames') // Value of "copy of the object on frames" field should be same cy.get('.cvat-propagate-confirm-object-on-frames') // Value of "copy of the object on frames" field should be same
.find('input') .find('input')
.should('have.attr', 'value', propagateOnTwoFrames); .should('have.attr', 'value', FROM_FRAME + PROPAGATE_FRAMES);
cy.contains('button', 'Yes').click(); cy.contains('button', 'Yes').click();
for (let i = FROM_FRAME; i <= FROM_FRAME + PROPAGATE_FRAMES; i++) {
cy.goCheckFrameNumber(i);
cy.get('.cvat_canvas_shape_cuboid').should('have.length', 1);
}
cy.goCheckFrameNumber(FROM_FRAME + PROPAGATE_FRAMES + 1);
cy.get('.cvat_canvas_shape_cuboid').should('not.exist');
}); });
it('On the 1st and 3rd frames the number of objects is equal to 1. On the 2nd frame equal to 2. On the 4th frame equal to 0', () => { it('Testing propagate backward', () => {
cy.get('.cvat_canvas_shape_cuboid').then(($cuboidCountFirstFrame) => { cy.removeAnnotations();
cy.goCheckFrameNumber(2); // Go to 3rd frame const FROM_FRAME = 4;
cy.get('.cvat_canvas_shape_cuboid').then(($cuboidCountThirdFrame) => { const UP_TO_FRAME = 1;
expect($cuboidCountFirstFrame.length).to.be.equal($cuboidCountThirdFrame.length); cy.goCheckFrameNumber(FROM_FRAME);
}); cy.createCuboid(createCuboidShape2Points);
}); startPropagation();
cy.goCheckFrameNumber(1); // Go to 2nd frame setupUpToFrame(UP_TO_FRAME);
cy.get('.cvat_canvas_shape_cuboid').then(($cuboidCountSecondFrame) => { cy.contains('button', 'Yes').click();
expect($cuboidCountSecondFrame.length).to.be.equal(2);
}); for (let i = FROM_FRAME - 1; i >= UP_TO_FRAME; i--) {
cy.goCheckFrameNumber(3); // Go to 4th frame cy.goCheckFrameNumber(i);
cy.get('.cvat_canvas_shape_cuboid').should('have.length', 1);
}
cy.goCheckFrameNumber(UP_TO_FRAME - 1);
cy.get('.cvat_canvas_shape_cuboid').should('not.exist'); cy.get('.cvat_canvas_shape_cuboid').should('not.exist');
}); });
}); });

@ -14,11 +14,11 @@ context('Rotate all images feature.', () => {
} }
function imageRotate(direction = 'anticlockwise', deg) { function imageRotate(direction = 'anticlockwise', deg) {
cy.get('.cvat-rotate-canvas-control').trigger('mouseover'); cy.get('.cvat-rotate-canvas-control').trigger('mouseover').should('be.visible');
if (direction === 'clockwise') { if (direction === 'clockwise') {
cy.get('.cvat-rotate-canvas-controls-right').click(); cy.get('.cvat-rotate-canvas-controls-right').should('be.visible').click();
} else { } else {
cy.get('.cvat-rotate-canvas-controls-left').click(); cy.get('.cvat-rotate-canvas-controls-left').should('be.visible').click();
} }
checkDegRotate(deg); checkDegRotate(deg);
} }

@ -1,4 +1,5 @@
// Copyright (C) 2020-2022 Intel Corporation // Copyright (C) 2020-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -11,7 +12,7 @@ context('Check propagation work from the latest frame', () => {
const createRectangleShape2Points = { const createRectangleShape2Points = {
points: 'By 2 Points', points: 'By 2 Points',
type: 'Shape', type: 'Shape',
labelName: labelName, labelName,
firstX: 250, firstX: 250,
firstY: 350, firstY: 350,
secondX: 350, secondX: 350,
@ -35,7 +36,9 @@ context('Check propagation work from the latest frame', () => {
it('Try to propagate', () => { it('Try to propagate', () => {
cy.get('#cvat_canvas_shape_1').trigger('mousemove'); cy.get('#cvat_canvas_shape_1').trigger('mousemove');
cy.get('body').type('{ctrl}b'); cy.get('body').type('{ctrl}b');
cy.get('.ant-modal-content').find('.ant-btn-primary').click(); cy.get('.cvat-propagate-confirm-up-to-input').type(advancedConfigurationParams.segmentSize - 1);
cy.get('.ant-modal-content').find('.ant-btn-primary').should('be.disabled');
cy.get('.ant-modal-content').find('.ant-btn-default').click();
cy.get('.ant-notification-notice').should('not.exist'); cy.get('.ant-notification-notice').should('not.exist');
}); });
}); });

@ -171,7 +171,7 @@ context('Manipulations with masks', { scrollBehavior: false }, () => {
cy.get('.cvat-object-item-menu').within(() => { cy.get('.cvat-object-item-menu').within(() => {
cy.contains('button', 'Propagate').click(); cy.contains('button', 'Propagate').click();
}); });
cy.get('.cvat-propagate-confirm-object-up-to-frame').find('input') cy.get('.cvat-propagate-confirm-up-to-input').find('input')
.should('have.attr', 'value', serverFiles.length - 1); .should('have.attr', 'value', serverFiles.length - 1);
cy.contains('button', 'Yes').click(); cy.contains('button', 'Yes').click();
for (let i = 1; i < serverFiles.length; i++) { for (let i = 1; i < serverFiles.length; i++) {

@ -62,7 +62,9 @@ Cypress.Commands.add('activateOrganization', (organizationShortName) => {
.find('[role="menuitem"]') .find('[role="menuitem"]')
.filter(':contains("Organization")') .filter(':contains("Organization")')
.trigger('mouseover'); .trigger('mouseover');
cy.contains('.cvat-header-menu-organization-item', organizationShortName).click(); cy.contains('.cvat-header-menu-organization-item', organizationShortName)
.should('be.visible')
.click();
cy.get('.cvat-header-menu-user-dropdown').should('be.visible'); cy.get('.cvat-header-menu-user-dropdown').should('be.visible');
cy.get('.cvat-header-menu-user-dropdown-organization') cy.get('.cvat-header-menu-user-dropdown-organization')
.should('exist') .should('exist')

Loading…
Cancel
Save