@@ -54,6 +54,28 @@ def __init__(
5454 self .ptz_autotracker_thread = ptz_autotracker_thread
5555 self .prev_enabled = self .camera_config .enabled
5656
57+ # Minimum object area thresholds for fast-tracking updates to secondary
58+ # face/LPR pipelines when using a model without built-in detection.
59+ self .face_recognition_min_obj_area : int = 0
60+ self .lpr_min_obj_area : int = 0
61+
62+ if (
63+ self .camera_config .face_recognition .enabled
64+ and "face" not in config .objects .all_objects
65+ ):
66+ # A face is roughly 1/8 of person box area; use a conservative
67+ # multiplier so fast-tracking starts slightly before the optimal zone
68+ self .face_recognition_min_obj_area = (
69+ self .camera_config .face_recognition .min_area * 6
70+ )
71+
72+ if (
73+ self .camera_config .lpr .enabled
74+ and "license_plate" not in self .camera_config .objects .track
75+ ):
76+ # A plate is a smaller fraction of a vehicle box; use ~20x multiplier
77+ self .lpr_min_obj_area = self .camera_config .lpr .min_area * 20
78+
5779 def get_current_frame (self , draw_options : dict [str , Any ] = {}) -> np .ndarray :
5880 with self .current_frame_lock :
5981 frame_copy = np .copy (self ._current_frame )
@@ -372,13 +394,30 @@ def update(
372394
373395 updated_obj .last_updated = frame_time
374396
375- # if it has been more than 5 seconds since the last thumb update
376- # and the last update is greater than the last publish or
377- # the object has changed significantly or
378- # the object moved enough to update the path
397+ # Determine the staleness threshold for publishing updates.
398+ # Fast-track to 1s for objects in the optimal size range for
399+ # secondary face/LPR recognition that don't yet have a sub_label.
400+ obj_area = updated_obj .obj_data .get ("area" , 0 )
401+ obj_label = updated_obj .obj_data .get ("label" )
402+ publish_threshold = 5
403+
404+ if (
405+ obj_label == "person"
406+ and self .face_recognition_min_obj_area > 0
407+ and obj_area >= self .face_recognition_min_obj_area
408+ and updated_obj .obj_data .get ("sub_label" ) is None
409+ ) or (
410+ obj_label in ("car" , "motorcycle" )
411+ and self .lpr_min_obj_area > 0
412+ and obj_area >= self .lpr_min_obj_area
413+ and updated_obj .obj_data .get ("sub_label" ) is None
414+ and updated_obj .obj_data .get ("recognized_license_plate" ) is None
415+ ):
416+ publish_threshold = 1
417+
379418 if (
380419 (
381- frame_time - updated_obj .last_published > 5
420+ frame_time - updated_obj .last_published > publish_threshold
382421 and updated_obj .last_updated > updated_obj .last_published
383422 )
384423 or significant_update
0 commit comments