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

Fixed using single shape annotation mode with multiple labels #7606

Merged
merged 6 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
4 changes: 4 additions & 0 deletions changelog.d/20240314_105752_boris_fixed_ssa.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Fixed

- Using single shape annotation mode with multiple labels
(<https://github.com/opencv/cvat/pull/XXXX>)
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ import Alert from 'antd/lib/alert';
import Modal from 'antd/lib/modal';
import Button from 'antd/lib/button';

import { CombinedState, NavigationType } from 'reducers';
import { CombinedState, NavigationType, ObjectType } from 'reducers';
import { Canvas, CanvasMode } from 'cvat-canvas-wrapper';
import {
Job, JobState, Label, LabelType,
} from 'cvat-core-wrapper';
import { ActionUnion, createAction } from 'utils/redux';
import { changeFrameAsync, saveAnnotationsAsync, setNavigationType } from 'actions/annotation-actions';
import {
rememberObject, changeFrameAsync, saveAnnotationsAsync, setNavigationType,
} from 'actions/annotation-actions';
import LabelSelector from 'components/label-selector/label-selector';
import GlobalHotKeys from 'utils/mousetrap-react';

Expand Down Expand Up @@ -219,6 +221,11 @@ function SingleShapeSidebar(): JSX.Element {
canvasInitializerRef.current = (): void => {
const canvas = store.getState().annotation.canvas.instance as Canvas;
if (isCanvasReady && canvas.mode() !== CanvasMode.DRAW && state.label && state.labelType !== LabelType.ANY) {
appDispatch(rememberObject({
activeLabelID: state.label.id,
activeObjectType: ObjectType.SHAPE,
}));

canvas.draw({
enabled: true,
shapeType: state.labelType,
Expand Down
24 changes: 24 additions & 0 deletions tests/cypress/e2e/features/single_object_annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ context('Single object annotation mode', { scrollBehavior: false }, () => {
submitJob();
}

function changeLabel(labelName) {
cy.get('.cvat-single-shape-annotation-sidebar-label-select').click();
cy.get('.ant-select-dropdown').not('.ant-select-dropdown-hidden').within(() => {
cy.get('.ant-select-item-option-content').contains(labelName).click();
});
}

before(() => {
cy.visit('auth/login');
cy.login();
Expand Down Expand Up @@ -228,6 +235,23 @@ context('Single object annotation mode', { scrollBehavior: false }, () => {
cy.get('.cvat-player-next-button').click();
checkFrameNum(2);

// Change label and draw an object,
const anotherLabelName = 'points_label';

bsekachev marked this conversation as resolved.
Show resolved Hide resolved
bsekachev marked this conversation as resolved.
Show resolved Hide resolved
cy.get('.cvat-single-shape-annotation-sidebar-navigate-empty-checkbox').within(() => {
cy.get('[type="checkbox"]').check();
});
cy.get('.cvat-player-previous-button-empty').click();

changeLabel(anotherLabelName);
clickPoints(pointsShape);

// be sure the object has correct label
cy.changeWorkspace('Standard');
cy.get(`#cvat-objects-sidebar-state-item-${frameCount}`).within(() => {
cy.get('.cvat-objects-sidebar-state-item-label-selector').should('have.text', anotherLabelName);
});
bsekachev marked this conversation as resolved.
Show resolved Hide resolved

cy.saveJob();
});
});
Expand Down
Loading