Spaces:
Sleeping
Sleeping
File size: 442 Bytes
03efa53 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
from ultralytics import YOLO
import cv2
model = YOLO("runs/detect/weights/best.pt")
cap = cv2.VideoCapture(0) # 0 = default webcam
while cap.isOpened():
ret, frame = cap.read()
if not ret: break
results = model(frame, conf=0.5, imgsz=640, augment=False)
annotated_frame = results[0].plot()
cv2.imshow("Webcam Detection", annotated_frame)
if cv2.waitKey(1) == ord('q'): break
cap.release()
cv2.destroyAllWindows() |