Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Matrix Multiplication Values Not Correct

Matrix multiplication.....

So i am converting some Opencv code to Opencvjs and i cannot get the correct matrix multiplication result.

In C++ which appears to work.

cv::Mat translation = -rotation * S;

Print out of each matrix. (std::cout << cv::Mat() << std::endl)

-rotation = [-0.49347955, -0.015945198; 0.015945198, -0.49347955]

S = [295.79922; 245.82167]

Print out of the result.

Translation [-149.89055; -116.59139]

Then verification via an online Matrix Multiplication tool gives a different answer, as well as opencvjs using GEMM.

image description

Is the cv::Mat * (multiplication) operator the same as GEMM?

This is the opencvjs code i expected to give the same result, but the online matrix calculator gives yet another result.

cv.gemm(rotation, Sroi, -1, emptyMat, 0, translation, 0);

I am missing something obvious, i think.

Matrix Multiplication Values Not Correct

Matrix multiplication.....

So i am converting some Opencv code to Opencvjs and i cannot get the correct matrix multiplication result.

In C++ which appears to work.

cv::Mat translation = -rotation * S;

Print out of each matrix. (std::cout << cv::Mat() << std::endl)

-rotation = [-0.49347955, -0.015945198; 0.015945198, -0.49347955]

S = [295.79922; 245.82167]

Print out of the result.

Translation [-149.89055; -116.59139]

Then verification via an online Matrix Multiplication tool gives a different answer, as well as opencvjs using GEMM.

image description

Is the cv::Mat * (multiplication) operator the same as GEMM?

This is the opencvjs code i expected to give the same result, but the online matrix calculator gives yet another result.

cv.gemm(rotation, Sroi, S, -1, emptyMat, 0, translation, 0);

I am missing something obvious, i think.

click to hide/show revision 3
retagged

updated 2016-08-08 10:17:07 -0600

berak gravatar image

Matrix Multiplication Values Not Correct

Matrix multiplication.....

So i am converting some Opencv code to Opencvjs and i cannot get the correct matrix multiplication result.

In C++ which appears to work.

cv::Mat translation = -rotation * S;

Print out of each matrix. (std::cout << cv::Mat() << std::endl)

-rotation = [-0.49347955, -0.015945198; 0.015945198, -0.49347955]

S = [295.79922; 245.82167]

Print out of the result.

Translation [-149.89055; -116.59139]

Then verification via an online Matrix Multiplication tool gives a different answer, as well as opencvjs using GEMM.

image description

Is the cv::Mat * (multiplication) operator the same as GEMM?

This is the opencvjs code i expected to give the same result, but the online matrix calculator gives yet another result.

cv.gemm(rotation, S, -1, emptyMat, 0, translation, 0);

I am missing something obvious, i think.

Matrix Multiplication Values Not Correct

Matrix multiplication.....

So i am converting some Opencv code to Opencvjs and i cannot get the correct matrix multiplication result.

In C++ which appears to work.

cv::Mat translation = -rotation * S;

Print out of each matrix. (std::cout << cv::Mat() << std::endl)

-rotation = [-0.49347955, -0.015945198; 0.015945198, -0.49347955]

S = [295.79922; 245.82167]

Print out of the result.

Translation [-149.89055; -116.59139]

Then verification via an online Matrix Multiplication tool gives a different answer, as well as opencvjs using GEMM.

image description

Is the cv::Mat * (multiplication) operator the same as GEMM?

This is the opencvjs code i expected to give the same result, but the online matrix calculator gives yet another result.

cv.gemm(rotation, S, -1, emptyMat, 0, translation, 0);

I am missing something obvious, i think.

UPDATE: EDIT ADDED CORRECT VALUES.

image description

The answers is still incorrect....... can somebody please tell me what is METHODOLOGICALLY WRONG WITH WHAT I AM DOING HERE.

Matrix Multiplication Values Not Correct

Matrix multiplication.....

So i am converting some Opencv code to Opencvjs and i cannot get the correct matrix multiplication result.

In C++ which appears to work.

cv::Mat translation = -rotation * S;

Print out of each matrix. (std::cout << cv::Mat() << std::endl)

-rotation = [-0.49347955, -0.015945198; 0.015945198, -0.49347955]

S = [295.79922; 245.82167]

Print out of the result.

Translation [-149.89055; -116.59139]

Then verification via an online Matrix Multiplication tool gives a different answer, as well as opencvjs using GEMM.

image description

Is the cv::Mat * (multiplication) operator the same as GEMM?

This is the opencvjs code i expected to give the same result, but the online matrix calculator gives yet another result.

cv.gemm(rotation, S, -1, emptyMat, 0, translation, 0);

I am missing something obvious, i think.

UPDATE: EDIT ADDED CORRECT VALUES.

image description

The answers is still incorrect....... can somebody please tell me what is METHODOLOGICALLY WRONG WITH WHAT I AM DOING HERE.

image description

Am i taking crazy pills here?