Ask Your Question
1

How to obtain depth map from stereo camera ?

asked 2015-04-05 20:04:04 -0500

lilouch gravatar image

updated 2015-04-06 23:18:48 -0500

Hello,

I would like to try a visual odometry algorithm with the KITTI dataset. However the KITTI dataset, in my case, has only sequences of pictures with the left and right camera. I don't have any cloud or depth information in the dataset. (Actually yes there is also velodyne data but i'm not interested in laser for now)

Therefore, I presume that from the left and right camera, I have to obtain the depth map (correct me if I'm mistaken) ? How i can do that in ROS ? I saw that there is a node called stereo_image_proc node who can deal with stereo but I only can obtain a disparity MAP and I didn't find any topic that publishes this depth map.

EDIT: I can have the disparity image or/and the pointCloud2

Can someone help me ?

Thank you

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-04-14 20:58:02 -0500

lilouch gravatar image

updated 2015-04-15 00:31:16 -0500

I finally was able to obtain the depth map from the disparity picture thank to the disparity_image_proc nodelet. It used an OpenCV function to project disparity into 3D space.

The main issue was the the fact that image_view and stereo_image_view nodes didn't work in my ROS indigo ( https://github.com/ros-perception/ima... ) and therefore I wasn't able to obtain a good depth map because i couldn't adjust the parameters properly in real time because I couldn't see the results directly.

Finally, I installed ROS Hydro and I could change the parameters directly with image_view. And now It works !

EDIT: by the way can you explain me how to run the script you provided ? I'm not able to make it work despite i followed the python tutorial.

edit flag offensive delete link more

Comments

How did you change the parameters in real time?. thanks

Sai Anirudh Kondaveeti gravatar image Sai Anirudh Kondaveeti  ( 2015-05-21 13:33:06 -0500 )edit
1
lilouch gravatar image lilouch  ( 2015-05-22 00:50:24 -0500 )edit
1

answered 2015-04-14 08:58:49 -0500

Miquel Massot gravatar image

Hi lilouch,

there are some steps you have to do before obtaining the depth image or the pointcloud (what do you prefer?)

  1. Publish the images as ROS topics: Write a node to do that, or use one already available. For instance this one. You'll need two instances of this same node, one for the left camera and one for the right.
  2. Run stereo_image_proc to rectify the images and calculate their disparity. This node calculates also the pointcloud. From the pointcloud you've already got the depth, but in case you need a depth image, read below:

As you may already know, depth can be calculated from disparity using Z = fB/d, where f is the focal lenght (px), B is the baseline (m) and d is the disparity (px). Z is depth in m. Both f and B are fixed terms, so your entire disparity image inverted (termwise), multiplied by a constant is your depth image.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-04-05 20:04:04 -0500

Seen: 3,424 times

Last updated: Apr 15 '15