mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-07-26 13:47:03 +02:00
filter objects before triggering events
This commit is contained in:
parent
fbe721c860
commit
3d2f1437e4
@ -116,6 +116,9 @@ cameras:
|
|||||||
# from the video stream without re-encoding. Clips are them created by using ffmpeg to merge segments
|
# from the video stream without re-encoding. Clips are them created by using ffmpeg to merge segments
|
||||||
# without re-encoding. The segements saved are unaltered from what frigate receives to avoid re-encoding.
|
# without re-encoding. The segements saved are unaltered from what frigate receives to avoid re-encoding.
|
||||||
# They do not contain bounding boxes. 30 seconds of video is added to the start of the clip.
|
# They do not contain bounding boxes. 30 seconds of video is added to the start of the clip.
|
||||||
|
#
|
||||||
|
# NOTE: This will only work for camera feeds that can be copied into the mp4 container format without
|
||||||
|
# encoding such as h264. I do not expect this to work for mjpeg streams.
|
||||||
################
|
################
|
||||||
save_clips: False
|
save_clips: False
|
||||||
|
|
||||||
|
@ -22,6 +22,11 @@ COLOR_MAP = {}
|
|||||||
for key, val in LABELS.items():
|
for key, val in LABELS.items():
|
||||||
COLOR_MAP[val] = tuple(int(round(255 * c)) for c in cmap(key)[:3])
|
COLOR_MAP[val] = tuple(int(round(255 * c)) for c in cmap(key)[:3])
|
||||||
|
|
||||||
|
def filter_false_positives(event):
|
||||||
|
if len(event['history']) < 2:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
class TrackedObjectProcessor(threading.Thread):
|
class TrackedObjectProcessor(threading.Thread):
|
||||||
def __init__(self, config, client, topic_prefix, tracked_objects_queue, event_queue):
|
def __init__(self, config, client, topic_prefix, tracked_objects_queue, event_queue):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
@ -65,6 +70,8 @@ class TrackedObjectProcessor(threading.Thread):
|
|||||||
updated_ids = list(set(current_ids).intersection(previous_ids))
|
updated_ids = list(set(current_ids).intersection(previous_ids))
|
||||||
|
|
||||||
for id in new_ids:
|
for id in new_ids:
|
||||||
|
# only register the object here if we are sure it isnt a false positive
|
||||||
|
if not filter_false_positives(current_tracked_objects[id]):
|
||||||
tracked_objects[id] = current_tracked_objects[id]
|
tracked_objects[id] = current_tracked_objects[id]
|
||||||
# publish events to mqtt
|
# publish events to mqtt
|
||||||
self.client.publish(f"{self.topic_prefix}/{camera}/events/start", json.dumps(tracked_objects[id]), retain=False)
|
self.client.publish(f"{self.topic_prefix}/{camera}/events/start", json.dumps(tracked_objects[id]), retain=False)
|
||||||
@ -139,10 +146,9 @@ class TrackedObjectProcessor(threading.Thread):
|
|||||||
###
|
###
|
||||||
# Report over MQTT
|
# Report over MQTT
|
||||||
###
|
###
|
||||||
# count objects with more than 2 entries in history by type
|
# count objects by type
|
||||||
obj_counter = Counter()
|
obj_counter = Counter()
|
||||||
for obj in tracked_objects.values():
|
for obj in tracked_objects.values():
|
||||||
if len(obj['history']) > 1:
|
|
||||||
obj_counter[obj['label']] += 1
|
obj_counter[obj['label']] += 1
|
||||||
|
|
||||||
# report on detected objects
|
# report on detected objects
|
||||||
|
Loading…
Reference in New Issue
Block a user