Opencv矩阵乘法

RBM*_*RBM 2 c++ opencv matrix-multiplication

我需要乘以矩阵及其转置,但我得到以下错误:

"OpenCV错误:断言失败(类型== B.type()&&(类型== CV_32FC1 ||类型== CV_64FC1 || type == CV_32FC2 || type == CV_64FC2))在未知函数中,文件.. .. ..\src\opencv\modules\core\src\matmul.cpp,第711行"

这是代码:

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

sga*_*zvi 7

OpenCV仅支持浮点实数或复数类型矩阵的矩阵乘法.

您正在创建有符号整数类型的矩阵.

支持的类型是:

CV_32FC1 //real float
CV_32FC2 //complex float
CV_64FC1 //real double
CV_64FC2 //complex double
Run Code Online (Sandbox Code Playgroud)

以下类似的代码将起作用:

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