Opencv Matrix multiplication

岁酱吖の 提交于 2019-12-02 04:44:32

问题


i need to multiply a matrix and its transpose but i get the following error :

"OpenCV Error: Assertion failed (type == B.type() && (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2)) in unknown function, file .. ....\src\opencv\modules\core\src\matmul.cpp, line 711"

here is the code:

int dA[] = {
     1,     2,     3,
     4,     5,     6,
     6,     5,     4,
    }; 
Mat A = Mat(3,3, CV_32S, dA );
Mat C = A.t()* A;

回答1:


OpenCV only supports matrix multiplication for matrices of floating point real or complex types.

You are creating matrix of signed integer type.

Supported types are:

CV_32FC1 //real float
CV_32FC2 //complex float
CV_64FC1 //real double
CV_64FC2 //complex double

The following similar code will work:

float dA[] = {
     1,     2,     3,
     4,     5,     6,
     6,     5,     4,
    }; 
Mat A = Mat(3,3, CV_32F, dA );
Mat C = A.t()* A;


来源:https://stackoverflow.com/questions/14795825/opencv-matrix-multiplication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!