Ask Your Question
0

extract the data from a cv::Matx44d?

asked 2017-01-24 14:07:14 -0600

stillNovice gravatar image

updated 2017-01-24 14:08:25 -0600

Hi, I am new to the Matx format, and am trying to extract data into a std::vector and a cv::Mat.

I have :

cv::Matx44d resultMat;

which is a 4 x 4 transformation matrix. I wish to extract the translation part of this (the last col) into a std::vector, and the rotation part (the top left 3x3 matrix) into a new Mat object.

How can I go about this?

Thanks!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-01-24 14:16:44 -0600

LBerger gravatar image

updated 2017-01-24 14:31:49 -0600

opencv 3.2 and C++. just do it !

Matx44d xxt(11, 12,13,14,21,22,23,24,31,32,33,34,41,42,43,44);
Mat xt(xxt);
Mat xr=xt(Range(0,3),Range(0,3)).clone();//Mat xr=xt(Rect(0,0,3,3)).clone(); 
vector<double> lastCol;
lastCol = xt.colRange(Range(3, 4));
for (int ii=0;ii<4;ii++)
    cout<<lastCol[ii]<<"\t";
cout<<"\n";
cout<<xr;

results :

xt = [11, 12, 13, 14;  
21, 22, 23, 24; 
31, 32, 33, 34;  
41, 42, 43, 44]
 14    24      34      44 
[11, 12, 13;  
21, 22, 23;  
31, 32, 33]
edit flag offensive delete link more

Comments

1

thanks! Much appreciated. :)

stillNovice gravatar imagestillNovice ( 2017-01-24 14:21:26 -0600 )edit
1

Actually... when i replace the Mat xt with my cv::Matx44d xt, it gives errors.Rect and colrange are not members of Matx it seems...

stillNovice gravatar imagestillNovice ( 2017-01-24 14:25:31 -0600 )edit
1

right my first try was wrong!

LBerger gravatar imageLBerger ( 2017-01-24 14:32:23 -0600 )edit
1

thanks again, works perfectly now.

stillNovice gravatar imagestillNovice ( 2017-01-24 14:38:36 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-01-24 14:07:14 -0600

Seen: 940 times

Last updated: Jan 24 '17