Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Calculating a magnitude

Hi there, I have a hard time compiling this piece of code:

UMat dx, dy;
Sobel(GREY_IMAGE, dx, GREY_IMAGE.depth(), 1, 0, 3);
Sobel(GREY_IMAGE, dy, GREY_IMAGE.depth(), 0, 1, 3);
resize(dx, dx, Size(dx.rows, dx.rows), 0, 0, CV_INTER_AREA);
resize(dy, dy, Size(dx.rows, dx.rows), 0, 0, CV_INTER_AREA);
UMat mag(dx.size(), dx.type());
magnitude(dx, dy, mag);

Whenever I try it a get a response:

{msg="OpenCV(4.0.0-dev) E:\opencv-master\modules\core\src\mathfuncs.cpp:151: error: (-215:Assertion failed) src1.size() == src2.size() && type == src2.type() && (depth == CV_32F || depth == CV_64F) in funct... ...}

I have no idea what's wrong with the code above. Dimensions are ok, all three matrixes are quadratic. What shall I do?