-
Notifications
You must be signed in to change notification settings - Fork 15
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
Video single frame annotation #1019
base: master
Are you sure you want to change the base?
Changes from all commits
787630e
867a7bd
f4d4478
9f6ec6d
231fa11
5261bf0
a79da52
3cd67f8
97b7239
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,21 +7,35 @@ import VectorLayer from '@biigle/ol/layer/Vector'; | |
import VectorSource from '@biigle/ol/source/Vector'; | ||
import snapInteraction from "./snapInteraction.vue"; | ||
import { isInvalidShape } from '../../../annotations/utils'; | ||
import { Point } from '@biigle/ol/geom'; | ||
import { computeDistance } from '../../utils'; | ||
|
||
/** | ||
* Mixin for the videoScreen component that contains logic for the draw interactions. | ||
* | ||
* @type {Object} | ||
*/ | ||
|
||
const POINT_CLICK_COOLDOWN = 400; | ||
const POINT_CLICK_DISTANCE = 5; | ||
|
||
export default { | ||
mixins: [snapInteraction], | ||
data() { | ||
return { | ||
pendingAnnotation: {}, | ||
autoplayDrawTimeout: null, | ||
drawEnded: true, | ||
lastDrawnPoint: new Point(0, 0), | ||
lastDrawnPointTime: 0, | ||
}; | ||
}, | ||
props: { | ||
singleAnnotation: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}, | ||
computed: { | ||
hasSelectedLabel() { | ||
return !!this.selectedLabel; | ||
|
@@ -199,13 +213,19 @@ export default { | |
let lastFrame = this.pendingAnnotation.frames[this.pendingAnnotation.frames.length - 1]; | ||
|
||
if (lastFrame === undefined || lastFrame < this.video.currentTime) { | ||
this.pendingAnnotation.frames.push(this.video.currentTime); | ||
this.pendingAnnotation.points.push(this.getPointsFromGeometry(e.feature.getGeometry())); | ||
if (this.singleAnnotation && this.isPointDoubleClick(e)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't you have to check |
||
this.pendingAnnotationSource.once('addfeature', function (e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add the explanation:
|
||
this.removeFeature(e.feature); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't you return here and skip the rest of the function? |
||
} else { | ||
this.pendingAnnotation.frames.push(this.video.currentTime); | ||
this.pendingAnnotation.points.push(this.getPointsFromGeometry(e.feature.getGeometry())); | ||
|
||
if (!this.video.ended && this.autoplayDraw > 0) { | ||
this.play(); | ||
window.clearTimeout(this.autoplayDrawTimeout); | ||
this.autoplayDrawTimeout = window.setTimeout(this.pause, this.autoplayDraw * 1000); | ||
if (!this.video.ended && this.autoplayDraw > 0) { | ||
this.play(); | ||
window.clearTimeout(this.autoplayDrawTimeout); | ||
this.autoplayDrawTimeout = window.setTimeout(this.pause, this.autoplayDraw * 1000); | ||
} | ||
} | ||
} else { | ||
// If the pending annotation (time) is invalid, remove it again. | ||
|
@@ -217,6 +237,22 @@ export default { | |
} | ||
|
||
this.$emit('pending-annotation', this.pendingAnnotation); | ||
|
||
if (this.singleAnnotation) { | ||
if (this.isDrawingPoint) { | ||
if (this.isPointDoubleClick(e)) { | ||
this.resetPendingAnnotation(this.pendingAnnotation.shape); | ||
return; | ||
} | ||
this.lastDrawnPointTime = new Date().getTime(); | ||
this.lastDrawnPoint = e.feature.getGeometry(); | ||
} | ||
this.pendingAnnotationSource.once('addfeature', this.finishDrawAnnotation); | ||
} | ||
Comment on lines
+241
to
+251
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel all this can be added to the |
||
}, | ||
isPointDoubleClick(e) { | ||
return new Date().getTime() - this.lastDrawnPointTime < POINT_CLICK_COOLDOWN | ||
&& computeDistance(this.lastDrawnPoint, e.feature.getGeometry()) < POINT_CLICK_DISTANCE; | ||
}, | ||
}, | ||
created() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,10 @@ | |
<div class="sidebar-tab__section"> | ||
<power-toggle :active="muteVideo" title-off="Mute video" title-on="Unmute video" v-on:on="handleMuteVideo" v-on:off="handleUnmuteVideo">Mute Video</power-toggle> | ||
</div> | ||
|
||
<div class="sidebar-tab__section"> | ||
<power-toggle :active="singleAnnotation" title-off="Enable Single-Frame Annotation" title-on="Disable Single-Frame Annotation" v-on:on="handleSingleAnnotation" v-on:off="handleDisableSingleAnnotation">Single-Frame Annotation</power-toggle> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The title is not very helpful. What about "Enable always creating single-frame annotations" (and "Disable ...")? |
||
</div> | ||
</div> | ||
</settings-tab> | ||
</sidebar-tab> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
computeDistance
and the constants are used both in the image annotation tool and the video annotation tool, please create a new file for these and reuse the same function/constants in both tools.