Update sub labels for previous timeline items

This commit is contained in:
Nick Mowen 2024-01-23 06:59:04 -07:00
parent 58d66c5353
commit fc259133ac
5 changed files with 28 additions and 27 deletions

View File

@ -85,12 +85,13 @@ class TimelineProcessor(threading.Thread):
"""Handle object detection."""
save = False
camera_config = self.config.cameras[camera]
event_id = event_data["id"]
timeline_entry = {
Timeline.timestamp: event_data["frame_time"],
Timeline.camera: camera,
Timeline.source: "tracked_object",
Timeline.source_id: event_data["id"],
Timeline.source_id: event_id,
Timeline.data: {
"box": to_relative_box(
camera_config.detect.width,
@ -107,6 +108,23 @@ class TimelineProcessor(threading.Thread):
"attribute": "",
},
}
# make sure all timeline items have a sub label
if prev_event_data != None and prev_event_data.get(
"sub_label"
) != event_data.get("sub_label"):
# update existing timeline items to have sub label
sub_label = event_data["sub_label"]
if sub_label[0] not in ALL_ATTRIBUTE_LABELS:
if event_id in self.pre_event_cache.keys():
for e in self.pre_event_cache[event_id]:
e[Timeline.data]["sub_label"] = sub_label
else:
Timeline.update(
data=Timeline.data.update({"sub_label": sub_label})
).where(Timeline.source_id == event_id).execute()
if event_type == "start":
timeline_entry[Timeline.class_type] = "visible"
save = True
@ -129,13 +147,6 @@ class TimelineProcessor(threading.Thread):
event_data["attributes"].keys()
)[0]
save = True
elif not prev_event_data.get("sub_label") and event_data.get("sub_label"):
sub_label = event_data["sub_label"][0]
if sub_label not in ALL_ATTRIBUTE_LABELS:
timeline_entry[Timeline.class_type] = "sub_label"
timeline_entry[Timeline.data]["sub_label"] = sub_label
save = True
elif event_type == "end":
timeline_entry[Timeline.class_type] = "gone"
save = True

View File

@ -52,7 +52,10 @@ export default function PreviewThumbnailPlayer({
}
if (!playerRef.current) {
setIsInitiallyVisible(true);
if (isHovered) {
setIsInitiallyVisible(true);
}
return;
}
@ -103,7 +106,7 @@ export default function PreviewThumbnailPlayer({
{
threshold: 1.0,
root: document.getElementById("pageRoot"),
rootMargin: "-15% 0px -15% 0px",
rootMargin: "-10% 0px -25% 0px",
}
);
if (node) autoPlayObserver.current.observe(node);

View File

@ -36,7 +36,6 @@ type Timeline = {
class_type:
| "visible"
| "gone"
| "sub_label"
| "entered_zone"
| "attribute"
| "active"

View File

@ -42,15 +42,6 @@ export function getTimelineIcon(timelineItem: Timeline) {
default:
return <LuTruck className="w-4 mr-1" />;
}
case "sub_label":
switch (timelineItem.data.label) {
case "person":
return <MdFaceUnlock className="w-4 mr-1" />;
case "car":
return <MdOutlinePictureInPictureAlt className="w-4 mr-1" />;
default:
return <LuCircleDot className="w-4 mr-1" />;
}
case "heard":
return <LuEar className="w-4 mr-1" />;
case "external":
@ -119,8 +110,6 @@ export function getTimelineItemDescription(timelineItem: Timeline) {
}
return title;
}
case "sub_label":
return `${timelineItem.data.label} recognized as ${timelineItem.data.sub_label}`;
case "gone":
return `${label} left`;
case "heard":

View File

@ -123,7 +123,7 @@ export default function DesktopTimelineView({
const timelineTime = useMemo(() => {
if (scrubbing) {
return playerTime;
return selectedPlayback.range.start + playerTime;
} else {
// take a player time in seconds and convert to timestamp in timeline
let timestamp = 0;
@ -395,11 +395,10 @@ export default function DesktopTimelineView({
setTimeToSeek(Math.round(seekTime));
}}
timechangedHandler={(data) => {
const playbackTime = data.time.getTime() / 1000;
playerRef.current?.currentTime(
playbackTime - timeline.range.start
);
setScrubbing(false);
const playbackTime =
data.time.getTime() / 1000 - timeline.range.start;
playerRef.current?.currentTime(playbackTime);
playerRef.current?.play();
}}
selectHandler={(data) => {