Opencv 矩阵乘法

问题描述 投票:0回答:1

我需要将矩阵与其转置相乘,但出现以下错误:

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

这是代码:

int dA[] = {
     1,     2,     3,
     4,     5,     6,
     6,     5,     4,
    }; 
Mat A = Mat(3,3, CV_32S, dA );
Mat C = A.t()* A;
c++ opencv matrix-multiplication
1个回答
8
投票

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

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

支持的类型有:

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

以下类似代码将起作用:

float dA[] = {
     1,     2,     3,
     4,     5,     6,
     6,     5,     4,
    }; 
Mat A = Mat(3,3, CV_32F, dA );
Mat C = A.t()* A;
© www.soinside.com 2019 - 2024. All rights reserved.