Ask Your Question
1

strange stereorectify error with rotation matrix

asked 2012-10-24 08:52:15 -0600

makokal gravatar image

Hi,

I am doing stereo rectification using calibration data for a stereo pair in standard form (intrinsics as 3x3 Mat, distortions as 5x1 Mat, Rotation as 3x3 Mat and Translation as 3x1 Mat). But I keep getting the following exception

OpenCV Error: Formats of input arguments do not match (All the matrices must have 
the same   data type) in cvRodrigues2, 
file /build/buildd/opencv-2.3.1/modules/calib3d/src/calibration.cpp,  line 507 
terminate called after throwing an instance of 'cv::Exception' what():  
/build/buildd/opencv-2.3.1/modules/calib3d/src/calibration.cpp:507: error: (-205) 
All the matrices must have the same data type in function cvRodrigues2

Here is the calibration data http://pastebin.com/uGLzjYqx

I call stereorectify with the following

cv::stereoRectify(ints_left_, ints_right_, dtcs_left_, dtcs_right_, 
          cv::Size(640, 480), rotation_, translation_, 
          homography_left_, homography_right_, 
          rppm_left_, rppm_right_, qmat_);

Thanks

edit retag flag offensive close merge delete

Comments

I've stumbled with the same problem, did you reach any solutions?

ma7ashish gravatar imagema7ashish ( 2013-03-25 00:34:08 -0600 )edit

I am also getting the same error. Anyone reached the solution? Regards,

Maham Khan gravatar imageMaham Khan ( 2013-10-20 07:29:45 -0600 )edit

Hi i ran into the same problem, But in my case i was Calibrating the Stereo camera using opencv 3.0 & generated the Camera intrinsic & extrinsic parameters file & i was using opencv 2411(different Opencv version) for Stereo Rectify & it was failing. When i re calibrate the camera using same opencv version the issue got fixed! Hope this Hint will help someone!:)

Balaji R gravatar imageBalaji R ( 2015-09-03 06:46:30 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2013-10-22 10:43:23 -0600

vidstige gravatar image

I ran in to the same problem. Opening up the source code revealed the problem - The cv::stereoRectify function assumes most of the input matrices are in double precision format (CV_64F). Converting the rotation matrix (rotation_ in your example) to a double precision cv::Mat solves the problem.

cv::Mat r;
rotation_.convertTo(r, CV_64F);
cv::stereoRectify(ints_left_, ints_right_, dtcs_left_, dtcs_right_, 
          cv::Size(640, 480), r, translation_, 
          homography_left_, homography_right_, 
          rppm_left_, rppm_right_, qmat_);

Hope this clarifies things.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-10-24 08:52:15 -0600

Seen: 4,855 times

Last updated: Oct 22 '13