I have a matrix D
which I would like to set to zero where another matrix T
is zero and keep intact otherwise. In numpy, I'd do this:
D[T==0]=0;
but with cv::Mat
, not sure how to do it. I tried this:
D&=(T!=0);
with this result:
OpenCV Error: Assertion failed (type == B.type()) in gemm, file /build/opencv-AuXD2R/opencv-3.3.1/modules/core/src/matmul.cpp, line 1558
terminate called after throwing an instance of 'cv::Exception'
what(): /build/opencv-AuXD2R/opencv-3.3.1/modules/core/src/matmul.cpp:1558: error: (-215) type == B.type() in function gemm
Is the problem that I am mixing numeric types? I also tried this then (D
is CV_32F
as well, which I verified by outputting T.type()
, 5
):
cv::Mat TnotZero;
cv::Mat(T!=0).convertTo(TnotZero,CV_32F);
D&=TnotZero;
with the same result.
What is the solution?