提交 076899af 编写于 作者: B Boris Sekachev 提交者: Nikita Manovich

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
上级 d4ce6216
......@@ -525,6 +525,7 @@ class ShapeCollectionModel extends Listener {
}
this._frame = frame;
this._interpolate();
this.selectShape(this._lastPos, false);
}
else {
this._clear();
......
......@@ -245,6 +245,8 @@ class ShapeCreatorView {
y: null,
};
let numberOfPoints = 0;
if (this._polyShapeSize) {
let size = this._polyShapeSize;
let sizeDecrement = function() {
......@@ -272,6 +274,7 @@ class ShapeCreatorView {
x: e.detail.event.clientX,
y: e.detail.event.clientY,
};
numberOfPoints ++;
});
this._drawInstance.on('drawpoint', (e) => {
......@@ -279,17 +282,23 @@ class ShapeCreatorView {
x: e.detail.event.clientX,
y: e.detail.event.clientY,
};
numberOfPoints ++;
});
this._frameContent.on('mousedown.shapeCreator', (e) => {
if (e.which === 3) {
let lenBefore = this._drawInstance.array().value.length;
this._drawInstance.draw('undo');
let lenAfter = this._drawInstance.array().value.length;
if (lenBefore != lenAfter) {
numberOfPoints --;
}
}
});
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) {
this._drawInstance.draw('point', e);
}
......@@ -339,9 +348,9 @@ class ShapeCreatorView {
let w = polybox.width;
let h = polybox.height;
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);
}
}
......
......@@ -134,15 +134,20 @@ class ShapeMergerModel extends Listener {
}
)
);
}
// if last is annotation box, push outside
if (shapeDict[sortedFrames[sortedFrames.length - 1]].shape.type === 'annotation_box') {
// push an outsided box after each annotation box if next frame is empty
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]);
copy.outside = true;
copy.frame += 1;
copy.z_order = this._collectionModel.zOrder(frame).max;
copy.attributes = [];
object.shapes.push(copy);
}
}
Logger.addEvent(Logger.EventType.mergeObjects, {
count: this._shapesForMerge.length,
......
......@@ -28,7 +28,7 @@ class ShapeSplitter {
split(track, frame) {
let keyFrames = track.keyframes.sort((a,b) => a - b);
let exported = track.export();
if (frame > keyFrames[0]) {
if (frame > +keyFrames[0]) {
let curInterpolation = track.interpolate(frame);
let prevInterpolation = track.interpolate(frame - 1);
let curAttributes = this._convertMutableAttributes(curInterpolation.attributes);
......@@ -45,13 +45,20 @@ class ShapeSplitter {
}
}
if (!prevInterpolation.position.outside && track.type.split('_')[1] === 'box') {
prevPositionList.push(Object.assign(prevInterpolation.position, {
if (track.type.split('_')[1] === 'box') {
prevPositionList.push(Object.assign({}, prevInterpolation.position, {
frame: frame - 1,
attributes: prevAttrributes,
}));
if (!prevInterpolation.position.outside) {
prevPositionList.push(Object.assign({}, prevInterpolation.position, {
outside: true,
frame: frame,
attributes: prevAttrributes,
attributes: [],
}));
}
}
curPositionList.push(Object.assign(curInterpolation.position, {
frame: frame,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册