mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-07 03:35:26 +03:00
recalc relative zoom value
This commit is contained in:
parent
7868943dca
commit
2dd71a7d48
@ -57,6 +57,6 @@ INSERT_MANY_RECORDINGS = "insert_many_recordings"
|
|||||||
AUTOTRACKING_MOTION_MIN_DISTANCE = 20
|
AUTOTRACKING_MOTION_MIN_DISTANCE = 20
|
||||||
AUTOTRACKING_MOTION_MAX_POINTS = 500
|
AUTOTRACKING_MOTION_MAX_POINTS = 500
|
||||||
AUTOTRACKING_MAX_MOVE_METRICS = 500
|
AUTOTRACKING_MAX_MOVE_METRICS = 500
|
||||||
AUTOTRACKING_ZOOM_OUT_HYSTERESIS = 2.2
|
AUTOTRACKING_ZOOM_OUT_HYSTERESIS = 1.1
|
||||||
AUTOTRACKING_ZOOM_IN_HYSTERESIS = 0.8
|
AUTOTRACKING_ZOOM_IN_HYSTERESIS = 0.9
|
||||||
AUTOTRACKING_ZOOM_EDGE_THRESHOLD = 0.02
|
AUTOTRACKING_ZOOM_EDGE_THRESHOLD = 0.05
|
||||||
|
|||||||
@ -630,9 +630,9 @@ class PtzAutoTracker:
|
|||||||
below_distance_threshold = self._below_distance_threshold(camera, obj)
|
below_distance_threshold = self._below_distance_threshold(camera, obj)
|
||||||
|
|
||||||
# ensure object isn't too big in frame
|
# ensure object isn't too big in frame
|
||||||
below_dimension_threshold = (bb_right - bb_left) / camera_width < min(
|
below_dimension_threshold = (bb_right - bb_left) / camera_width < 0.8 and (
|
||||||
self.zoom_factor[camera], 0.6
|
bb_bottom - bb_top
|
||||||
) and (bb_bottom - bb_top) / camera_height < min(self.zoom_factor[camera], 0.6)
|
) / camera_height < 0.8
|
||||||
|
|
||||||
# ensure object is not moving quickly
|
# ensure object is not moving quickly
|
||||||
below_velocity_threshold = (
|
below_velocity_threshold = (
|
||||||
@ -703,7 +703,8 @@ class PtzAutoTracker:
|
|||||||
zoom_in_hysteresis
|
zoom_in_hysteresis
|
||||||
and away_from_edge
|
and away_from_edge
|
||||||
and below_velocity_threshold
|
and below_velocity_threshold
|
||||||
and (below_distance_threshold or below_dimension_threshold)
|
and below_distance_threshold
|
||||||
|
and below_dimension_threshold
|
||||||
and not at_max_zoom
|
and not at_max_zoom
|
||||||
):
|
):
|
||||||
return True
|
return True
|
||||||
@ -817,11 +818,8 @@ class PtzAutoTracker:
|
|||||||
# relative zooming concurrently with pan/tilt
|
# relative zooming concurrently with pan/tilt
|
||||||
if camera_config.onvif.autotracking.zooming == ZoomingModeEnum.relative:
|
if camera_config.onvif.autotracking.zooming == ZoomingModeEnum.relative:
|
||||||
if self.tracked_object_previous[camera] is None:
|
if self.tracked_object_previous[camera] is None:
|
||||||
# start with a slightly altered box to encourage an initial zoom
|
zoom = target_box ** self.zoom_factor[camera]
|
||||||
self.previous_target_box[camera] = target_box * (
|
else:
|
||||||
AUTOTRACKING_ZOOM_OUT_HYSTERESIS - 0.05
|
|
||||||
)
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
result := self._should_zoom_in(
|
result := self._should_zoom_in(
|
||||||
camera,
|
camera,
|
||||||
@ -831,12 +829,15 @@ class PtzAutoTracker:
|
|||||||
else obj.obj_data["box"],
|
else obj.obj_data["box"],
|
||||||
)
|
)
|
||||||
) is not None:
|
) is not None:
|
||||||
# zoom in value
|
# zoom value
|
||||||
zoom = target_box ** (self.zoom_factor[camera] / 1.5)
|
zoom = (
|
||||||
|
2
|
||||||
if not result:
|
* (
|
||||||
# zoom out
|
self.previous_target_box[camera]
|
||||||
zoom = -(1 - zoom) if zoom != 0 else 0
|
/ (target_box + self.previous_target_box[camera])
|
||||||
|
)
|
||||||
|
- 1
|
||||||
|
)
|
||||||
|
|
||||||
logger.debug(f"{camera}: Zooming: {result} Zoom amount: {zoom}")
|
logger.debug(f"{camera}: Zooming: {result} Zoom amount: {zoom}")
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user