Opencv矩阵乘法 [英] Opencv Matrix multiplication

查看:1051
本文介绍了Opencv矩阵乘法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



OpenCV错误:Assertion失败(type == B.type()& ;&(type == CV_32FC1 || type ==
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;


解决方案

OpenCV只支持对浮点数或复杂类型。



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



支持的类型有:

  CV_32FC1 //真正的浮动
CV_32FC2 //复杂的浮动
CV_64FC1 //真双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;


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;

解决方案

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;

这篇关于Opencv矩阵乘法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆