I need to extract YUV frames directly from a web camera using OpenCV from C++ on the Windows platform. In other words: a setup in OpenCV that makes the capture device's read() method return a YUV Mat. I'm looking for a working example or documentation on how to do this.
The specific YUV subformat isn't that important for starters. The camera can produce YUV output. I cannot simply convert a BGR Mat to YUV - I need to capture it from the device without any conversions.
So far I've tried and combined
- connecting using several specific APIs (CV_CAP_DSHOW, CV_CAP_FFMPEG, CV_CAP_GSTREAMER, etc.)
- changing between different FOURCCs (MJPG, UYVY, etc.)
- toggling the CAP_PROP_CONVERT_RGB setting
- to find out what CAP_PROP_MODE might do
All to no avail as I'm still just getting output in BGR. So, any hints, links, three-liners?
(I'm using OpenCV 4.5.2)