Ask Your Question
0

Distorted images after camera calibration+stereo_image_proc [closed]

asked 2012-08-27 03:41:46 -0500

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!

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by georgebrindeiro
close date 2012-11-05 01:06:19

Comments

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

georgebrindeiro gravatar imagegeorgebrindeiro ( 2012-08-27 03:42:32 -0500 )edit

If I remove the distortion parameters, the images are at least visible... So my guess is the problem is there.

georgebrindeiro gravatar imagegeorgebrindeiro ( 2012-08-27 04:33:06 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-11-05 01:05:44 -0500

updated 2012-11-07 01:13:39 -0500

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<double,12>& P)
{
        for(int ii = 0; ii < 3; ii++)
            for(int jj = 0; jj < 4; jj++)
                P[3*ii+jj] = left_P_[ii][jj];
}

Correct Version

inline void left_P(boost::array<double,12>& P)
{
        for(int ii = 0; ii < 3; ii++)
            for(int jj = 0; jj < 4; jj++)
                P[4*ii+jj] = left_P_[ii][jj];
}
edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-08-27 03:41:46 -0500

Seen: 768 times

Last updated: Nov 07 '12