mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-06 19:25:22 +03:00
add zoom factor and catch motion exception
This commit is contained in:
parent
d11c1a2066
commit
49aa1b5da5
@ -105,9 +105,16 @@ class PtzMotionEstimator:
|
|||||||
# Norfair estimator function needs color so it can convert it right back to gray
|
# Norfair estimator function needs color so it can convert it right back to gray
|
||||||
frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2BGRA)
|
frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2BGRA)
|
||||||
|
|
||||||
self.coord_transformations = self.norfair_motion_estimator.update(
|
try:
|
||||||
frame, mask
|
self.coord_transformations = self.norfair_motion_estimator.update(
|
||||||
)
|
frame, mask
|
||||||
|
)
|
||||||
|
except:
|
||||||
|
# sometimes opencv can't find enough features in the image to find homography, so catch this error
|
||||||
|
logger.error(
|
||||||
|
f"Autotracker: motion estimator couldn't find homography for {camera_name} at frame time {frame_time}"
|
||||||
|
)
|
||||||
|
self.coord_transformations = None
|
||||||
|
|
||||||
self.frame_manager.close(frame_id)
|
self.frame_manager.close(frame_id)
|
||||||
|
|
||||||
@ -545,7 +552,10 @@ class PtzAutoTracker:
|
|||||||
|
|
||||||
if camera_config.onvif.autotracking.zooming == ZoomingModeEnum.relative:
|
if camera_config.onvif.autotracking.zooming == ZoomingModeEnum.relative:
|
||||||
# relative zooming concurrently with pan/tilt
|
# relative zooming concurrently with pan/tilt
|
||||||
zoom = obj.obj_data["area"] / (camera_width * camera_height)
|
zoom_factor = 30
|
||||||
|
zoom = max(
|
||||||
|
obj.obj_data["area"] / (camera_width * camera_height) * zoom_factor, 1
|
||||||
|
)
|
||||||
|
|
||||||
# test if we need to zoom out
|
# test if we need to zoom out
|
||||||
if not self._should_zoom_in(
|
if not self._should_zoom_in(
|
||||||
@ -557,12 +567,14 @@ class PtzAutoTracker:
|
|||||||
):
|
):
|
||||||
zoom = -(1 - zoom)
|
zoom = -(1 - zoom)
|
||||||
|
|
||||||
# don't make small movements if area hasn't changed significantly
|
# don't make small movements to zoom in if area hasn't changed significantly
|
||||||
|
# but always zoom out if necessary
|
||||||
if (
|
if (
|
||||||
"area" in obj.previous
|
"area" in obj.previous
|
||||||
and abs(obj.obj_data["area"] - obj.previous["area"])
|
and abs(obj.obj_data["area"] - obj.previous["area"])
|
||||||
/ obj.obj_data["area"]
|
/ obj.obj_data["area"]
|
||||||
< 0.1
|
< 0.2
|
||||||
|
and zoom > 0
|
||||||
):
|
):
|
||||||
zoom = 0
|
zoom = 0
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user