Core.gemm for MatrixMulitplication

asked 2014-05-07 04:43:49 -0600

glethien gravatar image

I want to do a Matrix multiplication with OpenCV on Java.

As Core.muliply is not a "right" matrix multiplication

multiply(Mat src1, Mat src2, Mat dst, double scale)

Calculates the per-element scaled product of two arrays.

I am confused about how to perform a "normal" matrix multiplication. Core.gemm seems to solve the problem.

gemm(Mat src1, Mat src2, double alpha, Mat src3, double gamma, Matdst)

Performs generalized matrix multiplication.

Gemm uses this formula for the multiplication

dst = alphasrc1.t()src2 + beta*src3.t();

Now I want to get the essential matrix from the fundamental matrix I've calculated before using this piece of Code

Mat fundamental = Calib3d.findFundamentalMat(object_left, object_right, Calib3d.RANSAC, 3, 0.99); Core.gemm(cameraMatrix.t(), fundamental, 1, cameraMatrix, 0, E, Core.GEMM_1_T);

Core.gemm(E, cameraMatrix , 1, E, 0, E, Core.GEMM_1_T);

The flag Core.GEMM_1_T means to transpose src1

Therefore I calculate cameraMatrix^T * fundamental and save this ( lets call this E') Next step is that I calculate E' * cameraMatrix.

edit retag flag offensive close merge delete