ucbdrive / hd3

Code for Hierarchical Discrete Distribution Decomposition for Match Density Estimation (CVPR 2019)
BSD 3-Clause "New" or "Revised" License
204 stars 31 forks source link

Convert output disparity maps to depth #35

Closed connorlee77 closed 3 years ago

connorlee77 commented 3 years ago

I was wondering if you knew the correct parameters to convert the disparity map to depth. I was using the formula:

D = baselinefocal / (disparity img_size)

and I was using the parameters:

D = 0.54 721 / (disparity 1242)

The outputs are on the order of 0.00 - 0.1, which doesn't make sense. Any idea what I'm missing here?

yzcjtr commented 3 years ago

Hi, the formula should be depth = baseline_length focal_length / disparity. If the baseline length is 0.54m and the focal length is 721 pixels, depth should be 0.54 721 / disparity. (Note the units of baseline, focal length, and disparity are meter, pixel, and pixel).

connorlee77 commented 3 years ago

@yzcjtr thanks for the reply! I actually run into outputs on the order of 0.00-0.1 with 0.54 * 721 / disparity. Dividing by1242 makes it even smaller.

Multiplying by a factor of 100 seems to make sense, i.e. 100 0.54 721/disparity. Any idea why this is the case?

yzcjtr commented 3 years ago

If the baseline and focal length are correct, the output range does indicate all the depth values are within 10cm. Multiplying with 100 doesn't sound good to me. Maybe you can visualize the point cloud to see if the depth makes sense.

Baboom-l commented 3 years ago

There are some problems in the formula D = baselinefocal / (disparity img_size) Actually, it should be D = baseline*focal / (disparity)

connorlee77 commented 3 years ago

Regardless of formula correctness, the output values don't make physical sense. I had to multiply in a constant to make it align with the point cloud depths.

yzcjtr commented 3 years ago

I'm afraid you are getting incorrect disparity values. Some of your test configs might be wrong. If your depth values are less than 0.1m, all the disparities should be greater than ~3893 pixels, which doesn't make sense. You can verify if your disparity prediction is correct by checking the EPE metric.