Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  • problem 1: the depth:

    GREY_IMAGE.depth() is probably just CV_8U, and you need some float format for magnitude() later. you're also truncating negative values from the sobel like this(again, unsigned char ...), so, a bad idea

  • problem 2: handling UMat:

    please do not reuse UMats for src and dst, this causes known reference problems. you can't do resize() in-place anyway,.


UMat dx, dy, dxs,dys;
Sobel(gr, dx, CV_32F, 1, 0, 3); // float result !
Sobel(gr, dy, CV_32F, 0, 1, 3);
resize(dx, dxs, Size(dx.rows, dx.rows), 0, 0, CV_INTER_AREA); // use fresh result UMat header
resize(dy, dys, Size(dx.rows, dx.rows), 0, 0, CV_INTER_AREA);
UMat mag; // leave empty.
magnitude(dxs, dys, mag);

// just to visualize;
Mat res;
hconcat(dxs,dys, res);
hconcat(res,mag, res);

image description