0
$\begingroup$

Rosanswers logo

Hello everyone!

This question might not be specific to ROS, but I decided to give it a try anyway. I am using stereo_image_proc to rectify my camera's image output and produce the corresponding disparity image, but the results are bizarre.

As seen below, where the top images are the unrectified images displayed within my node (plus an unscaled disparity image obtained locally, which is of no interest to this discussion) and the bottom images are the output from stereo_image_proc, severely distorted due to some mistake I am making.

Images before and after stereo_image_proc

For camera calibration, I used the graphical tool in the camera_calibration package. I published those using the CameraInfo message, doing nothing obviously wrong.

So what could I be doing wrong? These are the hypotheses I have tested:

  • Wrong calibration parameters: Initially I was using the parameters obtained from my camera's standard calibration tool (smallv, from SVS). I thought that might be the problem, due to conflicting calibration models. After reading about both models, I was convinced they were equivalent, but decided I should try calibration from within ROS just to be sure. Turns out the parameters I got were very similar, as were the results.

  • Swapped left/right images: I don't know why I thought that could be the reason for such a problem, but a quick test ruled that out of the question. If someone has a strong argument for this hypothesis, though, I will be more thorough in my testing.

  • Swapped matrices in CameraInfo: The results are so bad I thought I might be swapping a couple parameters in the calibration results. What is the standard way to build CameraInfo messages from the raw result from camera_calibration? I simply parsed the text output and copied the values I deemed appropriate into the messages, since I have not yet implemented the set_camera_info service.

I would appreciate any help I can get, I am completely stumped!


Originally posted by georgebrindeiro on ROS Answers with karma: 1264 on 2012-08-27

Post score: 0


Original comments

Comment by georgebrindeiro on 2012-08-27:
Note: I am able to rectify the images using SVS, but I would like to be able to do that using stereo_image_proc instead

Comment by georgebrindeiro on 2012-08-27:
If I remove the distortion parameters, the images are at least visible... So my guess is the problem is there.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Just as a note: I hardcoded the calibration parameters I obtained from the ROS calibration tool and was successful. So either SVS parameters are not directly compatible (in terms of units) with OpenCV parameters, or I made some mistake in parameter passing.

EDIT: Both things were actually happening:

  • OpenCV assumes units in meters and SVS in millimeters, so I had to multiply P[3] (essentially the baseline) by 0.001

  • I made a stupid mistake in an accessor function for the projection matrix

Wrong Version

inline void left_P(boost::array& P) { for(int ii = 0; ii

Correct Version

inline void left_P(boost::array& P) { for(int ii = 0; ii

Originally posted by georgebrindeiro with karma: 1264 on 2012-11-05

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.