c++ opencv matrix inverse multiply another matrix

3019 views c++
-2

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.

answered question

1 Answer

13

OpenCV's format is (x,y), where x is basically your everyday x-axis and y points downwards. It looks like this:

Hence a OpenCV matrix tvec(1,3,cv::DataType<double>::type) 'goes three rows down' if that makes sense. It is basically a 3x1 matrix. The operation cv::Mat rightSideMat = rotationMatrix.inv() * tvec; the makes sense. OpenCV's coordinates can be a little confusing in the beginning (e.g. the origin is the top left corner of the picture).

posted this

Have an answer?

JD

Please login first before posting an answer.