繁体   English   中英

OpenCV 简单二维矩阵乘法失败

[英]OpenCV simple 2D matrix multiplication fails

我只是想将两个简单的二维矩阵相乘。

#include <iostream>
#include "opencv2/core.hpp"

using namespace std;
using namespace cv;

int main(const int argc,const char* argv[])
{

    Mat A = (Mat_<char>(2,2) << 1,2,3,4);
    Mat B = (Mat_<char>(2,2) << 2,2,2,2);
    Mat C = A*B;

    cout << C << endl;

    return 0;
}

为什么我会得到核心转储(gemm)?

抛出'cv :: Exception'实例后调用终止what():OpenCV(4.1.0)/OpenCV/opencv-4.1.0/modules/core/src/matmul.dispatch.cpp:337:错误:(- 215: 断言失败) (type == (((5) & ((1 << 3) - 1)) + (((1)-1) << 3)) || type == (((6) & ((1 << 3) - 1)) + (((1)-1) << 3)) || 类型 == (((5) & ((1 << 3) - 1)) + ( ((2)-1) << 3)) || 类型 == (((6) & ((1 << 3) - 1)) + (((2)-1) << 3))) 在function '宝石'

中止(核心转储)

https://github.com/opencv/opencv/blob/master/modules/core/src/matmul.dispatch.cpp#L337

根据消息来源,似乎代码需要浮动,

CV_Assert_N( type == B.type(), (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2) );

尝试使用Mat_<float> (为我工作)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM