"""复用现有 ObjectDetector 的薄封装.""" import threading from config.detection import DETECTION_CONFIG from panorama_camera import ObjectDetector class DetectorService: def __init__(self, model_path: str = None, use_gpu: bool = None): model_path = model_path or DETECTION_CONFIG.get("model_path") if use_gpu is None: use_gpu = DETECTION_CONFIG.get("use_gpu", True) self.detector = ObjectDetector(model_path=model_path, use_gpu=use_gpu) self._lock = threading.Lock() def detect(self, frame): with self._lock: return self.detector.detect(frame)