Stereo Vision Experiment
SetupFor the experiment I used 2 Sitecom VP-004 cameras' and an old PC (celeron D430). These camera's where placed 9cm apart and 1 meter form the objects (direction of red arrow):
The blue arrows indicate the direction of natural light sources (3 windows). The wall shown in the movies below was 4 meters behind the objects.
The C++ program uses the videolab video components for Borland C++ builder to capture and process the data from the webcams. It also contains some settings to change parameters for maximum disparity, window size, minimum object size, error function, etc, etc.
Disparity AlgorithmThe program uses the disparity algorithm as described by Luigi Di Stefanoa, Massimiliano Marchionni and Stefano Mattoccia in their paper: A fast area-based stereo matching algorithm. All credits should go to them, as I only translated their proposal to an actual C++ implementation.
Object detection AlgorithmThe object detection algorithm works by dividing the disparity map in a 16×16 matrix and calculating the average disparity in every sub-area. After which a recursive function searches for adjacent areas with an average disparity larger than the threshold. There area's, which indicate a possible object, are outlined.
ResultsWith some optimization the program is able to calculate 10 frames per second on the test PC.
Video showing 'real-time' calculation of the disparity map.
The following video is made with the same program. Only this time the source code was rewritten to better utilize the compiler optimization routines. This speeded up the program from its initial 0.2 FPS to 6 FPS:
ConclusionIt is possible to use the proposed methods to calculate depth maps, using only 2 low cost webcams. The resolution of the resulting map is very reasonable, around ~1cm. The only real difficulty is to get the camera's aligned.
DownloadsYou can download the source code for this experiment here: stereo_vision.zip (3.2 MB)
Note: You also need to install the videolab components for Borland C++ Builder (also available for Microsoft Visual C++).
Why does the program have 2 windows per webcam? They both seem to show the same picture.
It looks like the camera's are not properly focused, I've experimented with cheap webcams in the past, and discovered the image quality is actually not that bad when they are properly focused (try turning the lens). Daylight also helps a lot for those cheap CMOS sensors. You might get better results when you tweak the focus and light source a bit.
Left windows shows webcam input, right window shows the filter output (some blur to remove noise, normalization of the image, etc)Why does the program have 2 windows per webcam? They both seem to show the same picture.
They are a bit out of focus, but most of the blur is caused by a filter to remove salt & peper noise.It looks like the camera's are not properly focused, I've experimented with cheap webcams in the past, and discovered the image quality is actually not that bad when they are properly focused (try turning the lens). Daylight also helps a lot for those cheap CMOS sensors. You might get better results when you tweak the focus and light source a bit.
They have a resolution of 320x240, which is sufficient for this experiment. And they where only ¤5 each, which is a big plusI have a webcam with better much the quality of the image. this webcams of you has image quality of ms-dos
I've been to Bosch security systems, where they have similar systems. And while their image quality is much better, the price is around 1000x as high.I've seen professional stereoscopic cameras (as well as professional webcam-sized cameras + changeable lenses) for computer vision purposes for which custom software was written. It wasn't cheap, that's for sure .
2 days.How much time did you invest in writing the software?
Anybody can help me?
Comments are closed