Project Idea- Object detection and distance estimation

Hey guys, I have a Jetbot with a calibrated camera. And I want to detect and estimate the distance of the cube as seen in the image. I am aware that TensorFlow 2 Detection Model Zoo provides a virality of models that can be used with transfer learning to detect objects, but I am not sure how to estimate the distance of each object. What do you suggest ?

Hi there,

In theory you could detect objects first and then find the distance in pixel units between the object detection centers and then multiply this by a factor that you have initially found that corresponds to the distance per each pixel in your images, if they are all the same or different factors if images are different.

You could also train a model to detect distance direclty too but it might take a lot of images and resources to train it.

Hi @gent.spah ,

thanks for replying. can you pls elaborate more, because I don’t know why computing the distance in pixel units between the object detection centres would help me estimate their distances. Is there maybe a name of this method or a resource that you can provide?

Also, if I want to train a model, is there a model you can suggest?

If you have two cameras, triangulation is what measurement technology offers and what we used when I studied Mechatronics couple of years ago for this kind of task: Triangulation - Wikipedia.

But I believe you want to use one camera and probably always in that calibrated environment.

I guess what you can do is to leverage OpenCVs functionality and:

Best regards
Christian

1 Like

Hi @Christian_Simonis ,

thanks for the links. In my case the size of objects are known, so I found if I use triangle similarity I will get a good estimate of the object distance. But one problem with the cube is that the apparent width of the cube in the image doest always correspond to the width of the 2d bounding box because of the orientation of the object(as I tried to show this with black and blue straight lines). I will need to estimate the width. I made some research, and it seemed like there are 3d object detection models that can estimate a 3d bounding box, but I wonder now if there is an easier approach to tackle this problem. What do you think?

image

Ok, I see.

Probably you can also derive the angle of the object in the room by:

Probably parts of these steps are already standard functions in OpenCV or other CV libraries I could imagine.

Best regards
Christian