Код: Выделить всё
from ultralytics import YOLO
import cv2
model = YOLO('yolov8n.pt')
cap = cv2.VideoCapture(0)
cap.set(3, 640)
cap.set(4, 480)
while True:
_, frame = cap.read()
img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
results = model.predict(img)
for r in results:
for c in r.boxes.cls:
print(model.names[int(c)])
cv2.imshow('YOLO V8 Detection', frame)
if cv2.waitKey(1) & 0xFF == ord(' '):
break
cap.release()
cv2.destroyAllWindows()
Подробнее здесь: https://stackoverflow.com/questions/753 ... unding-box