require a position change to be an active object

This commit is contained in:
Blake Blackshear 2022-02-05 07:09:31 -06:00
parent 87cd618998
commit db369a5b7f
2 changed files with 22 additions and 1 deletions

View File

@ -178,6 +178,7 @@ class TrackedObject:
"area": self.obj_data["area"], "area": self.obj_data["area"],
"region": self.obj_data["region"], "region": self.obj_data["region"],
"motionless_count": self.obj_data["motionless_count"], "motionless_count": self.obj_data["motionless_count"],
"position_changes": self.obj_data["position_changes"],
"current_zones": self.current_zones.copy(), "current_zones": self.current_zones.copy(),
"entered_zones": self.entered_zones.copy(), "entered_zones": self.entered_zones.copy(),
"has_clip": self.has_clip, "has_clip": self.has_clip,
@ -266,7 +267,13 @@ class TrackedObject:
box = self.thumbnail_data["box"] box = self.thumbnail_data["box"]
box_size = 300 box_size = 300
region = calculate_region( region = calculate_region(
best_frame.shape, box[0], box[1], box[2], box[3], box_size, multiplier=1.1 best_frame.shape,
box[0],
box[1],
box[2],
box[3],
box_size,
multiplier=1.1,
) )
best_frame = best_frame[region[1] : region[3], region[0] : region[2]] best_frame = best_frame[region[1] : region[3], region[0] : region[2]]
@ -732,6 +739,10 @@ class TrackedObjectProcessor(threading.Thread):
if not snapshot_config.enabled: if not snapshot_config.enabled:
return False return False
# object never changed position
if obj.obj_data["position_changes"] == 0:
return False
# if there are required zones and there is no overlap # if there are required zones and there is no overlap
required_zones = snapshot_config.required_zones required_zones = snapshot_config.required_zones
if len(required_zones) > 0 and not set(obj.entered_zones) & set(required_zones): if len(required_zones) > 0 and not set(obj.entered_zones) & set(required_zones):
@ -752,6 +763,10 @@ class TrackedObjectProcessor(threading.Thread):
if not record_config.enabled: if not record_config.enabled:
return False return False
# object never changed position
if obj.obj_data["position_changes"] == 0:
return False
# If there are required zones and there is no overlap # If there are required zones and there is no overlap
required_zones = record_config.events.required_zones required_zones = record_config.events.required_zones
if len(required_zones) > 0 and not set(obj.entered_zones) & set(required_zones): if len(required_zones) > 0 and not set(obj.entered_zones) & set(required_zones):
@ -773,6 +788,10 @@ class TrackedObjectProcessor(threading.Thread):
return True return True
def should_mqtt_snapshot(self, camera, obj: TrackedObject): def should_mqtt_snapshot(self, camera, obj: TrackedObject):
# object never changed position
if obj.obj_data["position_changes"] == 0:
return False
# if there are required zones and there is no overlap # if there are required zones and there is no overlap
required_zones = self.config.cameras[camera].mqtt.required_zones required_zones = self.config.cameras[camera].mqtt.required_zones
if len(required_zones) > 0 and not set(obj.entered_zones) & set(required_zones): if len(required_zones) > 0 and not set(obj.entered_zones) & set(required_zones):

View File

@ -30,6 +30,7 @@ class ObjectTracker:
obj["id"] = id obj["id"] = id
obj["start_time"] = obj["frame_time"] obj["start_time"] = obj["frame_time"]
obj["motionless_count"] = 0 obj["motionless_count"] = 0
obj["position_changes"] = 0
self.tracked_objects[id] = obj self.tracked_objects[id] = obj
self.disappeared[id] = 0 self.disappeared[id] = 0
self.positions[id] = { self.positions[id] = {
@ -100,6 +101,7 @@ class ObjectTracker:
self.tracked_objects[id]["motionless_count"] += 1 self.tracked_objects[id]["motionless_count"] += 1
else: else:
self.tracked_objects[id]["motionless_count"] = 0 self.tracked_objects[id]["motionless_count"] = 0
self.tracked_objects[id]["position_changes"] += 1
self.tracked_objects[id].update(new_obj) self.tracked_objects[id].update(new_obj)
def match_and_update(self, frame_time, new_objects): def match_and_update(self, frame_time, new_objects):