|
|
@@ -1185,21 +1185,6 @@ class AsyncCoordinator(Coordinator):
|
|
|
"""发送PTZ命令并打印日志"""
|
|
|
x_ratio, y_ratio = target.position
|
|
|
|
|
|
- # 计算PTZ角度(用于日志)
|
|
|
- if self.enable_calibration and self.calibrator and self.calibrator.is_calibrated():
|
|
|
- pan, tilt = self.calibrator.transform(x_ratio, y_ratio)
|
|
|
- zoom = self.ptz.ptz_config.get('default_zoom', 8)
|
|
|
- coord_type = "校准坐标"
|
|
|
- else:
|
|
|
- pan, tilt, zoom = self.ptz.calculate_ptz_position(x_ratio, y_ratio)
|
|
|
- coord_type = "估算坐标"
|
|
|
-
|
|
|
- logger.info(
|
|
|
- f"[PTZ] 发送命令: 目标ID={target.track_id} "
|
|
|
- f"全景位置=({x_ratio:.3f}, {y_ratio:.3f}) → "
|
|
|
- f"PTZ角度=(pan={pan:.1f}°, tilt={tilt:.1f}°, zoom={zoom}) [{coord_type}]"
|
|
|
- )
|
|
|
-
|
|
|
# 检查位置变化是否超过阈值
|
|
|
ptz_threshold = self.config.get('ptz_position_threshold', 0.03)
|
|
|
if self.last_ptz_position is not None:
|
|
|
@@ -1217,6 +1202,15 @@ class AsyncCoordinator(Coordinator):
|
|
|
logger.debug(f"[PTZ] 冷却中,跳过 (间隔={current_time - self._last_ptz_time:.2f}s < {ptz_cooldown}s)")
|
|
|
return
|
|
|
|
|
|
+ # 计算PTZ角度(用于日志)
|
|
|
+ if self.enable_calibration and self.calibrator and self.calibrator.is_calibrated():
|
|
|
+ pan, tilt = self.calibrator.transform(x_ratio, y_ratio)
|
|
|
+ zoom = self.ptz.ptz_config.get('default_zoom', 8)
|
|
|
+ coord_type = "校准坐标"
|
|
|
+ else:
|
|
|
+ pan, tilt, zoom = self.ptz.calculate_ptz_position(x_ratio, y_ratio)
|
|
|
+ coord_type = "估算坐标"
|
|
|
+
|
|
|
# 获取当前批次信息和人员序号
|
|
|
batch_id = self._current_batch_id if self._enable_paired_saving else None
|
|
|
person_index = self._person_ptz_index.get(target.track_id, -1) if self._enable_paired_saving else -1
|
|
|
@@ -1234,6 +1228,11 @@ class AsyncCoordinator(Coordinator):
|
|
|
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')
|
|
|
+ logger.info(
|
|
|
+ f"[PTZ] 命令已发送: 目标ID={target.track_id} "
|
|
|
+ f"全景位置=({x_ratio:.3f}, {y_ratio:.3f}) → "
|
|
|
+ f"PTZ角度=(pan={pan:.1f}°, tilt={tilt:.1f}°, zoom={zoom}) [{coord_type}]"
|
|
|
+ )
|
|
|
except queue.Full:
|
|
|
logger.warning("[PTZ] 命令队列满,丢弃本次命令")
|
|
|
|