from ultralytics import YOLO import json import cv2 as cv m = YOLO("best.pt") c = cv.VideoCapture(0) while True: _, frame = c.read() res = m(frame) for i in json.loads(res[0].to_json()): i = i['box'] cv.rectangle(frame, (round(i['x1']), round(i['y1'])), (round(i['x2']), round(i['y2'])), (0, 0, 255), 3) #print(i) cv.imshow('frame', frame) if cv.waitKey(1) == ord('q'): break c.release() cv.destroyAllWindows()