mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-05 22:32:50 +03:00
fix autotracking debug overlay max target box lookup
This commit is contained in:
@@ -134,10 +134,8 @@ class CameraState:
|
||||
and self.camera_config.detect.width is not None
|
||||
and self.camera_config.detect.height is not None
|
||||
):
|
||||
max_target_box = (
|
||||
self.ptz_autotracker_thread.tracked_object_metrics[
|
||||
self.name
|
||||
]["max_target_box"]
|
||||
max_target_box = self.ptz_autotracker_thread.max_target_box(
|
||||
self.name
|
||||
)
|
||||
side_length = max_target_box * (
|
||||
max(
|
||||
|
||||
@@ -332,6 +332,11 @@ class PtzAutoTracker(threading.Thread):
|
||||
def _reset_tracked_object_metrics(self, camera: str) -> None:
|
||||
self.tracked_object_metrics[camera] = {}
|
||||
|
||||
def max_target_box(self, camera: str) -> float:
|
||||
"""Return the largest target box ratio allowed for the zoom factor."""
|
||||
zoom_factor = self.config.cameras[camera].onvif.autotracking.zoom_factor
|
||||
return AUTOTRACKING_MAX_AREA_RATIO ** (1 / zoom_factor)
|
||||
|
||||
async def _wait_until_stopped(
|
||||
self, camera: str, metrics: PTZMetrics | None = None
|
||||
) -> None:
|
||||
@@ -940,7 +945,7 @@ class PtzAutoTracker(threading.Thread):
|
||||
camera_config = self.config.cameras[camera]
|
||||
tom = self.tracked_object_metrics[camera]
|
||||
zoom_factor = camera_config.onvif.autotracking.zoom_factor
|
||||
max_target_box = AUTOTRACKING_MAX_AREA_RATIO ** (1 / zoom_factor)
|
||||
max_target_box = self.max_target_box(camera)
|
||||
camera_width = camera_config.frame_shape[1]
|
||||
camera_height = camera_config.frame_shape[0]
|
||||
camera_fps = camera_config.detect.fps
|
||||
@@ -1174,7 +1179,7 @@ class PtzAutoTracker(threading.Thread):
|
||||
camera_config = self.config.cameras[camera]
|
||||
tom = self.tracked_object_metrics[camera]
|
||||
zoom_factor = camera_config.onvif.autotracking.zoom_factor
|
||||
max_target_box = AUTOTRACKING_MAX_AREA_RATIO ** (1 / zoom_factor)
|
||||
max_target_box = self.max_target_box(camera)
|
||||
|
||||
# frame width and height
|
||||
camera_width = camera_config.frame_shape[1]
|
||||
|
||||
@@ -123,5 +123,19 @@ class TestAutotrackerDisable(unittest.TestCase):
|
||||
self.assertIs(payload, autotracking)
|
||||
|
||||
|
||||
class TestAutotrackerMaxTargetBox(unittest.TestCase):
|
||||
def test_follows_live_zoom_factor(self) -> None:
|
||||
# the debug overlay and the zoom decisions both read this, so it has to
|
||||
# track a zoom_factor changed while an object is being followed
|
||||
tracker = _make_tracker()
|
||||
autotracking = tracker.config.cameras[CAMERA].onvif.autotracking
|
||||
|
||||
autotracking.zoom_factor = 0.5
|
||||
self.assertAlmostEqual(tracker.max_target_box(CAMERA), 0.6**2)
|
||||
|
||||
autotracking.zoom_factor = 0.25
|
||||
self.assertAlmostEqual(tracker.max_target_box(CAMERA), 0.6**4)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user