forked from Github/frigate
Improve motion detection and region selection (#6741)
* refactor existing motion detector * implement and use cnt bgsub * pass fps to motion detector * create a simplified motion detector * lightning detection * update default motion config * lint imports * use estimated boxes for regions * use improved motion detector * update test * use a different strategy for clustering motion and object boxes * increase alpha during calibration * simplify object consolidation * add some reasonable constraints to the estimated box * adjust cluster boundary to 10% * refactor * add disabled debug code * fix variable scope
This commit is contained in:
@@ -231,16 +231,32 @@ class NorfairTracker(ObjectTracker):
|
||||
# update or create new tracks
|
||||
active_ids = []
|
||||
for t in tracked_objects:
|
||||
estimate = tuple(t.estimate.flatten().astype(int))
|
||||
# keep the estimate within the bounds of the image
|
||||
estimate = (
|
||||
max(0, estimate[0]),
|
||||
max(0, estimate[1]),
|
||||
min(self.detect_config.width - 1, estimate[2]),
|
||||
min(self.detect_config.height - 1, estimate[3]),
|
||||
)
|
||||
obj = {
|
||||
**t.last_detection.data,
|
||||
"estimate": estimate,
|
||||
}
|
||||
active_ids.append(t.global_id)
|
||||
if t.global_id not in self.track_id_map:
|
||||
self.register(t.global_id, t.last_detection.data)
|
||||
self.register(t.global_id, obj)
|
||||
# if there wasn't a detection in this frame, increment disappeared
|
||||
elif t.last_detection.data["frame_time"] != frame_time:
|
||||
id = self.track_id_map[t.global_id]
|
||||
self.disappeared[id] += 1
|
||||
# sometimes the estimate gets way off
|
||||
# only update if the upper left corner is actually upper left
|
||||
if estimate[0] < estimate[2] and estimate[1] < estimate[3]:
|
||||
self.tracked_objects[id]["estimate"] = obj["estimate"]
|
||||
# else update it
|
||||
else:
|
||||
self.update(t.global_id, t.last_detection.data)
|
||||
self.update(t.global_id, obj)
|
||||
|
||||
# clear expired tracks
|
||||
expired_ids = [k for k in self.track_id_map.keys() if k not in active_ids]
|
||||
|
||||
Reference in New Issue
Block a user