import sys sys.path.insert(0, '/home/admin/dsh/dual_camera_system') import cv2 from panorama_camera import ObjectDetector from config.detection import DETECTION_CONFIG import time print('Loading detector...') detector = ObjectDetector( model_path=DETECTION_CONFIG['model_path'], use_gpu=DETECTION_CONFIG['use_gpu'], model_type=DETECTION_CONFIG['model_type'] ) print('Detector loaded, type:', detector.model_type) # Load test image frame = cv2.imread('/home/admin/dsh/panorama_now.jpg') if frame is None: print('Failed to load image') sys.exit(1) print('Image shape:', frame.shape) # Run detection t0 = time.time() dets = detector.detect(frame) t1 = time.time() print(f'Detection took {t1-t0:.3f}s, found {len(dets)} objects') for d in dets: print(f' {d.class_name}: conf={d.confidence:.3f}, bbox={d.bbox}, center={d.center}') # Save marked image marked = frame.copy() for d in dets: x, y, w, h = d.bbox cv2.rectangle(marked, (x, y), (x+w, y+h), (0, 255, 0), 2) cv2.putText(marked, f'{d.class_name} {d.confidence:.2f}', (x, y-5), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 255, 0), 2) cv2.imwrite('/home/admin/dsh/detection_test.jpg', marked) print('Saved marked image to /home/admin/dsh/detection_test.jpg')