Skip to content

Commit

Permalink
Supported interpolation for 3D cuboids (#5629)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev authored Feb 8, 2023
1 parent b263d87 commit 5e0160b
Show file tree
Hide file tree
Showing 35 changed files with 771 additions and 300 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- \[SDK\] Class to represent a project as a PyTorch dataset
(<https://github.com/opencv/cvat/pull/5523>)
- Grid view and multiple context images supported (<https://github.com/opencv/cvat/pull/5542>)
- Interpolation is now supported for 3D cuboids.
Tracks can be exported/imported to/from Datumaro and Sly Pointcloud formats (<https://github.com/opencv/cvat/pull/5629>)
- Support for custom file to job splits in tasks (server API & SDK only)
(<https://github.com/opencv/cvat/pull/5536>)
- \[SDK\] A PyTorch adapter setting to disable cache updates
Expand Down
14 changes: 13 additions & 1 deletion cvat-canvas3d/src/typescript/canvas3d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (C) 2021-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporation
// Copyright (C) 2022-2023 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

Expand All @@ -15,6 +15,8 @@ import {
ShapeProperties,
GroupData,
Configuration,
SplitData,
MergeData,
} from './canvas3dModel';
import {
Canvas3dView, Canvas3dViewImpl, ViewsDOM, CameraAction,
Expand All @@ -38,6 +40,8 @@ interface Canvas3d {
fitCanvas(): void;
fit(): void;
group(groupData: GroupData): void;
merge(mergeData: MergeData): void;
split(splitData: SplitData): void;
destroy(): void;
}

Expand Down Expand Up @@ -80,6 +84,14 @@ class Canvas3dImpl implements Canvas3d {
this.model.group(groupData);
}

public split(splitData: SplitData): void {
this.model.split(splitData);
}

public merge(mergeData: MergeData): void {
this.model.merge(mergeData);
}

public isAbleToChangeFrame(): boolean {
return this.model.isAbleToChangeFrame();
}
Expand Down
15 changes: 13 additions & 2 deletions cvat-canvas3d/src/typescript/canvas3dController.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Copyright (C) 2021-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporation
// Copyright (C) 2022-2023 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

import { ObjectState } from '.';
import {
Canvas3dModel, Mode, DrawData, ActiveElement, GroupData, Configuration,
Canvas3dModel, Mode, DrawData, ActiveElement,
GroupData, Configuration, MergeData, SplitData,
} from './canvas3dModel';

export interface Canvas3dController {
Expand All @@ -17,6 +18,8 @@ export interface Canvas3dController {
readonly objects: ObjectState[];
mode: Mode;
group(groupData: GroupData): void;
merge(mergeData: MergeData): void;
split(splitData: SplitData): void;
}

export class Canvas3dControllerImpl implements Canvas3dController {
Expand Down Expand Up @@ -61,4 +64,12 @@ export class Canvas3dControllerImpl implements Canvas3dController {
public group(groupData: GroupData): void {
this.model.group(groupData);
}

public merge(mergeData: MergeData): void {
this.model.merge(mergeData);
}

public split(splitData: SplitData): void {
this.model.split(splitData);
}
}
53 changes: 49 additions & 4 deletions cvat-canvas3d/src/typescript/canvas3dModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (C) 2021-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporation
// Copyright (C) 2022-2023 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

Expand All @@ -18,7 +18,14 @@ export interface ActiveElement {

export interface GroupData {
enabled: boolean;
grouped: ObjectState[];
}

export interface MergeData {
enabled: boolean;
}

export interface SplitData {
enabled: boolean;
}

export interface Configuration {
Expand Down Expand Up @@ -80,6 +87,8 @@ export enum UpdateReasons {
DRAG_CANVAS = 'drag_canvas',
SHAPE_ACTIVATED = 'shape_activated',
GROUP = 'group',
MERGE = 'merge',
SPLIT = 'split',
FITTED_CANVAS = 'fitted_canvas',
CONFIG_UPDATED = 'config_updated',
SHAPES_CONFIG_UPDATED = 'shapes_config_updated',
Expand All @@ -91,6 +100,8 @@ export enum Mode {
EDIT = 'edit',
DRAG_CANVAS = 'drag_canvas',
GROUP = 'group',
MERGE = 'merge',
SPLIT = 'split',
}

export interface Canvas3dDataModel {
Expand All @@ -106,6 +117,8 @@ export interface Canvas3dDataModel {
objects: ObjectState[];
shapeProperties: ShapeProperties;
groupData: GroupData;
mergeData: MergeData;
splitData: SplitData;
configuration: Configuration;
isFrameUpdating: boolean;
nextSetupRequest: {
Expand All @@ -119,6 +132,7 @@ export interface Canvas3dModel {
data: Canvas3dDataModel;
readonly imageIsDeleted: boolean;
readonly groupData: GroupData;
readonly mergeData: MergeData;
readonly configuration: Configuration;
readonly objects: ObjectState[];
setup(frameData: any, objectStates: ObjectState[]): void;
Expand All @@ -131,6 +145,8 @@ export interface Canvas3dModel {
configure(configuration: Configuration): void;
fit(): void;
group(groupData: GroupData): void;
split(splitData: SplitData): void;
merge(mergeData: MergeData): void;
destroy(): void;
updateCanvasObjects(): void;
unlockFrameUpdating(): void;
Expand Down Expand Up @@ -166,7 +182,12 @@ export class Canvas3dModelImpl extends MasterImpl implements Canvas3dModel {
mode: Mode.IDLE,
groupData: {
enabled: false,
grouped: [],
},
mergeData: {
enabled: false,
},
splitData: {
enabled: false,
},
shapeProperties: {
opacity: 40,
Expand Down Expand Up @@ -343,10 +364,30 @@ export class Canvas3dModelImpl extends MasterImpl implements Canvas3dModel {
return;
}
this.data.mode = groupData.enabled ? Mode.GROUP : Mode.IDLE;
this.data.groupData = { ...this.data.groupData, ...groupData };
this.data.groupData = { ...groupData };
this.notify(UpdateReasons.GROUP);
}

public split(splitData: SplitData): void {
if (![Mode.IDLE, Mode.SPLIT].includes(this.data.mode)) {
throw Error(`Canvas is busy. Action: ${this.data.mode}`);
}

this.data.mode = splitData.enabled ? Mode.SPLIT : Mode.IDLE;
this.data.splitData = { ...splitData };
this.notify(UpdateReasons.SPLIT);
}

public merge(mergeData: MergeData): void {
if (![Mode.IDLE, Mode.MERGE].includes(this.data.mode)) {
throw Error(`Canvas is busy. Action: ${this.data.mode}`);
}

this.data.mode = mergeData.enabled ? Mode.MERGE : Mode.IDLE;
this.data.mergeData = { ...mergeData };
this.notify(UpdateReasons.MERGE);
}

public configure(configuration: Configuration): void {
if (typeof configuration.resetZoom === 'boolean') {
this.data.configuration.resetZoom = configuration.resetZoom;
Expand Down Expand Up @@ -391,6 +432,10 @@ export class Canvas3dModelImpl extends MasterImpl implements Canvas3dModel {
return { ...this.data.groupData };
}

public get mergeData(): MergeData {
return { ...this.data.mergeData };
}

public get imageIsDeleted(): boolean {
return this.data.imageIsDeleted;
}
Expand Down
Loading

0 comments on commit 5e0160b

Please sign in to comment.