OpenCV capture YUYV from camera without RGB conversion

I am trying to use openCV / C ++ to capture left and right image with LI-USB30_V024 stereo camera without automatically converting it to RGB. The camera outputs images in YUYV format.

I tried to use videoCapture.set (CV_CAP_PROP_CONVERT_RGB, false), but I get the message "HIGHGUI ERROR: V4L: property (16) not supported by device".

The reason I want to avoid converting to RGB is because the camera is combining the left and right video together with one YUYV image. Both cameras are monochrome, and as far as I can tell, the left image information is encoded in Y-channels, while the correct image is encoded in U and V-channels. For example, if I run guvcview, I get one image that contains both the left and right images on top. It looks like a black and white image (the left image is encoded in Y-channels) with a green and pink image on top (the right camera is encoded in the UV channels). I know this sounds rather unusual, so if you have any other ideas / questions about this, feel free to.

My goal is to capture the image as YUYV so that I can use split () to split the left image (Y-channels) from the right image (U and V-channels) and display them as monochrome images. However, once the image has been converted to RGB, the luma and chominance channels merge together and it becomes impossible to separate the two images.

To summarize, I need to capture a video without converting it to RGB in order to keep the YUYV format. This will allow me to separate the left and right images.

OR I need a way to record the left and right images separately, but I think this is unlikely.

I think this is possible in v4l, but I would rather use openCV if possible.

Thank!

+3


source to share


3 answers


I don't think there is a way to do this in openCV. In the end, there weren't many problems grabbing frames from V4L2 and saving them in openCV masks.



+2


source


I was using wrok on a camera that was generating YUV420 data and there was a problem setting it up. But this feature works for me.

videoCapture.set (CV_CAP_PROP_CONVERT_RGB, 0)



You can check if there is any other configuration that is causing the problem.

0


source


In the videoio.hpp header file :

// Generic camera output modes.
// Currently, these are supported through the libv4l interface only.
enum { CAP_MODE_BGR  = 0, // BGR24 (default)
       CAP_MODE_RGB  = 1, // RGB24
       CAP_MODE_GRAY = 2, // Y8
       CAP_MODE_YUYV = 3  // YUYV
     };

      

Using:

cv::VideoCapture camera = cv::VideoCapture();
camera.open(0);
camera.set(CV_CAP_PROP_MODE, CV_CAP_MODE_YUYV);

      

-2


source







All Articles