use numpy for euclidean distance

This commit is contained in:
Josh Hawkins 2023-09-28 09:05:49 -05:00
parent c389d832b2
commit 614099c83f

View File

@ -2,7 +2,6 @@
import copy import copy
import logging import logging
import math
import os import os
import queue import queue
import threading import threading
@ -656,10 +655,11 @@ class PtzAutoTracker:
# more often to keep the object in the center. Raising the percentage will cause less # more often to keep the object in the center. Raising the percentage will cause less
# movement and will be more flexible with objects not quite being centered. # movement and will be more flexible with objects not quite being centered.
# TODO: there's probably a better way to approach this # TODO: there's probably a better way to approach this
distance = math.sqrt( distance = np.linalg.norm(
(obj.obj_data["centroid"][0] - camera_config.detect.width / 2) ** 2 [
+ (obj.obj_data["centroid"][1] - camera_config.detect.height / 2) obj.obj_data["centroid"][0] - camera_config.detect.width / 2,
** 2 obj.obj_data["centroid"][1] - camera_config.detect.height / 2,
]
) )
obj_width = obj.obj_data["box"][2] - obj.obj_data["box"][0] obj_width = obj.obj_data["box"][2] - obj.obj_data["box"][0]