Skip to content

Commit

Permalink
Fixed using single shape annotation mode with multiple labels (#7606)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev authored Mar 15, 2024
1 parent 1f661bc commit 9e605f4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
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
40 changes: 36 additions & 4 deletions tests/cypress/e2e/features/single_object_annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ 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();
});
}

function resetAfterTestCase() {
cy.removeAnnotations();
cy.saveJob('PUT');
}

before(() => {
cy.visit('auth/login');
cy.login();
Expand Down Expand Up @@ -147,10 +159,7 @@ context('Single object annotation mode', { scrollBehavior: false }, () => {
});

describe('Tests basic features of single shape annotation mode', () => {
afterEach(() => {
cy.removeAnnotations();
cy.saveJob('PUT');
});
afterEach(resetAfterTestCase);

it('Check basic single shape annotation pipeline for polygon', () => {
openJob({ defaultLabel: 'polygon_label', defaultPointsCount: 4 });
Expand Down Expand Up @@ -190,6 +199,8 @@ context('Single object annotation mode', { scrollBehavior: false }, () => {
});

describe('Tests advanced features of single shape annotation mode', () => {
afterEach(resetAfterTestCase);

it('Check single shape annotation mode controls', () => {
openJob({ defaultLabel: 'polygon_label', defaultPointsCount: 4 });
checkSingleShapeModeOpened();
Expand Down Expand Up @@ -231,4 +242,25 @@ context('Single object annotation mode', { scrollBehavior: false }, () => {
cy.saveJob();
});
});

describe('Regression tests', () => {
afterEach(resetAfterTestCase);

it('Changing labels in single shape annotation mode', () => {
openJob({ defaultLabel: 'polygon_label', defaultPointsCount: 4 });
checkSingleShapeModeOpened();

const anotherLabelName = 'points_label';
changeLabel(anotherLabelName);
clickPoints(pointsShape);

cy.changeWorkspace('Standard');
cy.goCheckFrameNumber(0);
cy.get('#cvat-objects-sidebar-state-item-1').within(() => {
cy.get('.cvat-objects-sidebar-state-item-label-selector').should('have.text', anotherLabelName);
});

cy.saveJob();
});
});
});

0 comments on commit 9e605f4

Please sign in to comment.