簡體   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