Ver Fonte

feat(capture/uploader: add install_address parameter

1. 为CaptureUploader.handle_detection方法新增install_address可选参数并上报到上报数据中
2. 为全景和PTZ检测线程新增安装地址参数,传入上报方法
wenhongquan há 1 mês atrás
pai
commit
70409885a5

+ 4 - 4
deploy/src/dual_camera_system/app.py

@@ -135,7 +135,7 @@ def create_app(test_mode: bool = False) -> FastAPI:
                 )
 
                 if SYSTEM_CONFIG.get("enable_detection", True) and detector_service is not None:
-                    def panorama_detect_loop(g=gid, uploader=uploader, detector=detector_service):
+                    def panorama_detect_loop(g=gid, uploader=uploader, detector=detector_service, install_address=group.get("panorama", {}).get("install_address", "")):
                         interval = 0.5
                         frame_count = 0
                         while not stop_event.is_set():
@@ -156,7 +156,7 @@ def create_app(test_mode: bool = False) -> FastAPI:
                                         } for d in dets]
                                         for dd in det_dicts:
                                             print(f"[detect] {g} bbox={dd['bbox']} conf={dd['confidence']:.3f}")
-                                        uploader.handle_detection("panorama", frame, det_dicts)
+                                            uploader.handle_detection("panorama", frame, det_dicts, install_address)
                                         for d in det_dicts:
                                             x1, y1, x2, y2 = d["bbox"]
                                             cv2.rectangle(marked, (x1, y1), (x2, y2), (0, 255, 0), 2)
@@ -174,7 +174,7 @@ def create_app(test_mode: bool = False) -> FastAPI:
                     threads.append(t_panorama)
 
                     if ptz_url:
-                        def ptz_detect_loop(g=gid, uploader=uploader, detector=detector_service):
+                        def ptz_detect_loop(g=gid, uploader=uploader, detector=detector_service, install_address=group.get("ptz", {}).get("install_address", "")):
                             interval = 0.5
                             while not stop_event.is_set():
                                 try:
@@ -189,7 +189,7 @@ def create_app(test_mode: bool = False) -> FastAPI:
                                             } for d in dets]
                                             for dd in det_dicts:
                                                 print(f"[detect] {g} PTZ bbox={dd['bbox']} conf={dd['confidence']:.3f}")
-                                            uploader.handle_detection("ptz", frame, det_dicts)
+                                            uploader.handle_detection("ptz", frame, det_dicts, install_address)
                                 except Exception as exc:
                                     print(f"[ptz_detect_loop {g}] error: {exc}")
                                 time.sleep(interval)

+ 2 - 0
deploy/src/dual_camera_system/core/capture_uploader.py

@@ -79,6 +79,7 @@ class CaptureUploader:
         camera_type: str,
         frame: np.ndarray,
         detections: List[Dict],
+        install_address: str = "",
     ) -> List[Dict]:
         self._validate_inputs(frame, detections)
 
@@ -158,6 +159,7 @@ class CaptureUploader:
                 "project_id": DEVICE_CONFIG.get("project_id", ""),
                 "timestamp": ts,
                 "camera_type": camera_type,
+                "install_address": install_address,
                 "image_paths": [original_path, marked_path],
                 "image_urls": image_urls,
                 "detections": [