ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.08k stars 16.18k forks source link

I want to pass the image read by opencv to the model I/F #9913

Closed Heartful-echo closed 1 year ago

Heartful-echo commented 1 year ago

Search before asking

Question

Hi

I want to pass the image read by opencv to the model I/F. I wrote a simple code.

cap = cv2.VideoCapture (0) _, img= cap.read() results = model(img)

Even if there is a person in front of the camera, it will not be detected. Is this code written correctly?

Additional

No response

glenn-jocher commented 1 year ago

@kazuya-uchida this is incorrect usage since cv2 loads in BGR and all YOLO models expect RGB. See PyTorch Hub tutorial for correct usage examples.

Tutorials

Good luck 🍀 and let us know if you have any other questions!

Heartful-echo commented 1 year ago

@glenn-jocher

Thank you for your advice.

glenn-jocher commented 10 months ago

@Heartful-echo you're welcome! If you have any more questions or need further assistance, feel free to ask. We're here to help!