Some minor fixes (#212)

* Fixed: single point wasn't created in right scenario, double press N (without any point) created a point
* Fixed: merge didn't create outside objects in some cases
* Fixed: split didn't work right
* Object selection propagated to next frame
main
Boris Sekachev 7 years ago committed by Nikita Manovich
parent d4ce6216d6
commit 076899afa3

@ -525,6 +525,7 @@ class ShapeCollectionModel extends Listener {
} }
this._frame = frame; this._frame = frame;
this._interpolate(); this._interpolate();
this.selectShape(this._lastPos, false);
} }
else { else {
this._clear(); this._clear();

@ -245,6 +245,8 @@ class ShapeCreatorView {
y: null, y: null,
}; };
let numberOfPoints = 0;
if (this._polyShapeSize) { if (this._polyShapeSize) {
let size = this._polyShapeSize; let size = this._polyShapeSize;
let sizeDecrement = function() { let sizeDecrement = function() {
@ -272,6 +274,7 @@ class ShapeCreatorView {
x: e.detail.event.clientX, x: e.detail.event.clientX,
y: e.detail.event.clientY, y: e.detail.event.clientY,
}; };
numberOfPoints ++;
}); });
this._drawInstance.on('drawpoint', (e) => { this._drawInstance.on('drawpoint', (e) => {
@ -279,17 +282,23 @@ class ShapeCreatorView {
x: e.detail.event.clientX, x: e.detail.event.clientX,
y: e.detail.event.clientY, y: e.detail.event.clientY,
}; };
numberOfPoints ++;
}); });
this._frameContent.on('mousedown.shapeCreator', (e) => { this._frameContent.on('mousedown.shapeCreator', (e) => {
if (e.which === 3) { if (e.which === 3) {
let lenBefore = this._drawInstance.array().value.length;
this._drawInstance.draw('undo'); this._drawInstance.draw('undo');
let lenAfter = this._drawInstance.array().value.length;
if (lenBefore != lenAfter) {
numberOfPoints --;
}
} }
}); });
this._frameContent.on('mousemove.shapeCreator', (e) => { this._frameContent.on('mousemove.shapeCreator', (e) => {
if (e.shiftKey && this._type != 'points') { if (e.shiftKey && ['polygon', 'polyline'].includes(this._type)) {
if (lastPoint.x === null || lastPoint.y === null) { if (lastPoint.x === null || lastPoint.y === null) {
this._drawInstance.draw('point', e); this._drawInstance.draw('point', e);
} }
@ -339,9 +348,9 @@ class ShapeCreatorView {
let w = polybox.width; let w = polybox.width;
let h = polybox.height; let h = polybox.height;
let area = w * h; let area = w * h;
let type = this.type; let type = this._type;
if (area >= AREA_TRESHOLD || type === 'points' || type === 'polyline' && (w >= AREA_TRESHOLD || h >= AREA_TRESHOLD)) { if (area >= AREA_TRESHOLD || type === 'points' && numberOfPoints || type === 'polyline' && (w >= AREA_TRESHOLD || h >= AREA_TRESHOLD)) {
this._controller.finish({points: actualPoints}, type); this._controller.finish({points: actualPoints}, type);
} }
} }

@ -134,15 +134,20 @@ class ShapeMergerModel extends Listener {
} }
) )
); );
}
// if last is annotation box, push outside // push an outsided box after each annotation box if next frame is empty
if (shapeDict[sortedFrames[sortedFrames.length - 1]].shape.type === 'annotation_box') { let nextFrame = frame + 1;
let stopFrame = window.cvat.player.frames.stop;
let type = shapeDict[frame].shape.type;
if (type === 'annotation_box' && !(nextFrame in shapeDict) && nextFrame <= stopFrame) {
let copy = Object.assign({}, object.shapes[object.shapes.length - 1]); let copy = Object.assign({}, object.shapes[object.shapes.length - 1]);
copy.outside = true; copy.outside = true;
copy.frame += 1; copy.frame += 1;
copy.z_order = this._collectionModel.zOrder(frame).max;
copy.attributes = [];
object.shapes.push(copy); object.shapes.push(copy);
} }
}
Logger.addEvent(Logger.EventType.mergeObjects, { Logger.addEvent(Logger.EventType.mergeObjects, {
count: this._shapesForMerge.length, count: this._shapesForMerge.length,

@ -28,7 +28,7 @@ class ShapeSplitter {
split(track, frame) { split(track, frame) {
let keyFrames = track.keyframes.sort((a,b) => a - b); let keyFrames = track.keyframes.sort((a,b) => a - b);
let exported = track.export(); let exported = track.export();
if (frame > keyFrames[0]) { if (frame > +keyFrames[0]) {
let curInterpolation = track.interpolate(frame); let curInterpolation = track.interpolate(frame);
let prevInterpolation = track.interpolate(frame - 1); let prevInterpolation = track.interpolate(frame - 1);
let curAttributes = this._convertMutableAttributes(curInterpolation.attributes); let curAttributes = this._convertMutableAttributes(curInterpolation.attributes);
@ -45,13 +45,20 @@ class ShapeSplitter {
} }
} }
if (!prevInterpolation.position.outside && track.type.split('_')[1] === 'box') { if (track.type.split('_')[1] === 'box') {
prevPositionList.push(Object.assign(prevInterpolation.position, { prevPositionList.push(Object.assign({}, prevInterpolation.position, {
frame: frame - 1,
attributes: prevAttrributes,
}));
if (!prevInterpolation.position.outside) {
prevPositionList.push(Object.assign({}, prevInterpolation.position, {
outside: true, outside: true,
frame: frame, frame: frame,
attributes: prevAttrributes, attributes: [],
})); }));
} }
}
curPositionList.push(Object.assign(curInterpolation.position, { curPositionList.push(Object.assign(curInterpolation.position, {
frame: frame, frame: frame,

Loading…
Cancel
Save