Matrix Multiplication Values Not Correct [closed]

asked 2016-08-08 10:14:08 -0600

MRDaniel gravatar image

updated 2016-08-08 16:35:20 -0600

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?

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by MRDaniel
close date 2016-08-08 16:37:33.344641

Comments

sad, that it is no more maintained since 3 years (so be careful ..)

berak gravatar imageberak ( 2016-08-08 10:30:44 -0600 )edit
1
MRDaniel gravatar imageMRDaniel ( 2016-08-08 10:41:19 -0600 )edit

You are comparing different numbers. You have -0.49347955 in your C++ rotation matrix and -0.493413 in the online checker, so yeah, different results. And -0.015945198 vs -0.15945198

LorenaGdL gravatar imageLorenaGdL ( 2016-08-08 10:52:11 -0600 )edit

Bonus: please, dust off you old calculator instead of using an online Matrix Multiplication tool to make such an easy check. It will feel awesome ;)

LorenaGdL gravatar imageLorenaGdL ( 2016-08-08 10:59:23 -0600 )edit

@LorenaGdL I've updated the numbers and i am still confused,. Any clues?

MRDaniel gravatar imageMRDaniel ( 2016-08-08 16:30:55 -0600 )edit

Now you have changed sign of the numbers. In your C++matrix, 0-row,1-column is -0.015945198 while in the online tool is 0.015945198. Same with element 1-row, 0-column. Relax, and take your time to review everything. Methodologically everything is fine.

LorenaGdL gravatar imageLorenaGdL ( 2016-08-09 02:03:43 -0600 )edit