Download examples/opencv_lock_mode.py from muhammadpriv001/Object-Intelligence-Backend: direct link, hf CLI and curl.
- Browser
- Download file 814 Bytes
-
https://huggingface.co/spaces/muhammadpriv001/Object-Intelligence-Backend/resolve/main/examples/opencv_lock_mode.py
- Command line
-
hf download hf://spaces/muhammadpriv001/Object-Intelligence-Backend/examples/opencv_lock_mode.py
-
curl -L -o opencv_lock_mode.py https://huggingface.co/spaces/muhammadpriv001/Object-Intelligence-Backend/resolve/main/examples/opencv_lock_mode.py
814 Bytes
| """ | |
| OpenCV Example 4: Lock Mode Target Detection | |
| """ | |
| import cv2 | |
| from object_intelligence import ObjectDetector | |
| def main(): | |
| detector = ObjectDetector() | |
| detector.set_mode("combined") | |
| # Enable Lock Mode for target "My Cup" or generic target "cup" | |
| target = "cup" | |
| detector.lock(target) | |
| print(f"[INFO] Lock Mode activated for target: '{target}'. Press 'q' to quit...") | |
| camera = cv2.VideoCapture(0) | |
| while True: | |
| success, frame = camera.read() | |
| if not success: | |
| break | |
| annotated_frame, detections = detector.detect_and_draw(frame) | |
| cv2.imshow("Lock Mode Real-Time Feed", annotated_frame) | |
| if cv2.waitKey(1) & 0xFF == ord('q'): | |
| break | |
| camera.release() | |
| cv2.destroyAllWindows() | |
| if __name__ == "__main__": | |
| main() | |