I’m attempting to use OpenCV for a webcam stream and feed it to a yolov8 model I have for face detection.
Without using OpenCV, I am able to run (in python):
model= YOLO("mymodel.pt")
model.predict(source="1", show=True)
However this has pretty bad frames and I wanted to give OpenCV a try for more customization.
I can use OpenCV and open the webcam and even show it. However, using:
ret, frame = cv2.read()
results = model(frame)
I receive an error:
The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
trying to use any() or all() results in an error that a file ‘None’ or ‘True’ does not exist. I’m not quite sure what’s happening, but I have found plenty of examples of OpenCV webcam frames being sent to YOLO this way without such an error.