0

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?

lurker
  • 56,987
  • 9
  • 69
  • 103
alladinsane
  • 185
  • 1
  • 11
  • The error points to line 152 in your code. Is the code you're showing anywhere near there? – lurker Apr 16 '19 at 10:01
  • The error is pointing to an assertion line within the OpenCV library, which isn't particularly helpful. – PeteBlackerThe3rd Apr 16 '19 at 10:03
  • The assertion which is failing is checking three things, that the images are the same size, same type and have a type of either 32 or 64 bit float. Your code is taking the depth from the GREY_IMAGE mat we can't tell from your code snippet what depth this is, but if it's not a 32 or 64 bit float then that could be the cause of the error. – PeteBlackerThe3rd Apr 16 '19 at 10:06
  • Is there anything I could provide to make it more clear? – alladinsane Apr 16 '19 at 10:08
  • 1
    Oh guys, I'm so dumb. Just replaced GREY_IMAGE.depth() with CV_32F and everything works properly. Thanks for your help! – alladinsane Apr 16 '19 at 10:11
  • Glad you got it working. In my experience OpenCV assertion errors can be very cryptic! – PeteBlackerThe3rd Apr 16 '19 at 10:43

0 Answers0