# Society of Robots - Robot Forum

## Software => Software => Topic started by: RoenZ on July 31, 2007, 08:30:53 AM

Title: Get the depth and disparity map
Post by: RoenZ on July 31, 2007, 08:30:53 AM
Hi all.... i want to ask about the depth and disparity map.....
How i can get the depth and disparity map in stereo vision??
I'm using 2 Logitech Quickcam Pro 4000 in my stereo vision project.....

Z(depth) = f (focal length) * b (baseline) / disparity ---> i get from stereo triangulation equation

How it can be like that??? As u can see above, the unit of Z (depth) is in cm or mm right??  but if i calculated it the Z was not in cm nor mm......  it was in mm^2/pixel...... example :
focal length = 4 mm
baseline      = 100 mm
disparity      = 87 pixel
so the Z will be = 4.597 mm^2/pixel ?????
Title: Re: Get the depth and disparity map
Post by: Admin on July 31, 2007, 11:36:51 AM
So this is how I did it:
http://www.societyofrobots.com/programming_computer_vision_tutorial_pt3.shtml#stereo_vision

Z_actual = (b * focal_length) / (x_camL - x_camR)
Title: Re: Get the depth and disparity map
Post by: RoenZ on August 01, 2007, 07:24:03 AM
As for the X/Y locations . . . get out a yard stick and measure where the object is, and compare that to the X/Y pixel position that the camera says.

So you might get 5 inches with a camera reading of 2 pixels. So thats 5/2. I usually just fudge this cause I never need it to be accurate.

So if one day your camera says the object is at 8 pixels, then:
5"/2 pixels * 8 pixels = real location of the object in inches.

based on ur reply on the thread "get the object position..." above.....
i need another constanta right, i mean to change the pixel value to cm???
and what about xcamL and xcamR? is it true that the xcamL and xcamR unit in cm??? If true then how to convert it???I'm confused about that???
Thx
Title: Re: Get the depth and disparity map
Post by: Admin on August 01, 2007, 01:05:37 PM
Quote
i need another constanta right, i mean to change the pixel value to cm???
What you need is a transform. Basically an equation that says A pixels = B inches.

The method I mentioned in this post (http://www.societyofrobots.com/robotforum/index.php?topic=1679.0) is the simplest method. Unless you need high precision, its good enough.

Quote
and what about xcamL and xcamR? is it true that the xcamL and xcamR unit in cm??? If true then how to convert it???I'm confused about that???
It can be in whatever units you want. Just keep them consistent.
Title: Re: Get the depth and disparity map
Post by: RoenZ on August 22, 2007, 02:38:15 AM
Disparity map is the map that show the disparity between the left and right image right??? and depth map show the depth so is the disparity map and depth map have a connection??? or this 2 things are different???

Thx
Title: Re: Get the depth and disparity map
Post by: Admin on August 22, 2007, 09:06:51 AM
Yea there is a relation, but they are different. The difference between both images are a function of depth of the objects in view (as well as other things).

The disparity (difference between images) is what the robot senses, and the depth map is the solution.
Title: Re: Get the depth and disparity map
Post by: RoenZ on November 05, 2007, 11:38:26 AM
Thx for the definition....and now i knew it..... ;D
oh btw i have some problem again.... :o

Is it true the focal length value is constant??? because i calibrated my camera once again and i have a different value of focal length...... ???

I set up the Z= 160 cm so  got the disp = 56 pixel and by the stereo vision formula i got f=896 pixel, so after that i make a calculation with f=896 pixel and i got the value of Z from disp=1 to 255

But when the robot move in Z=80 cm (real condition) the disp was in 84 pixel and the focal length was changed too.... --> f=672 pixel......based on my calculation if Z=80 cm the disp must be 89 pixel (with f=896 pixel) why it can be like that???  ???

Pls tell me if i'm wrong...... ;)
thx