libv4l2 is a user space library to access V4L2 compatible video device. Current features (v0.1) include:
- V4L2 API (only)
- Query and set video device properties that include:
- Resolution, Image Format, Channel, Norm, fps...
- Read/Write and Memory mapped streaming I/O
- YUYV/YUV420 to RGB conversion. (No MJPEG yet)
- A simple GTK+ dialog to choose the video device to open and set the properties.
- Utility to convert video frame to IplImage format for use with OpenCV.
Dialog to query the V4L2 device available and choose the one to open.
Adjust device properties
Sample program - facedetect from OpenCV
The source comes with two libraries. They are libv4l2 and libcv-v4l2. libv4l2 is the core library to deal with v4l2 device. libcv-v4l2 is “supposed” to be an extension to OpenCV for access low level device setting, but only few functions are implemented and the design is not well. It will be completely rewritten afterward. All features that should not be provided by libv4l2 will be there (e.g. GTK+ Dialog)
libv4l2 itself is a very simple library that just requires standard library like libc6-dev in order to build, but libcv-v4l2 need packages of gtk+-2.0 and OpenCV.
The package of OpenCV has been available in Debian Etch/SID, they could be installed by:
apt-get install libcv-dev libcvaux-dev libhighgui-dev
The build instructions:
bzr branch http://benlau.e-fever.org/projects/bzr/libv4l2 libv4l2
./configure –prefix=/tmp/usr # for testing
There are two demo applications available. The first one is a video viewer with two dialogs to choose the input video device and set the properties respectively. The other one is a face detection program from the sample code of OpenCV project.
The library is still under development. The API may change for new version. Therefore, only static link libraries are provided.
Tested Camera :
KWorld DVD Marker [em28xx]
Logitech Quickcam Pro 4000 [PWC] - The PWC do not support to adjust FPS by standard V4L2 API
Logitech Quickcam Pro for Notebooks[UVC] - The driver supports MJPEG and YUYV for output. If chosen YUYV, only 1024×576 is provided.
Pinnacle DVC 90 [em28xx] - mmap fails in streaming I/O
Please feel free to contact me for any comment of the source