Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV matrix multiplication assertion

Tags:

c++

opencv

I'm getting

OpenCV Error: Assertion failed (type == B.type() && (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2)) in gemm, file /build/buildd
/opencv-2.4.9+dfsg/modules/core/src/matmul.cpp, line 711
terminate called after throwing an instance of 'cv::Exception'
  what():  /build/buildd/opencv-2.4.9+dfsg/modules/core/src/matmul.cpp:711: error: (-215) type == B.type() && (type == CV_32FC1 || type == CV_64FC1 || type == 
CV_32FC2 || type == CV_64FC2) in function gemm

I'd like to know where in the docs it's mentioned matrix multiplication is supported solely for floating point matrices? I could only find people telling this in SO, but nothing so far comparable to a standard documentation.

like image 647
pepper_chico Avatar asked May 02 '26 11:05

pepper_chico


1 Answers

You didn't mentioned the operator you are using but you can try mat1.mul(mat2), mat1*mat2, multiply(mat1, mat2, dst) or do:

mat1.convertTo(mat1, CV_32FC1);
mat2.convertTo(mat2, CV_32FC1);

and if needed:

mat1.convertTo(mat1, CV_8UC1);
mat2.convertTo(mat2, CV_8UC1);
like image 115
Tom A Avatar answered May 04 '26 01:05

Tom A



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!