# How to calculate vehicle detection distance?

I would like to know how to calculate the distance to each car when I run my application for an autonomous vehicle in real-time. In addition, I want to know how to implement the calculation in C++.

You can see in the images we can know the distance for each vehicle but I don't know what code I should use to make all these calculations for every vehicle.

Please check the photo to understand more about what I'm trying to achieve.

• I'm not sure what you need help with. You say towards the middle of the question, You can see in the images we can know the distance for each vehicle, but in the beginning you ask, I would like to know how to calculate the distance to each car. Do you know the distances to each car or not? – Chuck Sep 2 '15 at 13:15
• we are building a software for the autonomous vehicle and this software was writing by other company, and i want to know how did they made the calculation for the distance as you could see in the images. – assam alzookery Sep 2 '15 at 14:46
• Well they're doing the measurements wrong, so I wouldn't try to use them or recreate them. For instance, in the top picture, "Pedestrian", which looks like a light pole, is at minus 0.41, while the white car beside it is at 0.26 and the red car closer to the camera is at -0.3. Similarly, in the second image, the middle car is at a negative value while the cars closer and further away are both at positive values. – Chuck Sep 2 '15 at 18:26
• Are you sure the numbers above each detection are distances? They could also be some confidence metric. – Ben Sep 4 '15 at 15:32