Measuring distance between objects in an image

Hello everyone! Openmv3 is a appreciation project .I had read the source code .I had a issue, How to Measuring distance between objects in an image with openmv3.Thanks !

Count the number of pixels between two detections…

Please describe you project, setup, etc. In detail. Like two 5 sentence paragraphs. There are a lot of ways to detect objects. Given those ways, you can then just count the number of pixels between the two detections.

Thank you kwagyeman. I had used the haarcascade way to vehicle detection in road . I need the measuring or predicting the distance between vehicle and openmv3 camera .Thank you very much!

I wouldn’t use the OpenMV Cam in any safety critical application right now…

Anyway, can you detect cars and get their bounds box well enough? Someone fixed the haar cascade importer script recently so you should be able to use any haar you’d like now.

Thank you kwagyeman ! The openmv3 be used in ADAS.The distance measuring no be very accurately! Had any method can be come true? Thank you very much!

Hi, the size of an object you see roughly corelates to the size the distance it is away from you. You have to make your own lookup table to map object size to distance.

If you use the camera matrix (intrinsic and extrinsic stuff) you should be able to make pixels to real world. I can’t help with the math though you’ll have to figure it out.

Hello all,
I need to find the distance between the OpenMV CAM M4 to the object which was placed against to it… What is the procedure to calculate the distance between the camera and the object ???

Hi, without some type of exact reference like an OpenMV Cam a camera can’t really tell you this from one perspective. It’s not a distance sensor. However, there’s a correlation between the size of an object and it’s distance from the camera. So, if you use find_blobs()… then using the blobs .pixels() count you can infer the distance of the object by using a conversion function hand you hand calculate. I.e. you measure the distance and then the number of pixels() in the image and compare the two values. Write down a large number of readings for different distances… and then you make a piece wise model function. Note that pixels() and the distance are related in an 1/r^2 fashion so it’s not going to be a linear relationship. You’ll get better distance readings the closer you are to the object.