Ask Your Question

[Solved] How to force opencv 3.0 to read BA81 image using libv4l2 ?

asked 2016-10-08 06:26:12 -0500

gfx gravatar image

updated 2016-10-10 06:52:08 -0500

image description(/upfiles/14759252821837422.png)

image description

v4l2-ctl --list-formats
Index       : 0
Type        : Video Capture
Pixel Format: 'BA81'
Name        : 8-bit Bayer BGBG/GRGR

Index       : 1
Type        : Video Capture
Pixel Format: 'GREY'
Name        : 8-bit Greyscale

Index       : 2
Type        : Video Capture
Pixel Format: 'Y16 '
Name        : 16-bit Greyscale

My system is ubuntu 14.04, kernel 4.4.0-41-lowlatency. Because I read the new use of v4l2 lib in opencv 3.0 instead of v4l I update my old project from opencv 2.4.9 to opencv 3.0.0 (I test 3.1 too)... but if use v4l2 utils or fswebcam it is all ok my (bad camera only gain and abs_esposure is possible to change ... and grab in bayern format ...) grab perfect ... if use hello world opencv program (/opencv-3.0.0/samples/cpp/example_cmake) I have the same old issue that into 4.9 ... i solve it using some c function insert into my cpp code to manage and tranform the wrong image (demosaic bayer code...).

I think with opencv3.0 is really possible not use that piece of code and force v4l2 to make it work .... but in what file of videocapture is possible to make tha magic trik??

Regards Giorgio

edit retag flag offensive close merge delete


Obviusly i have tra to set CV_XXXX_FOURCC .... But The responso is : parametri not supported

gfx gravatar imagegfx ( 2016-10-08 08:07:18 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-10-10 06:51:36 -0500

gfx gravatar image

updated 2016-10-18 03:46:55 -0500

Ok Ok ... I see cap_v4l.cpp and cap_libv4l.cpp inside modules/videoio foldef of opencv3.0 installation folder.... In cap_v4l.cpp there is already a support for sony camera with BA81 grab format .... so I unistall opencv3.0 clean build folder and all folder and file redirect from pkconfig and re-compile with these option...


in these way I cai grab BRG image from my camera in BA81 mode without use a c function for demosaicing, start, stop, init, buffer usage, and clear device .... only with VideoCapture call....obviusly cvtcolor function convert BRG to RGB image ...

So I add in those file other camera V4L2_CID control.... and re-compile...

(a good result...) image description

Regards Giorgio

edit flag offensive delete link more


the modified file....MODIFIED cap_v4l.cpp

gfx gravatar imagegfx ( 2016-10-18 03:48:21 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-10-08 06:26:12 -0500

Seen: 561 times

Last updated: Oct 18 '16