|
@@ -1218,6 +1218,18 @@ class AsyncCoordinator(Coordinator):
|
|
|
"""发送PTZ命令并打印日志"""
|
|
"""发送PTZ命令并打印日志"""
|
|
|
x_ratio, y_ratio = target.position
|
|
x_ratio, y_ratio = target.position
|
|
|
|
|
|
|
|
|
|
+ # 冷却检查(与 _send_ptz_command 保持一致)
|
|
|
|
|
+ current_time = time.time()
|
|
|
|
|
+ if current_time - self._last_ptz_time < self.PTZ_COMMAND_COOLDOWN:
|
|
|
|
|
+ return
|
|
|
|
|
+
|
|
|
|
|
+ # 位置变化阈值检查
|
|
|
|
|
+ if self.last_ptz_position is not None:
|
|
|
|
|
+ last_x, last_y = self.last_ptz_position
|
|
|
|
|
+ if abs(x_ratio - last_x) < self.ptz_position_threshold and \
|
|
|
|
|
+ abs(y_ratio - last_y) < self.ptz_position_threshold:
|
|
|
|
|
+ return
|
|
|
|
|
+
|
|
|
# 计算PTZ角度(用于日志)
|
|
# 计算PTZ角度(用于日志)
|
|
|
if self.enable_calibration and self.calibrator and self.calibrator.is_calibrated():
|
|
if self.enable_calibration and self.calibrator and self.calibrator.is_calibrated():
|
|
|
pan, tilt = self.calibrator.transform(x_ratio, y_ratio)
|
|
pan, tilt = self.calibrator.transform(x_ratio, y_ratio)
|
|
@@ -1242,6 +1254,7 @@ class AsyncCoordinator(Coordinator):
|
|
|
|
|
|
|
|
try:
|
|
try:
|
|
|
self._ptz_queue.put_nowait(cmd)
|
|
self._ptz_queue.put_nowait(cmd)
|
|
|
|
|
+ self.last_ptz_position = (x_ratio, y_ratio) # 更新位置记录
|
|
|
self._update_stats('ptz_commands_sent' if 'ptz_commands_sent' in self.stats else 'persons_detected')
|
|
self._update_stats('ptz_commands_sent' if 'ptz_commands_sent' in self.stats else 'persons_detected')
|
|
|
logger.info(
|
|
logger.info(
|
|
|
f"[PTZ] 命令已发送: 目标ID={target.track_id} "
|
|
f"[PTZ] 命令已发送: 目标ID={target.track_id} "
|