diff --git a/docs/docs/configuration/autotracking.md b/docs/docs/configuration/autotracking.md index 4191a32c9..6fc6fdcef 100644 --- a/docs/docs/configuration/autotracking.md +++ b/docs/docs/configuration/autotracking.md @@ -113,7 +113,7 @@ If you initially calibrate with zooming disabled and then enable zooming at a la Every PTZ camera is different, so autotracking may not perform ideally in every situation. This experimental feature was initially developed using an EmpireTech/Dahua SD1A404XB-GNR. -The object tracker in Frigate estimates the motion of the PTZ so that tracked objects are preserved when the camera moves. In most cases (especially for faster moving objects), the default 5 fps is insufficient for the motion estimator to perform accurately. 10 fps is the current recommendation. Higher frame rates will likely not be more performant and will only slow down Frigate and the motion estimator. Adjust your camera to output at least 10 frames per second and change the `fps` parameter in the [detect configuration](index.md) of your configuration file. +The object tracker in Frigate estimates the motion of the PTZ so that tracked objects are preserved when the camera moves. In most cases 5 fps is sufficient, but if you plan to track faster moving objects, you may want to increase this slightly. Higher frame rates (> 10fps) will only slow down Frigate and the motion estimator and may lead to dropped frames, especially if you are using experimental zooming. A fast [detector](object_detectors.md) is recommended. CPU detectors will not perform well or won't work at all. You can watch Frigate's debug viewer for your camera to see a thicker colored box around the object currently being autotracked. diff --git a/frigate/config.py b/frigate/config.py index 2c9734ec6..41033b55e 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -171,7 +171,7 @@ class PtzAutotrackConfig(FrigateBaseModel): timeout: int = Field( default=10, title="Seconds to delay before returning to preset." ) - movement_weights: Optional[Union[float, List[float]]] = Field( + movement_weights: Optional[Union[str, List[str]]] = Field( default=[], title="Internal value used for PTZ movements based on the speed of your camera's motor.", ) diff --git a/frigate/object_processing.py b/frigate/object_processing.py index 64794361f..44538cbb2 100644 --- a/frigate/object_processing.py +++ b/frigate/object_processing.py @@ -248,9 +248,9 @@ class TrackedObject: if self.obj_data["frame_time"] - self.previous["frame_time"] > 60: significant_change = True - # update autotrack at half fps - if self.obj_data["frame_time"] - self.previous["frame_time"] > ( - 1 / (self.camera_config.detect.fps / 2) + # update autotrack at most 3 objects per second + if self.obj_data["frame_time"] - self.previous["frame_time"] >= ( + 1 / min(self.camera_config.detect.fps, 3) ): autotracker_update = True diff --git a/frigate/ptz/autotrack.py b/frigate/ptz/autotrack.py index f5e709102..dad8d8cc8 100644 --- a/frigate/ptz/autotrack.py +++ b/frigate/ptz/autotrack.py @@ -58,8 +58,6 @@ class PtzMotionEstimator: self.ptz_metrics = ptz_metrics self.ptz_start_time = self.ptz_metrics["ptz_start_time"] self.ptz_stop_time = self.ptz_metrics["ptz_stop_time"] - self.last_update = 0 - self.update_interval = 1 / (self.camera_config.detect.fps / 3) self.ptz_metrics["ptz_reset"].set() logger.debug(f"{config.name}: Motion estimator init") @@ -89,25 +87,12 @@ class PtzMotionEstimator: self.coord_transformations = None self.last_update = 0 - ptz_moving = ptz_moving_at_frame_time( + if ptz_moving_at_frame_time( frame_time, self.ptz_start_time.value, self.ptz_stop_time.value - ) - - if ( - self.camera_config.onvif.autotracking.zooming != ZoomingModeEnum.disabled - and ( - (frame_time - self.last_update > self.update_interval and ptz_moving) - or frame_time == self.ptz_start_time.value - or frame_time == self.ptz_stop_time.value - ) - ) or ( - self.camera_config.onvif.autotracking.zooming == ZoomingModeEnum.disabled - and ptz_moving ): logger.debug( f"{camera}: Motion estimator running - frame time: {frame_time}" ) - self.last_update = frame_time frame_id = f"{camera}{frame_time}" yuv_frame = self.frame_manager.get( @@ -284,6 +269,10 @@ class PtzAutoTracker: if camera_config.onvif.autotracking.movement_weights: if len(camera_config.onvif.autotracking.movement_weights) == 5: + camera_config.onvif.autotracking.movement_weights = [ + float(val) + for val in camera_config.onvif.autotracking.movement_weights + ] self.ptz_metrics[camera][ "ptz_min_zoom" ].value = camera_config.onvif.autotracking.movement_weights[0]