Browse Source

refactor(paired_image_saver): 优化全景图保存逻辑,提升代码清晰度

- 调整全景图保存函数,去除内部人员置信度过滤,改由调用方负责过滤
- 修改全景图保存日志,记录实际保存的人员数量
- 统一全景图保存文件命名,使用实际人员数量命名文件
- 优化注释说明,明确人员列表已预处理,简化代码理解
- 细节调整,提升代码可读性和维护性,未改变主要功能逻辑
wenhongquan 3 days ago
parent
commit
9458b0bc93

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


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


+ 7 - 14
dual_camera_system/paired_image_saver.py

@@ -184,7 +184,7 @@ class PairedImageSaver:
             batch_dir: 批次目录
             batch_id: 批次ID
             frame: 全景帧
-            persons: 人员列表
+            persons: 人员列表(已由调用方过滤,此处不再过滤)
             
         Returns:
             保存路径或 None
@@ -193,16 +193,9 @@ class PairedImageSaver:
             # 复制图像避免修改原图
             marked_frame = frame.copy()
             
-            # 过滤有效人员(置信度 >= 阈值)
-            person_threshold = 0.8  # 人员检测置信度阈值
-            valid_persons = []
-            for person in persons:
-                conf = person.get('confidence', 0.0)
-                if conf >= person_threshold:
-                    valid_persons.append(person)
-            
-            # 绘制每个有效人员的标记(使用连续的序号)
-            for i, person in enumerate(valid_persons):
+            # 绘制每个人员的标记(使用连续的序号)
+            # 注意:persons 已由调用方(coordinator)过滤,置信度均 >= 阈值
+            for i, person in enumerate(persons):
                 bbox = person.get('bbox', (0, 0, 0, 0))
                 x1, y1, x2, y2 = bbox
                 conf = person.get('confidence', 0.0)
@@ -233,12 +226,12 @@ class PairedImageSaver:
                     (0, 0, 0), 2
                 )
             
-            # 保存图片(使用有效人员数量)
-            filename = f"00_panorama_n{len(valid_persons)}.jpg"
+            # 保存图片(使用人员数量)
+            filename = f"00_panorama_n{len(persons)}.jpg"
             filepath = batch_dir / filename
             cv2.imwrite(str(filepath), marked_frame, [cv2.IMWRITE_JPEG_QUALITY, 90])
             
-            logger.info(f"[配对保存] 全景图已保存: {filepath},有效人员 {len(valid_persons)}/{len(persons)}")
+            logger.info(f"[配对保存] 全景图已保存: {filepath},人员数量 {len(persons)}")
             return str(filepath)
             
         except Exception as e: