Ask Your Question
0

why composeRT function is showing error for column vectors?

asked 2016-07-23 02:52:41 -0600

kevgeo gravatar image

So I'm basically try to get the combination of two rotation and translation transformations.

Mat rvec1(1,3,CV_32F);
rvec1.at<double>(0,0) = 2.3;
rvec1.at<double>(0,1) = 4.5;
rvec1.at<double>(0,2) = 7.8;

Mat rvec2(1,3,CV_32F);
rvec2.at<double>(0,0) = 2.1;
rvec2.at<double>(0,1) = 4;
rvec2.at<double>(0,2) = 1.2;

Mat tvec1(1,3,CV_32F);
tvec1.at<double>(0,0) = 4;
tvec1.at<double>(0,1) = 2;
tvec1.at<double>(0,2) = 3;

Mat tvec2(1,3,CV_32F);
tvec2.at<double>(0,0) = 2;
tvec2.at<double>(0,1) = 3;
tvec2.at<double>(0,2) = 13;

Mat rvec3,tvec3;

//-> Calling composeRT function
composeRT(rvec1, tvec1, rvec2, tvec2, rvec3, tvec3);

But i'm getting this error- OpenCV Error: Assertion failed (_rvec1->rows == 3 && _rvec1->cols == 1 && CV_ARE_SIZES_EQ(_rvec1, _rvec2)) in cvComposeRT, file /home/kevmepls/opencv-2.4.9/modules/calib3d/src/calibration.cpp, line 407 terminate called after throwing an instance of 'cv::Exception' what(): /home/kevmepls/opencv-2.4.9/modules/calib3d/src/calibration.cpp:407: error: (-215) _rvec1->rows == 3 && _rvec1->cols == 1 && CV_ARE_SIZES_EQ(_rvec1, _rvec2) in function cvComposeRT

Aborted (core dumped)

If i make the inputs as row vectors, then no errors arises. So why is error coming when inputs are column vectors?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-07-23 02:55:52 -0600

berak gravatar image

updated 2016-07-23 03:04:15 -0600

if your Mat type is CV_32F, you have to access it like

rvec2.at<float>(y,x)  // not double !

also, you have to use row vecs, not column ones, e.g.

Mat rvec1(3, 1, CV_32F);
rvec1.at<float>(0,0) = 2.3;
rvec1.at<float>(1,0) = 4.5; // <-- indexing changed.
rvec1.at<float>(2,0) = 7.8; // ...
edit flag offensive delete link more

Comments

Alright and just one more doubt, is it only row vectors of size 3 as if i make it less or more than 3, I'm getting error?

kevgeo gravatar imagekevgeo ( 2016-07-23 03:06:12 -0600 )edit

yes, exactly [1x3] vecs requred here.

berak gravatar imageberak ( 2016-07-23 03:08:46 -0600 )edit

Thanks a lot berak for the swift answers

kevgeo gravatar imagekevgeo ( 2016-07-23 03:11:25 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-07-23 02:52:41 -0600

Seen: 594 times

Last updated: Jul 23 '16