I have my webcam set up to be the input for my model.predict() function and want to trigger some code if the function detects a certain object. The model.predict() function does not seem to ever terminate when using a webcam however, making this not possible. Just wondering what a solution to this could be.
from ultralytics import YOLO
from ultralytics.yolo.v8.detect.predict import DetectionPredictor
import cv2
print('hi')
model = YOLO("C:/Users/User/Downloads/best.pt")
outs = model.predict(source="0", show=True)
print('hey')
# hi gets printed but not hey
If i include the paramater verbose=true in the predict function, the information I need is printed to the terminal, but I do not know how to access this in a variable to trigger more code. Perhaps multi-threading could help but surely there would be a simpler method?