mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
reduce detection rate for stationary objects
This commit is contained in:
parent
e36099a342
commit
75c8570913
@ -13,7 +13,7 @@ import numpy as np
|
||||
from scipy.spatial import distance as dist
|
||||
|
||||
from frigate.config import DetectConfig
|
||||
from frigate.util import draw_box_with_label
|
||||
from frigate.util import intersection_over_union
|
||||
|
||||
|
||||
class ObjectTracker:
|
||||
@ -27,6 +27,7 @@ class ObjectTracker:
|
||||
id = f"{obj['frame_time']}-{rand_id}"
|
||||
obj["id"] = id
|
||||
obj["start_time"] = obj["frame_time"]
|
||||
obj["motionless_count"] = 0
|
||||
self.tracked_objects[id] = obj
|
||||
self.disappeared[id] = 0
|
||||
|
||||
@ -36,6 +37,13 @@ class ObjectTracker:
|
||||
|
||||
def update(self, id, new_obj):
|
||||
self.disappeared[id] = 0
|
||||
if (
|
||||
intersection_over_union(self.tracked_objects[id]["box"], new_obj["box"])
|
||||
> 0.9
|
||||
):
|
||||
self.tracked_objects[id]["motionless_count"] += 1
|
||||
else:
|
||||
self.tracked_objects[id]["motionless_count"] = 0
|
||||
self.tracked_objects[id].update(new_obj)
|
||||
|
||||
def match_and_update(self, frame_time, new_objects):
|
||||
|
@ -498,9 +498,21 @@ def process_frames(
|
||||
# look for motion
|
||||
motion_boxes = motion_detector.detect(frame)
|
||||
|
||||
# only get the tracked object boxes that intersect with motion
|
||||
# get stationary object ids
|
||||
# check every 10th frame for stationary objects
|
||||
stationary_object_ids = [
|
||||
obj["id"]
|
||||
for obj in object_tracker.tracked_objects.values()
|
||||
if obj["motionless_count"] >= 10
|
||||
and obj["motionless_count"] % 10 != 0
|
||||
and object_tracker.disappeared[obj["id"]] == 0
|
||||
]
|
||||
|
||||
# get tracked object boxes that aren't stationary
|
||||
tracked_object_boxes = [
|
||||
obj["box"] for obj in object_tracker.tracked_objects.values()
|
||||
obj["box"]
|
||||
for obj in object_tracker.tracked_objects.values()
|
||||
if not obj["id"] in stationary_object_ids
|
||||
]
|
||||
|
||||
# combine motion boxes with known locations of existing objects
|
||||
@ -513,7 +525,18 @@ def process_frames(
|
||||
]
|
||||
|
||||
# resize regions and detect
|
||||
detections = []
|
||||
# seed with stationary objects
|
||||
detections = [
|
||||
(
|
||||
obj["label"],
|
||||
obj["score"],
|
||||
obj["box"],
|
||||
obj["area"],
|
||||
obj["region"],
|
||||
)
|
||||
for obj in object_tracker.tracked_objects.values()
|
||||
if obj["id"] in stationary_object_ids
|
||||
]
|
||||
for region in regions:
|
||||
detections.extend(
|
||||
detect(
|
||||
|
Loading…
Reference in New Issue
Block a user