noahzn / Lite-Mono

[CVPR2023] Lite-Mono: A Lightweight CNN and Transformer Architecture for Self-Supervised Monocular Depth Estimation
MIT License
540 stars 61 forks source link

absolute distance #84

Closed garusuke closed 12 months ago

garusuke commented 12 months ago

I would like to know the absolute distance [m] from the output result. To do this, can I get it by doing pred_depth *= opt.pred_depth_scale_factor for the depth in the output of the disp_to_depth function? If this is ok, please tell me how to set the appropriate opt.pred_depth_scale_factor, and if not, how else?

noahzn commented 12 months ago

Hi, the method predicts relative depth values, not absolute distances. In the evaluation the code uses median filtering to scale the predicted depth values. I remember the authors of Monodepth2 said that this worked fine with KITTI. However, you can not use the monocular method to get accurate absolute distance. You can use stereo data for training to get absolute depth.

garusuke commented 12 months ago

Thanks for the reply. How do you code the median scaling? Could you please tell me the different parts of this code? The constant for depth_scale_factor is just assigned a value of 100/2.

MIN_DEPTH = 0.01
MAX_DEPTH = 100
min_disp = 1 / 100
max_disp = 1 / 0.01
scaled_disp = min_disp + (max_disp - min_disp) * disp
depth = 1 / scaled_disp
depth_scale_factor = 50
depth *= depth_scale_factor
depth[depth < MIN_DEPTH] = MIN_DEPTH 
depth[depth > MAX_DEPTH] = MAX_DEPTH
noahzn commented 12 months ago

The median scaling code is here. In the default code opt.pred_depth_scale_factor is set to 1, so we didn't use this scale factor.

garusuke commented 12 months ago

Are you saying that it is not possible to do median scaling an image for which the gt_depth is not known?

noahzn commented 12 months ago

Yes, you need to know the ground-truth. This is for the evaluation of predicted depth.

garusuke commented 12 months ago

I understand. Thank you very much. If we train in absolute distance, can we get depth in meters?

noahzn commented 12 months ago

Yes, you can get metric depth if you use supervised monocular training or stereo training.

garusuke commented 12 months ago

I understand. Thanks for everything.