Kristan
Kristan

Reputation: 387

OpenCV Error: Assertion failed -- matrix subtract

I have to following matrices with parameters:-

cv::Mat fFuncv--> size of fFunc [924440 x 10] and depth 5 

cv::Mat Ones -->size of Ones [924440 x 1] and depth 5

cv::Mat cFuncv-->size of cFunc [1 x 10] and depth 5

when I do:-

d = fFunc - Ones * cFunc;

I got the following error message

OpenCV Error:

Assertion failed (a_size.width == len) in gemm, file D:\opencv\sources\modules\core\src\matmul.cpp, line 1537 terminate called after throwing an instance of 'cv::Exception' what(): D:\opencv\sources\modules\core\src\matmul.cpp:1537: error: (-215) a_size.width == len in function gemm

if I perform another substract method, like

cv::subtract(fFunc,Ones*cFunc,d);

OpenCV Error:

Assertion failed (type2 == CV_64F && (sz2.height == 1 || sz2.height == 4)) in arithm_op, file D:\opencv\sources\modules\core\src\arithm.cpp, line 661 terminate called after throwing an instance of 'cv::Exception' what(): D:\opencv\sources\modules\core\src\arithm.cpp:661: error: (-215) type2 == CV_64F && (sz2.height == 1 || sz2.height == 4) in function arithm_op

Can you please help me what the error messages are meaning? What do I wrong?

Upvotes: 1

Views: 1359

Answers (1)

Quang Hoang
Quang Hoang

Reputation: 150825

I believe size is [Width,Height], which is [num_cols,num_rows] so you can't multiply a Ones * cFunc, but rather cFunc * Ones.

Upvotes: 1

Related Questions