Compare commits

..

No commits in common. "8a0f4e195d974f6e91632b9b4e21034de535be62" and "f2361cb81e0326b396c715882e6fb13d31683b5c" have entirely different histories.

2 changed files with 32 additions and 10 deletions

View File

@ -269,10 +269,8 @@ class CameraState:
for id in updated_ids:
updated_obj = tracked_objects[id]
thumb_update, significant_update, path_update, autotracker_update = (
updated_obj.update(
frame_time, current_detections[id], current_frame is not None
)
thumb_update, significant_update, autotracker_update = updated_obj.update(
frame_time, current_detections[id], current_frame is not None
)
if autotracker_update or significant_update:
@ -292,14 +290,14 @@ class CameraState:
# if it has been more than 5 seconds since the last thumb update
# and the last update is greater than the last publish or
# the object has changed significantly or
# the object moved enough to update the path
# we are due for an attribute update
if (
(
frame_time - updated_obj.last_published > 5
and updated_obj.last_updated > updated_obj.last_published
)
or significant_update
or path_update
or updated_obj.should_update_attribute()
):
# call event handlers
for c in self.callbacks["update"]:

View File

@ -1,5 +1,6 @@
"""Object attribute."""
import datetime
import logging
import math
import os
@ -71,6 +72,14 @@ class TrackedObject:
self.velocity_angle = 0
self.path_data = []
self.previous = self.to_dict()
self.requires_face_detection = (
self.camera_config.face_recognition.enabled
and "face" not in self.camera_config.objects.track
)
self.requires_lpr_detection = (
self.camera_config.lpr.enabled
and "license_plate" not in self.camera_config.objects.track
)
@property
def max_severity(self) -> Optional[str]:
@ -117,7 +126,6 @@ class TrackedObject:
def update(self, current_frame_time: float, obj_data, has_valid_frame: bool):
thumb_update = False
significant_change = False
path_update = False
autotracker_update = False
# if the object is not in the current frame, add a 0.0 to the score history
if obj_data["frame_time"] != current_frame_time:
@ -325,21 +333,37 @@ class TrackedObject:
if not self.path_data:
self.path_data.append((bottom_center, obj_data["frame_time"]))
path_update = True
elif (
math.dist(self.path_data[-1][0], bottom_center) >= threshold
or len(self.path_data) == 1
):
# check Euclidean distance before appending
self.path_data.append((bottom_center, obj_data["frame_time"]))
path_update = True
logger.debug(
f"Point tracking: {obj_data['id']}, {bottom_center}, {obj_data['frame_time']}"
)
self.obj_data.update(obj_data)
self.current_zones = current_zones
return (thumb_update, significant_change, path_update, autotracker_update)
return (thumb_update, significant_change, autotracker_update)
def should_update_attribute(self) -> bool:
"""Decides if attributes should be checked."""
if not self.active:
return False
if self.obj_data["label"] == "person" and not self.requires_face_detection:
return False
elif self.obj_data["label"] == "car" and not self.requires_lpr_detection:
return False
now = datetime.datetime.now().timestamp()
if now + 0.5 > self.last_published:
self.last_published = now
return True
return False
def to_dict(self):
event = {