only use max target box for relative zoom limiter (#8509)

This commit is contained in:
Josh Hawkins 2023-11-07 05:31:39 -06:00 committed by GitHub
parent 591b91194a
commit 1d99bb908d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -863,21 +863,11 @@ class PtzAutoTracker:
# introduce some hysteresis to prevent a yo-yo zooming effect # introduce some hysteresis to prevent a yo-yo zooming effect
zoom_out_hysteresis = ( zoom_out_hysteresis = (
self.tracked_object_metrics[camera]["target_box"] self.tracked_object_metrics[camera]["target_box"]
> (
self.tracked_object_metrics[camera]["original_target_box"]
* AUTOTRACKING_ZOOM_OUT_HYSTERESIS
)
or self.tracked_object_metrics[camera]["target_box"]
> self.tracked_object_metrics[camera]["max_target_box"] > self.tracked_object_metrics[camera]["max_target_box"]
* AUTOTRACKING_ZOOM_OUT_HYSTERESIS * AUTOTRACKING_ZOOM_OUT_HYSTERESIS
) )
zoom_in_hysteresis = ( zoom_in_hysteresis = (
self.tracked_object_metrics[camera]["target_box"] self.tracked_object_metrics[camera]["target_box"]
< (
self.tracked_object_metrics[camera]["original_target_box"]
* AUTOTRACKING_ZOOM_IN_HYSTERESIS
)
or self.tracked_object_metrics[camera]["target_box"]
< self.tracked_object_metrics[camera]["max_target_box"] < self.tracked_object_metrics[camera]["max_target_box"]
* AUTOTRACKING_ZOOM_IN_HYSTERESIS * AUTOTRACKING_ZOOM_IN_HYSTERESIS
) )
@ -1073,15 +1063,14 @@ class PtzAutoTracker:
) )
) is not None: ) is not None:
# zoom value # zoom value
limit = ( ratio = (
self.tracked_object_metrics[camera]["original_target_box"] self.tracked_object_metrics[camera]["max_target_box"]
if self.tracked_object_metrics[camera]["target_box"] / self.tracked_object_metrics[camera]["target_box"]
< self.tracked_object_metrics[camera]["max_target_box"]
else self.tracked_object_metrics[camera]["max_target_box"]
) )
ratio = limit / self.tracked_object_metrics[camera]["target_box"]
zoom = (ratio - 1) / (ratio + 1) zoom = (ratio - 1) / (ratio + 1)
logger.debug(f"{camera}: Zoom calculation: {zoom}") logger.debug(
f'{camera}: limit: {self.tracked_object_metrics[camera]["max_target_box"]}, ratio: {ratio} zoom calculation: {zoom}'
)
if not result: if not result:
# zoom out with special condition if zooming out because of velocity, edges, etc. # zoom out with special condition if zooming out because of velocity, edges, etc.
zoom = -(1 - zoom) if zoom > 0 else -(zoom * 2 + 1) zoom = -(1 - zoom) if zoom > 0 else -(zoom * 2 + 1)