use unclipped estimate in distance function only

This commit is contained in:
Josh Hawkins 2023-11-01 11:13:18 -05:00
parent e49f034721
commit 2433b9e00a

View File

@ -55,6 +55,10 @@ def distance(detection: np.array, estimate: np.array) -> float:
def frigate_distance(detection: Detection, tracked_object) -> float: def frigate_distance(detection: Detection, tracked_object) -> float:
# if we're actively autotracking an object
if tracked_object.autotracking_estimate is not None:
return distance(detection.points, tracked_object.autotracking_estimate)
else:
return distance(detection.points, tracked_object.estimate) return distance(detection.points, tracked_object.estimate)
@ -276,10 +280,10 @@ class NorfairTracker(ObjectTracker):
active_ids = [] active_ids = []
for t in tracked_objects: for t in tracked_objects:
estimate = tuple(t.estimate.flatten().astype(int)) estimate = tuple(t.estimate.flatten().astype(int))
if not self.ptz_tracking_active.is_set(): autotracking_estimate = (
estimate if not self.ptz_tracking_active.is_set() else None
)
# keep the estimate within the bounds of the image # keep the estimate within the bounds of the image
# always for non-autotracking cams
# and only for autotracking cams when not actively autotracking
estimate = ( estimate = (
max(0, estimate[0]), max(0, estimate[0]),
max(0, estimate[1]), max(0, estimate[1]),
@ -289,6 +293,7 @@ class NorfairTracker(ObjectTracker):
obj = { obj = {
**t.last_detection.data, **t.last_detection.data,
"estimate": estimate, "estimate": estimate,
"autotracking_estimate": autotracking_estimate,
"estimate_velocity": t.estimate_velocity, "estimate_velocity": t.estimate_velocity,
} }
active_ids.append(t.global_id) active_ids.append(t.global_id)