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 dextr, fixed moving of the canvas #1573

Merged
merged 5 commits into from
May 22, 2020
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
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Task/Job buttons has no "Open in new tab" option (<https://github.com/opencv/cvat/pull/1419>)
- Delete point context menu option has no shortcut hint (<https://github.com/opencv/cvat/pull/1416>)
- Fixed issue with unnecessary tag activation in cvat-canvas (<https://github.com/opencv/cvat/issues/1540>)
- Fixed an issue with large number of instances in instance mask (https://github.com/opencv/cvat/issues/1539)
- Fixed full COCO dataset import error with conflicting labels in keypoints and detection (https://github.com/opencv/cvat/pull/1548)
- Fixed COCO keypoints skeleton parsing and saving (https://github.com/opencv/cvat/issues/1539)
- Fixed an issue with large number of instances in instance mask (<https://github.com/opencv/cvat/issues/1539>)
- Fixed full COCO dataset import error with conflicting labels in keypoints and detection (<https://github.com/opencv/cvat/pull/1548>)
- Fixed COCO keypoints skeleton parsing and saving (<https://github.com/opencv/cvat/issues/1539>)
- Canvas cannot be moved with move functionality on left mouse key (<https://github.com/opencv/cvat/pull/1573>)
- Deep extreme cut request is sent when draw any shape with Make AI polygon option enabled (<https://github.com/opencv/cvat/pull/1573>)

### Security
-
Expand Down
2 changes: 1 addition & 1 deletion cvat-canvas/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cvat-canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-canvas",
"version": "1.1.0",
"version": "1.1.1",
"description": "Part of Computer Vision Annotation Tool which presents its canvas library",
"main": "src/canvas.ts",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions cvat-canvas/src/typescript/canvasView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ export class CanvasViewImpl implements CanvasView, Listener {
self.onEditDone(
state,
points,
)
);
e.preventDefault();
return;
}
Expand Down Expand Up @@ -687,7 +687,7 @@ export class CanvasViewImpl implements CanvasView, Listener {

this.content.addEventListener('mousedown', (event): void => {
if ([0, 1].includes(event.button)) {
if ([Mode.IDLE, Mode.DRAG, Mode.MERGE, Mode.SPLIT].includes(this.mode)
if ([Mode.IDLE, Mode.DRAG_CANVAS, Mode.MERGE, Mode.SPLIT].includes(this.mode)
|| event.button === 1 || event.altKey
) {
self.controller.enableDrag(event.clientX, event.clientY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ function DrawShapePopoverComponent(props: Props): JSX.Element {
onChangeCuboidDrawingMethod,
} = props;

const trackDisabled = shapeType === ShapeType.POLYGON || shapeType === ShapeType.POLYLINE
const trackDisabled = shapeType === ShapeType.POLYGON
|| shapeType === ShapeType.POLYLINE
|| (shapeType === ShapeType.POINTS && numberOfPoints !== 1);

return (
Expand Down Expand Up @@ -85,9 +86,7 @@ function DrawShapePopoverComponent(props: Props): JSX.Element {
</Select>
</Col>
</Row>
{
shapeType === ShapeType.POLYGON && <DEXTRPlugin />
}
{ shapeType === ShapeType.POLYGON && <DEXTRPlugin /> }
{
shapeType === ShapeType.RECTANGLE && (
<>
Expand Down Expand Up @@ -183,19 +182,14 @@ function DrawShapePopoverComponent(props: Props): JSX.Element {
<Row type='flex' justify='space-around'>
<Col span={12}>
<Tooltip title={`Press ${repeatShapeShortcut} to draw again`}>
<Button
onClick={onDrawShape}
>
<Button onClick={onDrawShape}>
Shape
</Button>
</Tooltip>
</Col>
<Col span={12}>
<Tooltip title={`Press ${repeatShapeShortcut} to draw again`}>
<Button
onClick={onDrawTrack}
disabled={trackDisabled}
>
<Button onClick={onDrawTrack} disabled={trackDisabled}>
Track
</Button>
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,7 @@ class DrawShapePopoverContainer extends React.PureComponent<Props, State> {
}

private onDraw(objectType: ObjectType): void {
const {
canvasInstance,
shapeType,
onDrawStart,
} = this.props;
const { canvasInstance, shapeType, onDrawStart } = this.props;

const {
rectDrawingMethod,
Expand Down Expand Up @@ -143,8 +139,8 @@ class DrawShapePopoverContainer extends React.PureComponent<Props, State> {
private onChangeCuboidDrawingMethod = (event: RadioChangeEvent): void => {
this.setState({
cuboidDrawingMethod: event.target.value,
})
}
});
};

private onDrawShape = (): void => {
this.onDraw(ObjectType.SHAPE);
Expand Down
2 changes: 1 addition & 1 deletion cvat-ui/src/cvat-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Reducer,
} from 'redux';
import { createLogger } from 'redux-logger';
import {isDev} from 'utils/enviroment';
import { isDev } from 'utils/enviroment';


const logger = createLogger({
Expand Down
106 changes: 57 additions & 49 deletions cvat-ui/src/utils/dextr-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import getCore from 'cvat-core-wrapper';
import { Canvas } from 'cvat-canvas-wrapper';
import { ShapeType, RQStatus } from 'reducers/interfaces';
import { ShapeType, RQStatus, CombinedState } from 'reducers/interfaces';
import { getCVATStore } from 'cvat-store';

const core = getCore();
const baseURL = core.config.backendAPI.slice(0, -7);
Expand Down Expand Up @@ -145,6 +146,60 @@ function serverRequest(
});
}

async function enter(this: any, self: DEXTRPlugin, objects: any[]): Promise<void> {
try {
if (self.data.enabled && objects.length === 1) {
const state = (getCVATStore().getState() as CombinedState);
const isPolygon = state.annotation
.drawing.activeShapeType === ShapeType.POLYGON;
if (!isPolygon) return;

document.body.append(antModalRoot);
const promises: Record<number, Promise<number[]>> = {};
for (let i = 0; i < objects.length; i++) {
if (objects[i].points.length >= 8) {
promises[i] = serverRequest(
self,
this.id,
objects[i].frame,
objects[i].points,
);
} else {
promises[i] = new Promise((resolve) => {
resolve(objects[i].points);
});
}
}

const transformed = await Promise
.all(Object.values(promises));
for (let i = 0; i < objects.length; i++) {
// eslint-disable-next-line no-param-reassign
objects[i] = new core.classes.ObjectState({
frame: objects[i].frame,
objectType: objects[i].objectType,
label: objects[i].label,
shapeType: ShapeType.POLYGON,
points: transformed[i],
occluded: objects[i].occluded,
zOrder: objects[i].zOrder,
});
}
}

return;
} catch (error) {
throw new core.exceptions.PluginError(error.toString());
} finally {
// eslint-disable-next-line no-param-reassign
self.data.canceled = false;
antModalButton.disabled = true;
if (antModalRoot.parentElement === document.body) {
document.body.removeChild(antModalRoot);
}
}
}

const plugin: DEXTRPlugin = {
name: 'Deep extreme cut',
description: 'Plugin allows to get a polygon from extreme points using AI',
Expand All @@ -154,54 +209,7 @@ const plugin: DEXTRPlugin = {
prototype: {
annotations: {
put: {
async enter(self: DEXTRPlugin, objects: any[]): Promise<void> {
try {
if (self.data.enabled) {
document.body.append(antModalRoot);
const promises: Record<number, Promise<number[]>> = {};
for (let i = 0; i < objects.length; i++) {
if (objects[i].points.length >= 8) {
promises[i] = serverRequest(
self,
(this as any).id,
objects[i].frame,
objects[i].points,
);
} else {
promises[i] = new Promise((resolve) => {
resolve(objects[i].points);
});
}
}

const transformed = await Promise
.all(Object.values(promises));
for (let i = 0; i < objects.length; i++) {
// eslint-disable-next-line no-param-reassign
objects[i] = new core.classes.ObjectState({
frame: objects[i].frame,
objectType: objects[i].objectType,
label: objects[i].label,
shapeType: ShapeType.POLYGON,
points: transformed[i],
occluded: objects[i].occluded,
zOrder: objects[i].zOrder,
});
}
}

return;
} catch (error) {
throw new core.exceptions.PluginError(error.toString());
} finally {
// eslint-disable-next-line no-param-reassign
self.data.canceled = false;
antModalButton.disabled = true;
if (antModalRoot.parentElement === document.body) {
document.body.removeChild(antModalRoot);
}
}
},
enter,
},
},
},
Expand Down