Spaces:
Running on Zero
Running on Zero
Download examples/opencv_known_objects.py from muhammadpriv001/Object-Intelligence-Backend: direct link, hf CLI and curl.
- Browser
- Download file 725 Bytes
-
https://huggingface.co/spaces/muhammadpriv001/Object-Intelligence-Backend/resolve/main/examples/opencv_known_objects.py
- Command line
-
hf download hf://spaces/muhammadpriv001/Object-Intelligence-Backend/examples/opencv_known_objects.py
-
curl -L -o opencv_known_objects.py https://huggingface.co/spaces/muhammadpriv001/Object-Intelligence-Backend/resolve/main/examples/opencv_known_objects.py
725 Bytes
| """ | |
| OpenCV Example 1: Known Object Detection (RT-DETR) | |
| """ | |
| import cv2 | |
| from object_intelligence import ObjectDetector | |
| def main(): | |
| detector = ObjectDetector() | |
| detector.set_mode("known") | |
| camera = cv2.VideoCapture(0) | |
| print("[INFO] Press 'q' to quit...") | |
| while True: | |
| success, frame = camera.read() | |
| if not success: | |
| print("[WARN] Failed to read frame from webcam.") | |
| break | |
| annotated_frame, detections = detector.detect_and_draw(frame) | |
| cv2.imshow("Known Object Detection (RT-DETR)", annotated_frame) | |
| if cv2.waitKey(1) & 0xFF == ord('q'): | |
| break | |
| camera.release() | |
| cv2.destroyAllWindows() | |
| if __name__ == "__main__": | |
| main() | |