ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Proper Sequence for Getting Disparity Map from GPU

asked 2012-02-02 05:22:09 -0600

wpi_igvc12 gravatar image

Hello,

I'm trying to write a GPU implementation of stereo_image_proc and am having some trouble getting a proper disparity map from my GPU. What I'm wondering is if I missed a filtering step. The current program flow goes as follows.

  1. Load left and right camera calibration data from two YAMLs and store in a Mat for OpenCV to later process
  2. Run initUndistortRectifyMap from OpenCV on said data to get the map matrices for rectification
  3. Upload map matrices as well as left and right camera images to GPU
  4. Rectify the images using gpu::remap
  5. Compute disparity map using gpu::StereoBM_GPU
  6. Bring image back to computer from GPU and publish into a ROS topic

I know everything up to and including rectifying the cameras images is correct because the rectified images are the same as those returned by stereo_image_proc. Below are the left and right camera images along with the disparity that is returned from the GPU. I also can't explain why there's a black bar on the left of the disparity map.

Left, Right, and Disparity

I can provide code if needed but I didn't want to clutter up the post if it was as simple as a missing step. Thanks for any help with this matter!

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2012-02-14 06:20:27 -0600

wpi_igvc12 gravatar image

It turned out to be a combination of having the images swapped and the images not being in gray scale (MONO8).

edit flag offensive delete link more
2

answered 2012-02-02 17:36:14 -0600

ahendrix gravatar image

Judging by the perspective, it looks like your left and right images may be swapped.

edit flag offensive delete link more
0

answered 2012-02-02 09:21:40 -0600

Patrick Mihelich gravatar image

The black bar on the left of the disparity map is expected, and related to the ndisparities (called disparity_range by stereo_image_proc) parameter, which determines the size of the search range. Go through the Choosing Good Stereo Parameters tutorial if you haven't already; it discusses in detail the block matching algorithm and how to tweak it.

Do you get a good disparity map from stereo_image_proc? Did you have to change any of the parameters? I recommend exposing every parameter you can through dynamic_reconfigure; being able to change them interactively is a big help. Maybe you just need to enable Sobel pre-filtering and/or low texture filtering.

You're not doing anything obviously wrong, so please do post the code.

We experimented a while back with changing stereo_image_proc to use the GPU, see stereo_image_proc_gpu. However that code is pretty old - dating to C Turtle, and I think pre-dating the current OpenCV GPU module - so it may or may not be useful.

edit flag offensive delete link more

Comments

We looked into adapting the code from stereo_image_proc_gpu however it proved to be more work than expected and we ended up writing our own code. We'd like to eventually release this code to the ROS community however it needs to go through some major revisions before that happens. When the code gets polished and commented a little more what's the best way to get community feedback?

wpi_igvc12 gravatar image wpi_igvc12  ( 2012-02-14 06:33:12 -0600 )edit

The best way is to put your package in a public repo (you can use github, code.google.com, etc) and send a link to the ros-users list to get it indexed on our wiki. See http://www.ros.org/wiki/Get%20Involved#Create_Your_Own_.2A-ros-pkg_Repository.

Patrick Mihelich gravatar image Patrick Mihelich  ( 2012-02-14 13:44:10 -0600 )edit

My ideal outcome would actually be to have this integrated into stereo_image_proc. We could add a dynamic_reconfigure option to the disparity nodelet to allow the user to choose between the CPU and GPU versions.

Patrick Mihelich gravatar image Patrick Mihelich  ( 2012-02-14 13:48:23 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2012-02-02 05:22:09 -0600

Seen: 1,493 times

Last updated: Feb 14 '12