2007年6月11日星期一

libv4l2

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.

Snapshots:

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
cd libv4l2
aclocal
automake
autoconf
./configure –prefix=/tmp/usr # for testing
make
make install

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.

/tmp/usr/bin/v4l2-demo
/tmp/usr/bin/facedetect

The library is still under development. The API may change for new version. Therefore, only static link libraries are provided.

API Doc:

http://benlau.e-fever.org/projects/docs/libv4l2/index.html
http://benlau.e-fever.org/projects/docs/libcv-v4l2/index.html

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


沒有留言:

Creative Commons License
本網誌Ben Lau製作,以共享創意署名-非商業性-相同方式共享 3.0 香港 授權條款釋出。