mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
switch mqtt to a binary on/off instead of sending a message for each score
This commit is contained in:
parent
85259ca00c
commit
afb70f11a8
@ -43,11 +43,11 @@ class MqttObjectPublisher(threading.Thread):
|
|||||||
with self.objects_parsed:
|
with self.objects_parsed:
|
||||||
self.objects_parsed.wait()
|
self.objects_parsed.wait()
|
||||||
|
|
||||||
# add all the person scores in detected objects and
|
# add all the person scores in detected objects
|
||||||
# average over past 1 seconds (5fps)
|
|
||||||
detected_objects = self._detected_objects.copy()
|
detected_objects = self._detected_objects.copy()
|
||||||
avg_person_score = sum([obj['score'] for obj in detected_objects if obj['name'] == 'person'])/5
|
person_score = sum([obj['score'] for obj in detected_objects if obj['name'] == 'person'])
|
||||||
payload['person'] = int(avg_person_score*100)
|
# if the person score is more than 100, set person to ON
|
||||||
|
payload['person'] = 'ON' if int(person_score*100) > 100 else 'OFF'
|
||||||
|
|
||||||
# send message for objects if different
|
# send message for objects if different
|
||||||
new_payload = json.dumps(payload, sort_keys=True)
|
new_payload = json.dumps(payload, sort_keys=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user