Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
25 changes: 24 additions & 1 deletion client/dive-common/components/ConfidenceSubsection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export default defineComponent({
type: Boolean,
default: false,
},
userModified: {
type: Boolean,
default: false,
},
},
setup() {
const typeStylingRef = useTrackStyleManager().typeStyling;
Expand Down Expand Up @@ -86,7 +90,7 @@ export default defineComponent({
}"
/>
</v-col>
<v-col :cols="pair[1] !== 1 && !disabled ? '7' : '8'">
<v-col :cols="pair[1] !== 1 && !disabled ? '6' : '7'">
{{ pair[0] }}
</v-col>
<v-spacer />
Expand All @@ -96,9 +100,28 @@ export default defineComponent({
>
{{ pair[1].toFixed(4) }}
</v-col>
<v-col v-if="userModified && index === 0" cols="1">
<v-tooltip
open-delay="200"
bottom
>
<template #activator="{ on }">
<v-icon
small
color="orange"
class="ml-1"
v-on="on"
>
mdi-pencil
</v-icon>
</template>
<span>This annotation has been modified by a user</span>
</v-tooltip>
</v-col>
<v-col
v-if="pair[1] !== 1 && !disabled"
class="shrink"
cols="1"
>
<v-tooltip
open-delay="200"
Expand Down
28 changes: 25 additions & 3 deletions client/dive-common/components/TrackDetailsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
useSelectedCamera,
} from 'vue-media-annotator/provides';
import { Attribute } from 'vue-media-annotator/use/AttributeTypes';
import type Track from 'src/track';
import TrackItem from 'vue-media-annotator/components/TrackItem.vue';
import TooltipBtn from 'vue-media-annotator/components/TooltipButton.vue';
import TypePicker from 'vue-media-annotator/components/TypePicker.vue';
Expand Down Expand Up @@ -106,14 +107,24 @@ export default defineComponent({
if (multiSelectList.value.length > 0) {
return multiSelectList.value.map(
(trackId) => cameraStore.getAnyPossibleTrack(trackId),
).filter((t) => t !== undefined);
).filter((t): t is Track => t !== undefined);
}
if (selectedTrackIdRef.value !== null) {
return [cameraStore.getAnyTrack(selectedTrackIdRef.value)];
const track = cameraStore.getAnyTrack(selectedTrackIdRef.value);
return track ? [track] : [];
}
return [];
});

const isUserModified = computed(() => {
if (selectedTrackList.value.length === 1) {
const track = selectedTrackList.value[0];
const [feature] = track.getFeature(frameRef.value);
return feature?.attributes?.userModified === true;
}
return false;
});

function setEditIndividual(attribute: Attribute | null) {
editIndividual.value = attribute;
}
Expand Down Expand Up @@ -227,6 +238,14 @@ export default defineComponent({
});
}

function setTrackType(type: string) {
const track = selectedTrackList.value[0];
// Find the confidence value for this type in the track's confidence pairs
const existingPair = track.confidencePairs.find(([t]) => t === type);
const confidenceVal = existingPair ? existingPair[1] : 1;
track.setType(type, confidenceVal);
}

return {
selectedTrackIdRef,
editingGroupIdRef,
Expand All @@ -245,6 +264,7 @@ export default defineComponent({
frameRef,
/* Selected */
selectedTrackList,
isUserModified,
multiSelectList,
multiSelectInProgress,
editingMultiTrack,
Expand All @@ -266,6 +286,7 @@ export default defineComponent({
toggleMerge,
unstageFromMerge,
updateSelectedTracksType,
setTrackType,
};
},
});
Expand Down Expand Up @@ -569,7 +590,8 @@ export default defineComponent({
flatten(selectedTrackList.map((t) => t.confidencePairs)).sort((a, b) => b[1] - a[1])
"
:disabled="selectedTrackList.length > 1"
@set-type="selectedTrackList[0].setType($event)"
:user-modified="isUserModified"
@set-type="setTrackType($event)"
/>
<attribute-subsection
v-if="!multiSelectInProgress"
Expand Down
17 changes: 16 additions & 1 deletion client/dive-common/use/useModeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,10 @@ export default function useModeManager({
const track = cameraStore.getPossibleTrack(selectedTrackId.value, selectedCamera.value);
if (track) {
// Determines if we are creating a new Detection
const { interpolate } = track.canInterpolate(frameNum);
const { interpolate, features } = track.canInterpolate(frameNum);
const [real] = features;
// If there's already a keyframe at this frame, we're editing an existing annotation
const isEditingExisting = real !== null && real.keyframe;

track.setFeature({
frame: frameNum,
Expand All @@ -409,6 +412,10 @@ export default function useModeManager({
keyframe: true,
interpolate: _shouldInterpolate(interpolate),
});
// Mark as user-modified if editing existing annotation (as detection attribute)
if (isEditingExisting) {
track.setFeatureAttribute(frameNum, 'userModified', true);
}
newTrackSettingsAfterLogic(track);
}
}
Expand Down Expand Up @@ -507,6 +514,9 @@ export default function useModeManager({
}
// Update the state of the track in the trackstore.
if (somethingChanged) {
// If there's already a keyframe at this frame, we're editing an existing annotation
const isEditingExisting = real !== null && real.keyframe;

track.setFeature({
frame: frameNum,
flick: flickNum,
Expand All @@ -522,6 +532,11 @@ export default function useModeManager({
})),
));

// Mark as user-modified if editing existing annotation (as detection attribute)
if (isEditingExisting) {
track.setFeatureAttribute(frameNum, 'userModified', true);
}

// Only perform "initialization" after the first shape.
// Treat this as a completed annotation if eventType is editing
// Or none of the recieps reported that they were unfinished.
Expand Down
8 changes: 5 additions & 3 deletions client/src/layers/AnnotationLayers/TextLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ function defaultFormatter(
const [type, confidence] = confidencePairs[i];

let text = '';
const userModified = annotation.features?.attributes?.userModified === true;
const modifiedIndicator = userModified ? ' ✏️' : '';
if (typeStyling) {
const { showLabel, showConfidence } = typeStyling.labelSettings(type);
if (showLabel && !showConfidence) {
text = type;
text = type + modifiedIndicator;
} else if (showConfidence && !showLabel) {
text = `${confidence.toFixed(2)}`;
text = `${confidence.toFixed(2)}${modifiedIndicator}`;
} else if (showConfidence && showLabel) {
text = `${type}: ${confidence.toFixed(2)}`;
text = `${type}: ${confidence.toFixed(2)}${modifiedIndicator}`;
}
}
arr.push({
Expand Down
Loading