# A deep learning approach that can calculate distance to obstacles

After reading about the most famous object detection CNN based methods: YOLO, YOLO 9000, r-cnn, faster r-cnn, etc., I was wondering if there is an architecture that can calculate the distance to the obstacle after detection?

Thank you.

Actually, I don't think this is a problem that could be solved just from the image because it could be a small object that is really close or and big object really far. As far as I know, self driving cars use sensors for this. From what I found here, you would need the actual height of the object to calculate it from one image.

I strongly suspect you could also calculate the distance by having two images and then using the distance between the two cameras, and the Pythagorean theorem to calculate it. But that's just conjecture.

• CNNs can distinguish objects from each other, how is that different from learning that distances could change depending on what kind of object it is? You can estimate the distance based on what type of objects they are, right? Feb 14 '18 at 16:13
• I am using this for Self Driving Cars what do you think I should do for this case ? Feb 14 '18 at 20:27
• @hbdz that's easier, you can use car's average height, it doesn't differ that much except in the case of special vehicles or trucks. But you can use the height of a regular car as a baseline and then extrapolate from there. Then you follow the first link I gave you about calculating the distance knowing the height, should be a good approximation. Feb 14 '18 at 20:32
• Using two cameras and the pythagorean theorem is called stereo vision, and is a common way of estimating distances. It is very similar to binocular vision in animals.
– craq
Aug 19 '19 at 2:19

As far as I am aware there are no direct architectures that solve this at this moment in time, but I don't think this is a big issue for CNNs in general. For your training set you could choose to either train directly to estimate a distance if it's always the same object or if there are multiple objects and you want to detect them you can add the distance to the loss function. You need to tune the weighting between these two different objectives however and it might not be obvious how to do this if you don't know how these object detectors work.