leggedrobotics / darknet_ros

YOLO ROS: Real-Time Object Detection for ROS
BSD 3-Clause "New" or "Revised" License
2.23k stars 1.18k forks source link

How can I estimate distance from object to my camera based on YOLO? (I have both stereo and 2D camera) #258

Open thejeshk opened 4 years ago

thejeshk commented 4 years ago

Hi,

I am using darknet_ros for custom object detection and I have one class called "traffic_cone"

Now, I am able to detect objects but I need to get the distance from the object detected. Is there anyway to do it?

I have gone through this thread but no success!! https://github.com/leggedrobotics/darknet_ros/issues/103

Could anyone help me how to achieve this?

Thank you :) TK

renowator commented 4 years ago

Hey, I guess there are some techniques to get distance with stereo camera, for using 2D camera you can do this: https://www.youtube.com/watch?v=h8WoErQle2U

Alex-Beh commented 4 years ago

@thejeshk I use #103 as reference and write a package to retrieve the real distance. You can find the related codes in the following link: link

I retrieve the camera_info once in link

Blackcipher101 commented 4 years ago

You can try OpenCV depth function