Преглед изворни кода

refactor(coordinator): 完整移除旧版联动控制器及相关类实现

- 删除了 TrackingState 枚举及 TrackingTarget 数据类
- 移除了 TargetSelector 目标选择策略类
- 删除 Coordinator 基类及其事件驱动子类 EventDrivenCoordinator
- 移除带有 PTZCommand 的 AsyncCoordinator 异步实现
- 彻底清理控制器相关的线程、跟踪与检测逻辑
- 移除 OCR、PTZ控制、目标选择和配对图片保存等功能代码
- 清理所有与联动协调和目标管理相关的状态和回调实现
wenhongquan пре 3 дана
родитељ
комит
c03978598c

BIN
dual_camera_system/__pycache__/coordinator.cpython-313.pyc


BIN
dual_camera_system/__pycache__/paired_image_saver.cpython-313.pyc


+ 14 - 15
dual_camera_system/coordinator.py

@@ -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] 命令队列满,丢弃本次命令")
     

+ 2 - 7
dual_camera_system/paired_image_saver.py

@@ -120,13 +120,8 @@ class PairedImageSaver:
         with self._batch_lock:
             current_time = time.time()
             
-            # 检查是否需要创建新批次(时间窗口已过)
-            if (self._current_batch is not None and 
-                current_time - self._last_batch_time < self.time_window):
-                # 仍在当前时间窗口内,复用当前批次
-                return self._current_batch.batch_id
-            
-            # 完成上一批次
+            # 完成上一批次(如果有)
+            # 注意:每次检测都创建独立批次,不复用,确保 batch_info 与实际检测一致
             if self._current_batch is not None:
                 self._finalize_batch(self._current_batch)