Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opencv depth map accuracy

I want to measure distance to an object using a 3d stereoscopic camera phone with opencv. I am looking for a formula which will measure the accuracy of the distance measurement, depending on the focal length, the distance between the 2 cameras, the image resolution, and the size of the measured object. Googling a little, I found this formula:

d = Z^2 * p / (f*b)

Z - distance to object, p - disparity accuracy, f - focal length, b - baseline (distance between cameras).

I know the baseline and the focal length, but I don't know the disparity accuracy. Is this formula what I need? If so, how do I find the disparity accuracy?

Thanks.

like image 620
barisdad Avatar asked Aug 17 '11 08:08

barisdad


2 Answers

I realize this is a year late, but just in case someone finds this.

The formula is this:

dD = dd * D^2 / fB

where:

  • dd = disparity error
  • dD = depth error
  • D = depth
  • f = focal length
  • B = baseline

if f = 6mm = 0.006m, B = 24mm = 0.024m, D = 10m, dd is 1 pixel [let's call it P for now, but it's usually about 1.4um].

Plugging all the numbers in gives:

dD = P * 10^2 / (0.006 * 0.024) ~ 694444 P

For P=1.4um, dD = 0.97 m (which is about 9.7%).

Now this is assuming that your correspondence gives single pixel error. You can do sub pixel search and depending on the noise level and texture in the image, you can get sub pixel accurate correspondence. In which case, your accuracy would be a little better.

NOTE that this formula is for error. The map between disparity and depth is as follows:

d = fB / D

where:

  • d = disparity
  • D = depth
  • f = focal length
  • B = baseline

Similarly, plugging the numbers in gives:

d = (0.006 * 0.024 / 10) m = 0.0000144 m = 0.0144 mm = 14.4 um.

if you assume that your pixel size is about 1.4um, then 14.4um is about 10 pixels. This is consistent with the error above -- meaning that a 1 pixel error represents roughly 10%.

A car that is 10 meters away is shifted 10 pixels between the left and right sensors.

I hope that helps.

like image 169
thang Avatar answered Oct 23 '22 00:10

thang


If you look at the paragraph after formula 8 in the document you link you can see that they have a disparity accuracy 0.18*10^-6m. Reading a bit further, I conclude that the disparity accuracy they use is the distance in m between two pixels on the CCD of the cameras used. For a 1/4" CCD (which measures 3.2mm by 2.4mm) with resolution 640X480 (a very old VGA camera) this would be 5*10^-6. I don't know what the sensor size for the LG Optimus 3D is, but assuming 1/4" CCD's and 2592 pixel horizontal resolution, the baseline for the disparity accuracy would be: 1.23*10^-6, giving a depth accuracy at 10m of about 0.85m. Which looks reasonable to me. If the CCD is smaller it will improve (i.e. the accuracy value lowers).

This is the lowest possible value that assumes perfect matching of features between the two stereo images. This value just represents the physical limitations of your stereo pair.

like image 5
jilles de wit Avatar answered Oct 22 '22 23:10

jilles de wit