Sync stationary object checks (#8238)

* Sync stationary object checks for all objects on a camera

* Formatting
This commit is contained in:
Nicolas Mowen 2023-10-19 16:14:33 -06:00 committed by GitHub
parent 8f349a6365
commit 12487b3b60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -532,6 +532,7 @@ def process_frames(
fps_tracker.start() fps_tracker.start()
startup_scan = True startup_scan = True
stationary_frame_counter = 0
region_min_size = get_min_region_size(model_config) region_min_size = get_min_region_size(model_config)
@ -585,23 +586,24 @@ def process_frames(
# check every Nth frame for stationary objects # check every Nth frame for stationary objects
# disappeared objects are not stationary # disappeared objects are not stationary
# also check for overlapping motion boxes # also check for overlapping motion boxes
stationary_object_ids = [ if stationary_frame_counter == detect_config.stationary.interval:
obj["id"] stationary_frame_counter = 0
for obj in object_tracker.tracked_objects.values() stationary_object_ids = []
# if it has exceeded the stationary threshold else:
if obj["motionless_count"] >= detect_config.stationary.threshold stationary_frame_counter += 1
# and it isn't due for a periodic check stationary_object_ids = [
and ( obj["id"]
detect_config.stationary.interval == 0 for obj in object_tracker.tracked_objects.values()
or obj["motionless_count"] % detect_config.stationary.interval != 0 # if it has exceeded the stationary threshold
) if obj["motionless_count"] >= detect_config.stationary.threshold
# and it hasn't disappeared # and it hasn't disappeared
and object_tracker.disappeared[obj["id"]] == 0 and object_tracker.disappeared[obj["id"]] == 0
# and it doesn't overlap with any current motion boxes when not calibrating # and it doesn't overlap with any current motion boxes when not calibrating
and not intersects_any( and not intersects_any(
obj["box"], [] if motion_detector.is_calibrating() else motion_boxes obj["box"],
) [] if motion_detector.is_calibrating() else motion_boxes,
] )
]
# get tracked object boxes that aren't stationary # get tracked object boxes that aren't stationary
tracked_object_boxes = [ tracked_object_boxes = [