After spending over a week looking for a good interface with V4L2 for webcam or video devices on Linux without having to workout the underlying details of the device IDs and pixel formats and every other parameter that needs to be set. I have created a simple library to interface with V4L2. I am sharing it as an open source to be used by anyone in any way they want. I haven’t written any documentation or manual with this code. However I have put comments on the code that I think would help where necessary. This is just a first release, and I would as and when time permits update it with modifications and bug-fixes. In order to use this program, you will need the following

1. V4L installed with the headers.
2. V4l2convert library. This is library that allows for access to other unsupported formats given by the camera. I will provide the version I am using and in the future post a link to their source code for you to use.

In this file I am attaching with this post, it includes

a. Source code with code::blocks project file.
b. It already includes, the compiled library
c. the
d. A sample main.cpp that uses this library with openCV. Note: that in this sample, I am using the BGR3 format in openCV. Other formats will not work.

Download link:

Any feedback would be much appreciate. This is my first library release on Linux, my intention is to make programming with V4L2 as simple and intuitive as possible.

I do not provide any warranty with this code, please use it at your own risk :).