I'm using OpenCV 2.4.8.2 with V4L2 connected to a UVC camera that claims to provide "raw" video. I've attached a (jpeg compressed) shot from a single frame provided by opencv's VideoCapture:
If I run:
$ v4l2-ctl -V Format Video Capture: Width/Height : 1280/720 Pixel Format : 'YUYV' Field : None Bytes per Line: 2560 Size Image : 1843200 Colorspace : Unknown (00000000) $v4l2-ctl --list-formats ioctl: VIDIOC_ENUM_FMT Index : 0 Type : Video Capture Pixel Format: 'YUYV' Name : YUV 4:2:2 (YUYV)
This appears to be a Bayered image, but opencv's VideoCapture has already split it into BGR24 format. Looking at cv:demosaicing I see that all of the Bayer2Foo methods require a source image has only one channel ...but the image VideoCapture provides already has three channels.
Digging deeper into the VideoCapture sources, it appears that opencv's icvRetrieveFrameCAM_V4L immediately performs yuyv_to_rgb24 on any video source with a detected palette of YUYV. My guess is that bayer2rgb24 would be more appropriate in this case, but I don't see a way to tell icvRetrieveFrameCAM_V4L to try that instead.
Any suggestions on a path forward here? I can't really change what the camera outputs, and apparently icvRetrieveFrameCAM_V4L will always generate BGR24. Is there a straightforward way to map this BGR24 format back to a format that can be demosaiced/debayered? The only alternative I can see is to write our own custom driver to pull images from the camera and skip VideoCapture altogether.
Thanks for any help!