How to change the camera pixel formate from V4L2_PIX_FMT_SRGGB8 to V4L2_PIX_FMT_YUYV

Hello :
now i am trying to make the camera work under the opencv3.2.0.but now is the problem : pixel formate is bayer not yuv or any other formate acceped by opencv (cap_v4l.cpp)
i still try to make the opencv work independed from gstreamer.


question :
1,exec : “gst-lunch-0.1” the command line like “formate=(String)I420” means 420 yuv formate and how could the gstream change the formate?
2,i tried to modifide code like this :

static int autosetup_capture_mode_v4l2(CvCaptureCAM_V4L* capture) {
//in case palette is already set and works, no need to setup.
if(capture->palette != 0 and try_palette_v4l2(capture)){
return 0;
__u32 try_order = {
#ifdef HAVE_JPEG
/* Bayer formats - see */

nothings seemed to happened to the display window.

Hi edwardlu

  1. There’s no way to change the nvcamerasrc output format, except have convertor to change it.
  2. If your sensor is bayer and you want to capture it by v4l2 them you need to postprocess the RAW data and convert to the format you want. The V4L2 won’t do any convert it only capture what sensor output.

hello shaneCCC:

I know it would be a huge effort to make the V4L-lib work in Opencv,but I still want to know:
First of all,my camera is the one Jetson-TX1 it takes,I did not change any other type of CCD sensor.

1,how gstream nvcamerasrc get the video data? by what kind of API the linux offers?
2,Bayer formate is what I get by ioctl :VIDIOC_G_FMT,if I tried to set the formate by VIDIOC_S_FMT :YUV(442).It failed-:(

Current TX1 support two pipeline to get data from sensor. One is based on gstreamer framework to implement nvcamerasrc, this pipeline go to ISP and the source code are not public. Another it the V4L2 framework’s v4l2src this pipeline only can get the raw data from the sensor. That means If your senosr is bayer you only can get bayer data, otherwise you need a YUV sensor instead of bayer sensor(TX1 default sensor d0v5693 is bayer sensor ).