Skip to content

Commit

Permalink
CVAT-UI: Couple of fixes (#1892)
Browse files Browse the repository at this point in the history
* Polygon interpolation fix

* Fix interpolation issue

* Updated changelog
  • Loading branch information
bsekachev authored Jul 15, 2020
1 parent cb114b5 commit e92014e
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `outside` annotations should not be in exported images (<https://github.com/opencv/cvat/issues/1620>)
- `CVAT for video format` import error with interpolation (<https://github.com/opencv/cvat/issues/1893>)
- `Image compression` definition mismatch (<https://github.com/opencv/cvat/issues/1900>)
- Points are dublicated during polygon interpolation sometimes (<https://github.com/opencv/cvat/pull/1892>)
- When redraw a shape with activated autobordering, previous points are visible (<https://github.com/opencv/cvat/pull/1892>)

### 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": "2.0.0",
"version": "2.0.1",
"description": "Part of Computer Vision Annotation Tool which presents its canvas library",
"main": "src/canvas.ts",
"scripts": {
Expand Down
13 changes: 7 additions & 6 deletions cvat-canvas/src/typescript/autoborderHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ interface TransformedShape {
}

export interface AutoborderHandler {
autoborder(enabled: boolean, currentShape?: SVG.Shape, ignoreCurrent?: boolean): void;
autoborder(enabled: boolean, currentShape?: SVG.Shape, currentID?: number): void;
transform(geometry: Geometry): void;
updateObjects(): void;
}

export class AutoborderHandlerImpl implements AutoborderHandler {
private currentShape: SVG.Shape | null;
private ignoreCurrent: boolean;
private currentID?: number;
private frameContent: SVGSVGElement;
private enabled: boolean;
private scale: number;
Expand All @@ -34,7 +34,7 @@ export class AutoborderHandlerImpl implements AutoborderHandler {

public constructor(frameContent: SVGSVGElement) {
this.frameContent = frameContent;
this.ignoreCurrent = false;
this.currentID = undefined;
this.currentShape = null;
this.enabled = false;
this.scale = 1;
Expand Down Expand Up @@ -231,7 +231,8 @@ export class AutoborderHandlerImpl implements AutoborderHandler {
this.removeMarkers();

const currentClientID = this.currentShape.node.dataset.originClientId;
const shapes = Array.from(this.frameContent.getElementsByClassName('cvat_canvas_shape'));
const shapes = Array.from(this.frameContent.getElementsByClassName('cvat_canvas_shape'))
.filter((shape: HTMLElement): boolean => +shape.getAttribute('clientID') !== this.currentID);
const transformedShapes = shapes.map((shape: HTMLElement): TransformedShape | null => {
const color = shape.getAttribute('fill');
const clientID = shape.getAttribute('clientID');
Expand Down Expand Up @@ -277,12 +278,12 @@ export class AutoborderHandlerImpl implements AutoborderHandler {
public autoborder(
enabled: boolean,
currentShape?: SVG.Shape,
ignoreCurrent: boolean = false,
currentID?: number,
): void {
if (enabled && !this.enabled && currentShape) {
this.enabled = true;
this.currentShape = currentShape;
this.ignoreCurrent = ignoreCurrent;
this.currentID = currentID;
this.updateObjects();
} else {
this.release();
Expand Down
12 changes: 8 additions & 4 deletions cvat-canvas/src/typescript/drawHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ export class DrawHandlerImpl implements DrawHandler {

this.drawPolyshape();
if (this.autobordersEnabled) {
this.autoborderHandler.autoborder(true, this.drawInstance, false);
this.autoborderHandler.autoborder(true, this.drawInstance, this.drawData.redraw);
}
}

Expand All @@ -446,7 +446,7 @@ export class DrawHandlerImpl implements DrawHandler {

this.drawPolyshape();
if (this.autobordersEnabled) {
this.autoborderHandler.autoborder(true, this.drawInstance, false);
this.autoborderHandler.autoborder(true, this.drawInstance, this.drawData.redraw);
}
}

Expand Down Expand Up @@ -478,7 +478,7 @@ export class DrawHandlerImpl implements DrawHandler {

if (this.canceled) return;
if ((xbr - xtl) * (ybr - ytl) >= consts.AREA_THRESHOLD) {
const d = { x: (xbr - xtl) * 0.1, y: (ybr - ytl)*0.1}
const d = { x: (xbr - xtl) * 0.1, y: (ybr - ytl) * 0.1 };
this.onDrawDone({
shapeType,
points: cuboidFrom4Points([xtl, ybr, xbr, ybr, xbr, ytl, xbr + d.x, ytl - d.y]),
Expand Down Expand Up @@ -767,7 +767,11 @@ export class DrawHandlerImpl implements DrawHandler {
this.autobordersEnabled = configuration.autoborders;
if (this.drawInstance) {
if (this.autobordersEnabled) {
this.autoborderHandler.autoborder(true, this.drawInstance, false);
this.autoborderHandler.autoborder(
true,
this.drawInstance,
this.drawData.redraw,
);
} else {
this.autoborderHandler.autoborder(false);
}
Expand Down
8 changes: 6 additions & 2 deletions cvat-canvas/src/typescript/editHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class EditHandlerImpl implements EditHandler {

this.setupEditEvents();
if (this.autobordersEnabled) {
this.autoborderHandler.autoborder(true, this.editLine, true);
this.autoborderHandler.autoborder(true, this.editLine, this.editData.state.clientID);
}
}

Expand Down Expand Up @@ -376,7 +376,11 @@ export class EditHandlerImpl implements EditHandler {
this.autobordersEnabled = configuration.autoborders;
if (this.editLine) {
if (this.autobordersEnabled) {
this.autoborderHandler.autoborder(true, this.editLine, true);
this.autoborderHandler.autoborder(
true,
this.editLine,
this.editData.state.clientID,
);
} else {
this.autoborderHandler.autoborder(false);
}
Expand Down
2 changes: 1 addition & 1 deletion cvat-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-core",
"version": "3.1.0",
"version": "3.1.1",
"description": "Part of Computer Vision Tool which presents an interface for client-side integration",
"main": "babel.config.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion cvat-core/src/annotations-objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,7 @@
}

function matchRightLeft(leftCurve, rightCurve, leftRightMatching) {
const matchedRightPoints = Object.values(leftRightMatching);
const matchedRightPoints = Object.values(leftRightMatching).flat();
const unmatchedRightPoints = rightCurve.map((_, index) => index)
.filter((index) => !matchedRightPoints.includes(index));
const updatedMatching = { ...leftRightMatching };
Expand Down
3 changes: 2 additions & 1 deletion cvat/apps/dataset_manager/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from copy import copy, deepcopy

import numpy as np
from itertools import chain
from scipy.optimize import linear_sum_assignment
from shapely import geometry

Expand Down Expand Up @@ -523,7 +524,7 @@ def match_left_right(left_curve, right_curve):
return matching

def match_right_left(left_curve, right_curve, left_right_matching):
matched_right_points = left_right_matching.values()
matched_right_points = list(chain.from_iterable(left_right_matching.values()))
unmatched_right_points = filter(lambda x: x not in matched_right_points, range(len(right_curve)))
updated_matching = deepcopy(left_right_matching)

Expand Down

0 comments on commit e92014e

Please sign in to comment.