final tweaks and docs

This commit is contained in:
Josh Hawkins 2023-10-08 18:40:39 -05:00
parent 7d0b9edeec
commit 2e788b2ca2
5 changed files with 40 additions and 10 deletions

View File

@ -147,11 +147,11 @@ Watching Frigate's debug view can help to determine a possible cause. The autotr
### I'm seeing an error in the logs that my camera "is still in ONVIF 'MOVING' status." What does this mean? ### I'm seeing an error in the logs that my camera "is still in ONVIF 'MOVING' status." What does this mean?
There are two possible reasons for this: a slow PTZ motor or buggy Hikvision firmware. Frigate uses an ONVIF parameter provided by the camera, `MoveStatus`, to determine when the PTZ's motor is moving or idle. According to some users, Hikvision PTZs (even with the latest firmware), are not updating this value after PTZ movement. Unfortunately there is no workaround to this bug in Hikvision firmware, so autotracking will not function correctly and should be disabled in your config. There are two possible known reasons for this (and perhaps others yet unknown): a slow PTZ motor or buggy camera firmware. Frigate uses an ONVIF parameter provided by the camera, `MoveStatus`, to determine when the PTZ's motor is moving or idle. According to some users, Hikvision PTZs (even with the latest firmware), are not updating this value after PTZ movement. Unfortunately there is no workaround to this bug in Hikvision firmware, so autotracking will not function correctly and should be disabled in your config. This may also be the case with other non-Hikvision cameras utilizing Hikvision firmware.
### I tried calibrating my camera, but it is stuck at 0%. ### I tried calibrating my camera, but the logs show that it is stuck at 0% and Frigate is not starting up.
This is often caused by the same reason as above - the `MoveStatus` ONVIF parameter is not changing due to a bug in Hikvision firmware. This is often caused by the same reason as above - the `MoveStatus` ONVIF parameter is not changing due to a bug in your camera's firmware. Also, see the note above: Frigate's web UI and all other cameras will be unresponsive while calibration is in progress. This is expected and normal. But if you don't see log entries every few seconds for calibration progress, your camera is not compatible with autotracking.
### I'm seeing this error in the logs: "Autotracker: motion estimator couldn't get transformations". What does this mean? ### I'm seeing this error in the logs: "Autotracker: motion estimator couldn't get transformations". What does this mean?

View File

@ -176,11 +176,13 @@ class Dispatcher:
if not self.ptz_metrics[camera_name]["ptz_autotracker_enabled"].value: if not self.ptz_metrics[camera_name]["ptz_autotracker_enabled"].value:
logger.info(f"Turning on ptz autotracker for {camera_name}") logger.info(f"Turning on ptz autotracker for {camera_name}")
self.ptz_metrics[camera_name]["ptz_autotracker_enabled"].value = True self.ptz_metrics[camera_name]["ptz_autotracker_enabled"].value = True
self.ptz_metrics[camera_name]["ptz_start_time"].value = 0
ptz_autotracker_settings.enabled = True ptz_autotracker_settings.enabled = True
elif payload == "OFF": elif payload == "OFF":
if self.ptz_metrics[camera_name]["ptz_autotracker_enabled"].value: if self.ptz_metrics[camera_name]["ptz_autotracker_enabled"].value:
logger.info(f"Turning off ptz autotracker for {camera_name}") logger.info(f"Turning off ptz autotracker for {camera_name}")
self.ptz_metrics[camera_name]["ptz_autotracker_enabled"].value = False self.ptz_metrics[camera_name]["ptz_autotracker_enabled"].value = False
self.ptz_metrics[camera_name]["ptz_start_time"].value = 0
ptz_autotracker_settings.enabled = False ptz_autotracker_settings.enabled = False
self.publish(f"{camera_name}/ptz_autotracker/state", payload, retain=True) self.publish(f"{camera_name}/ptz_autotracker/state", payload, retain=True)

View File

@ -80,7 +80,7 @@ class PtzMotionEstimator:
frame_time, self.ptz_start_time.value, self.ptz_stop_time.value frame_time, self.ptz_start_time.value, self.ptz_stop_time.value
): ):
logger.debug( logger.debug(
f"{camera}: Motion estimator running - frame time: {frame_time}, ptz start: {self.ptz_start_time.value}, ptz stop: {self.ptz_stop_time.value}" f"{camera}: Motion estimator running - frame time: {frame_time}"
) )
frame_id = f"{camera}{frame_time}" frame_id = f"{camera}{frame_time}"
@ -113,6 +113,7 @@ class PtzMotionEstimator:
) )
except Exception: except Exception:
# sometimes opencv can't find enough features in the image to find homography, so catch this error # sometimes opencv can't find enough features in the image to find homography, so catch this error
# https://github.com/tryolabs/norfair/pull/278
logger.warning( logger.warning(
f"Autotracker: motion estimator couldn't get transformations for {camera} at frame time {frame_time}" f"Autotracker: motion estimator couldn't get transformations for {camera} at frame time {frame_time}"
) )
@ -782,7 +783,7 @@ class PtzAutoTracker:
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 # start with a slightly altered box to encourage an initial zoom
self.previous_target_box[camera] = target_box * 1.2 self.previous_target_box[camera] = target_box * 1.15
if ( if (
result := self._should_zoom_in( result := self._should_zoom_in(
@ -910,11 +911,13 @@ class PtzAutoTracker:
def camera_maintenance(self, camera): def camera_maintenance(self, camera):
# bail and don't check anything if we're calibrating or tracking an object # bail and don't check anything if we're calibrating or tracking an object
if self.calibrating[camera] or self.tracked_object[camera] is not None: if (
not self.autotracker_init[camera]
or self.calibrating[camera]
or self.tracked_object[camera] is not None
):
return return
logger.debug(f"{camera}: Running camera maintenance")
# calls get_camera_status to check/update ptz movement # calls get_camera_status to check/update ptz movement
# returns camera to preset after timeout when tracking is over # returns camera to preset after timeout when tracking is over
autotracker_config = self.config.cameras[camera].onvif.autotracking autotracker_config = self.config.cameras[camera].onvif.autotracking

View File

@ -350,6 +350,13 @@ class OnvifController:
self.cams[camera_name]["active"] = True self.cams[camera_name]["active"] = True
self.ptz_metrics[camera_name]["ptz_stopped"].clear() self.ptz_metrics[camera_name]["ptz_stopped"].clear()
logger.debug(
f"{camera_name} PTZ start time: {self.ptz_metrics[camera_name]['ptz_frame_time'].value}"
)
self.ptz_metrics[camera_name]["ptz_start_time"].value = self.ptz_metrics[
camera_name
]["ptz_frame_time"].value
self.ptz_metrics[camera_name]["ptz_stop_time"].value = 0
move_request = self.cams[camera_name]["move_request"] move_request = self.cams[camera_name]["move_request"]
onvif: ONVIFCamera = self.cams[camera_name]["onvif"] onvif: ONVIFCamera = self.cams[camera_name]["onvif"]
preset_token = self.cams[camera_name]["presets"][preset] preset_token = self.cams[camera_name]["presets"][preset]
@ -359,7 +366,7 @@ class OnvifController:
"PresetToken": preset_token, "PresetToken": preset_token,
} }
) )
self.ptz_metrics[camera_name]["ptz_stopped"].set()
self.cams[camera_name]["active"] = False self.cams[camera_name]["active"] = False
def _zoom(self, camera_name: str, command: OnvifCommandEnum) -> None: def _zoom(self, camera_name: str, command: OnvifCommandEnum) -> None:

View File

@ -21,6 +21,7 @@ from frigate.log import LogPipe
from frigate.motion import MotionDetector from frigate.motion import MotionDetector
from frigate.motion.improved_motion import ImprovedMotionDetector from frigate.motion.improved_motion import ImprovedMotionDetector
from frigate.object_detection import RemoteObjectDetector from frigate.object_detection import RemoteObjectDetector
from frigate.ptz.autotrack import ptz_moving_at_frame_time
from frigate.track import ObjectTracker from frigate.track import ObjectTracker
from frigate.track.norfair_tracker import NorfairTracker from frigate.track.norfair_tracker import NorfairTracker
from frigate.types import PTZMetricsTypes from frigate.types import PTZMetricsTypes
@ -776,7 +777,24 @@ def process_frames(
logger.info(f"{camera_name}: frame {frame_time} is not in memory store.") logger.info(f"{camera_name}: frame {frame_time} is not in memory store.")
continue continue
motion_boxes = motion_detector.detect(frame) if motion_enabled.value else [] # always returns false if autotracking is disabled
ptz_moving = ptz_moving_at_frame_time(
frame_time,
ptz_metrics["ptz_start_time"].value,
ptz_metrics["ptz_stop_time"].value,
)
motion_boxes = (
motion_detector.detect(frame)
if motion_enabled.value and not ptz_moving
else []
)
# full frame motion if ptz is moving from autotracking - remove this later
# better to have motion detector expose property when it's calibrating
# but still return motion boxes for retention purposes
if ptz_moving:
motion_boxes = [(0, 0, frame_shape[1], frame_shape[0] * 3 // 2)]
regions = [] regions = []
consolidated_detections = [] consolidated_detections = []