Object-Intelligence-Backend / examples /opencv_specific_object.py
muhammadpriv001's picture
Frontend 1.0.0
4346a4c
Raw History Blame Contribute Delete
854 Bytes
"""
OpenCV Example 3: Specific Object Recognition (Visual Embeddings)
"""
import cv2
from object_intelligence import ObjectDetector
def main():
detector = ObjectDetector()
detector.set_mode("specific")
camera = cv2.VideoCapture(0)
print("[INFO] Press 'q' to quit...")
while True:
success, frame = camera.read()
if not success:
break
annotated_frame, detections = detector.detect_and_draw(frame)
for det in detections:
if det.get("type") == "specific":
print(f"[RECOGNIZED] Object: {det['label']} | Similarity: {det['confidence']:.2f}")
cv2.imshow("Specific Object Recognition", annotated_frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
camera.release()
cv2.destroyAllWindows()
if __name__ == "__main__":
main()