Using Philips webcam features with OpenCV and pwc
Introduction
Doing computer vision involves the use of a suitable and (in most cases) affordable
camera. Therefore often web cameras are taken into considerations. In spite of not being payed
by Philips I can say that the Philips SPC 900 NC delivers great results (it comes with a
VGA CCD sensor and high-quality optics!) at low cost (50 $). Using the OpenCV library
for grabbing images from webcams is really easy and cool. Unfortunately OpenCV doesn't support
the extended Philips webcam features like shutter speed settings and automatic gain control.
These features are interesting because allowing the camera hardware to adjust shutter speed and agc automatically works well for video conferences. But these lighting variations are undesired effects when doing tracking or color segmentation for example. Thus we are interested in keep these values fixed and this is exactly what is described here. This tutorial shows how to combine OpenCV with the pwc (Philips Webcam Driver) in order to gain full feature availability. It includes several samples and a small class which extends the OpenCV library with simple graphical button support. The tutorial is based on OpenCV 1.0, ffmpeg for writing video streams and the pwc driver under Ubuntu FeistyFawn Linux.
Screenshots & Videos
Here is a screenshot of grabber_demo which is part of the project. It allows for adjusting the framerate, gain, shutter speed and white balance. Additionally snapshots can be taken and with ffmpeg installed correctly also videos can be made by clicking on the button to toggle video capturing on and off. Note that the file names are fixed. Thus each time a snapshot or a video is taken the old snapshot or video will be overwritten.
You will be interested in some pictures and videos made with the Philips SPC 900 NC. So here they are! The following video has been taken at 30 fps with a resolution of 320x240. Lowlevel processing was done by the canny edge detector which comes with OpenCV.
The following pictures are taken with VGA resolution (640x480) while videos are either taken with VGA resolution at 15 fps or with a 320x240 resolution at 30 fps. This is the maximum I could achive under Linux :). All videos and pictures were captured using the sample programs provided below.
Downloads
The webcam sample code below includes an OpenCV wrapper for the pwc driver which extracts the device handle from a pointer to a CvCapture device and provides easy to use functions to modify shutter speed, automatic gain control, white balance, compression ratio, hardware sharpening and much more. In order to compile these samples you will have to install at least OpenCV 1.0 (for higher versions the code has perhaps to be modified... let me know). To save video streams you also have to download and install ffmpeg with the right parameters BEFORE installing OpenCV. This is a bit tricky, so if you're unsure you may want to look at the following step-by-step tutorial:
Here you find a howto on compiling and installing ffmpeg and OpenCV correctly!
Now you are ready to compile and run the demo files. Here you can download the project and documentation:
- Source Code, Version 1.0 (webcam.tar.gz)
- Online documentation (includes installation instructions)
- Offline documentation (webcam_manual.pdf)
If you are using a laptop, please try to avoid an USB-hub between camera and laptop. I encountered problems when doing this with full framerate. Instead plug in your camera directly to your computer's USB slot. Another issue is that you shouldn't close a demo program by clicking on the cross in the upper right corner (title) of the window. Instead use the ESC key or close it by clicking on the Exit button in the image window. Otherwise you will have to kill the process manually :). If you have problems compiling or running the demo files, let me know! If you find this project useful, please put a link to this page on your site.







