fix autotracking movement time prediction and recorded move times

Movement time prediction multiplied the fitted intercept by the saved zero-step calibration time instead of 1, so predictions didn't match the regression. In absolute zoom mode, a pan/tilt followed by a zoom recorded the zoom's timestamps against the pan/tilt distance, because _zoom_absolute resets the PTZ start and stop times. The pan/tilt times are now captured before the zoom runs.
This commit is contained in:
Josh Hawkins
2026-11-10 07:25:40 -06:00
parent 33c55649a4
commit e5b25d23e5
+17 -4
View File
@@ -585,7 +585,7 @@ class PtzAutoTracker(threading.Thread):
def _predict_movement_time(self, camera, pan, tilt): def _predict_movement_time(self, camera, pan, tilt):
combined_movement = abs(pan) + abs(tilt) combined_movement = abs(pan) + abs(tilt)
input_data = np.array([self.intercept[camera], combined_movement]) input_data = np.array([1, combined_movement])
return np.dot(self.move_coefficients[camera], input_data) return np.dot(self.move_coefficients[camera], input_data)
@@ -744,6 +744,8 @@ class PtzAutoTracker(threading.Thread):
continue continue
else: else:
pan_tilt_times = None
if ( if (
camera_config.onvif.autotracking.zooming camera_config.onvif.autotracking.zooming
== ZoomingModeEnum.relative == ZoomingModeEnum.relative
@@ -755,17 +757,28 @@ class PtzAutoTracker(threading.Thread):
await self._wait_until_stopped(camera, metrics) await self._wait_until_stopped(camera, metrics)
# _zoom_absolute resets the metrics timestamps
pan_tilt_times = (
metrics.start_time.value,
metrics.stop_time.value,
)
if zoom > 0 and metrics.zoom_level.value != zoom: if zoom > 0 and metrics.zoom_level.value != zoom:
await self.onvif._zoom_absolute(camera, zoom, 1) await self.onvif._zoom_absolute(camera, zoom, 1)
await self._wait_until_stopped(camera, metrics) await self._wait_until_stopped(camera, metrics)
start_time, stop_time = pan_tilt_times or (
metrics.start_time.value,
metrics.stop_time.value,
)
if camera_config.onvif.autotracking.movement_weights: if camera_config.onvif.autotracking.movement_weights:
logger.debug( logger.debug(
f"{camera}: Predicted movement time: {self._predict_movement_time(camera, pan, tilt)}" f"{camera}: Predicted movement time: {self._predict_movement_time(camera, pan, tilt)}"
) )
logger.debug( logger.debug(
f"{camera}: Actual movement time: {metrics.stop_time.value - metrics.start_time.value}" f"{camera}: Actual movement time: {stop_time - start_time}"
) )
# save metrics for better estimate calculations # save metrics for better estimate calculations
@@ -781,8 +794,8 @@ class PtzAutoTracker(threading.Thread):
{ {
"pan": pan, "pan": pan,
"tilt": tilt, "tilt": tilt,
"start_timestamp": metrics.start_time.value, "start_timestamp": start_time,
"end_timestamp": metrics.stop_time.value, "end_timestamp": stop_time,
} }
) )