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 all 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
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();
});
});
});
Loading