Stereo Vision Experiment

By xantus on Thursday 21 January 2010 16:50 - Comments (6)
Category: C++, Views: 6.698

ResultAfter reading an interesting paper about stereo vision, I wondered if it would be possible to use the proposed methods for calculating depth maps with the use of 2 low cost webcams.

Setup

For 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):

SetupSetup

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.
C++ program
C++ program form
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 Algorithm
The 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 Algorithm
The object detection algorithm works by dividing the disparity map in a 1616 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.
Object

Results

With 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:

Conclusion

It 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.

Downloads

You 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++).
http://www.greenbird.info/img.php?h&b=stereo-vision-experiment&f

Volgende: IBM font 01-'10 IBM font
Volgende: GAnalytics dokuwiki plugin 01-'10 GAnalytics dokuwiki plugin

Comments


By Tweakers user LeonM, Thursday 21 January 2010 19:24

Wow, that's not bad for just 2 simple webcams!

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.

By Tweakers user n0elite, Thursday 21 January 2010 20:22

Dude change the font of your blog. It hurts my eyes.

By Tweakers user Faust, Thursday 21 January 2010 21:57

I have a webcam with better much the quality of the image. this webcams of you has image quality of ms-dos

By Tweakers user YopY, Friday 22 January 2010 09:17

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 :+. It had better image quality and the two cameras were mounted in a fixed (metal) housing, so it'd have better results probably than this one. However, this one's a lot cheaper. How much time did you invest in writing the software?

By Tweakers user xantus, Monday 25 January 2010 15:50

Why does the program have 2 windows per webcam? They both seem to show the same picture.
Left windows shows webcam input, right window shows the filter output (some blur to remove noise, normalization of the image, etc)
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 are a bit out of focus, but most of the blur is caused by a filter to remove salt & peper noise.
I have a webcam with better much the quality of the image. this webcams of you has image quality of ms-dos
They have a resolution of 320x240, which is sufficient for this experiment. And they where only 5 each, which is a big plus :)
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 :+.
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.
How much time did you invest in writing the software?
2 days.

By chris, Monday 3 May 2010 03:52

I can't download the source code.
Anybody can help me?

Comments are closed