Ask Your Question
0

matrix inverse multiply another matrix

asked 2018-11-08 22:58:39 -0600

cy gravatar image

I asked this question on stackoverflow, but since it is concerning opencv specifically thought I try my luck here as well.


Forgive me if this sounds like an amateur question but I'm having problem understanding the code here. The author declared a rotation matrix of 3x3 and a translation vector of 1x3.

cv::Mat rvec(1,3,cv::DataType<double>::type);
cv::Mat tvec(1,3,cv::DataType<double>::type);
cv::Mat rotationMatrix(3,3,cv::DataType<double>::type);

And then later there is this operation

cv::Mat rightSideMat = rotationMatrix.inv() * tvec;

Can anyone explain to me why this works, when the shape of the matrices (3x3, 1x3) don't align? I have tried it out and it runs.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-11-09 02:01:47 -0600

berak gravatar image

updated 2018-11-09 03:18:49 -0600

code above will throw an exception, and won't work as is.

matrix multiplication is basically: _ * | , so if v = a single row, and M.rows==v.cols, it is:

v * M == (M.t() * v.t()).t()

(and the inversion does not matter at all here, since it does not change the shape of M)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-11-08 22:58:39 -0600

Seen: 3,527 times

Last updated: Nov 09 '18