mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-05 04:57:42 +03:00
Correctly ensure updates are more periodic when lpr or face detection is needed
This commit is contained in:
parent
5d63c58f2c
commit
3565c43cf7
@ -53,17 +53,6 @@ class CameraState:
|
|||||||
self.callbacks = defaultdict(list)
|
self.callbacks = defaultdict(list)
|
||||||
self.ptz_autotracker_thread = ptz_autotracker_thread
|
self.ptz_autotracker_thread = ptz_autotracker_thread
|
||||||
self.prev_enabled = self.camera_config.enabled
|
self.prev_enabled = self.camera_config.enabled
|
||||||
self.requires_face_detection = (
|
|
||||||
self.config.face_recognition.enabled
|
|
||||||
and "face" not in self.config.objects.all_objects
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_max_update_frequency(self, obj: TrackedObject) -> int:
|
|
||||||
return (
|
|
||||||
1
|
|
||||||
if self.requires_face_detection and obj.obj_data["label"] == "person"
|
|
||||||
else 5
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_current_frame(self, draw_options: dict[str, Any] = {}):
|
def get_current_frame(self, draw_options: dict[str, Any] = {}):
|
||||||
with self.current_frame_lock:
|
with self.current_frame_lock:
|
||||||
@ -298,14 +287,18 @@ class CameraState:
|
|||||||
|
|
||||||
updated_obj.last_updated = frame_time
|
updated_obj.last_updated = frame_time
|
||||||
|
|
||||||
# if it has been more than max_update_frequency seconds since the last thumb update
|
# if it has been more than 5 seconds since the last thumb update
|
||||||
# and the last update is greater than the last publish or
|
# and the last update is greater than the last publish or
|
||||||
# the object has changed significantly
|
# the object has changed significantly or
|
||||||
|
# we are due for an attribute update
|
||||||
if (
|
if (
|
||||||
frame_time - updated_obj.last_published
|
(
|
||||||
> self.get_max_update_frequency(updated_obj)
|
frame_time - updated_obj.last_published > 5
|
||||||
and updated_obj.last_updated > updated_obj.last_published
|
and updated_obj.last_updated > updated_obj.last_published
|
||||||
) or significant_update:
|
)
|
||||||
|
or significant_update
|
||||||
|
or updated_obj.should_update_attribute()
|
||||||
|
):
|
||||||
# call event handlers
|
# call event handlers
|
||||||
for c in self.callbacks["update"]:
|
for c in self.callbacks["update"]:
|
||||||
c(self.name, updated_obj, frame_name)
|
c(self.name, updated_obj, frame_name)
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
"""Object attribute."""
|
"""Object attribute."""
|
||||||
|
|
||||||
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
@ -71,6 +72,14 @@ class TrackedObject:
|
|||||||
self.velocity_angle = 0
|
self.velocity_angle = 0
|
||||||
self.path_data = []
|
self.path_data = []
|
||||||
self.previous = self.to_dict()
|
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
|
@property
|
||||||
def max_severity(self) -> Optional[str]:
|
def max_severity(self) -> Optional[str]:
|
||||||
@ -338,6 +347,22 @@ class TrackedObject:
|
|||||||
self.current_zones = current_zones
|
self.current_zones = current_zones
|
||||||
return (thumb_update, significant_change, autotracker_update)
|
return (thumb_update, significant_change, autotracker_update)
|
||||||
|
|
||||||
|
def should_update_attribute(self) -> bool:
|
||||||
|
"""Decides if attributes should be checked."""
|
||||||
|
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
|
||||||
|
print(f"running manual attribute update")
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
event = {
|
event = {
|
||||||
"id": self.obj_data["id"],
|
"id": self.obj_data["id"],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user