Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

That problem seems to be known for quite a while. http://code.opencv.org/issues/4149

As mentioned in the code there is an assertion for accessing rows out of a submatrix.(hog.cpp, 311+). The code might still access values out of the submatrix range in x direction.

325:   dbuf[x] = (float)(lut[imgPtr[xmap[x+1]]] - lut[imgPtr[xmap[x-1]]]);

Anyway the result is different gradient image output in x direction.

Mat img = imread("image.png", 0);
Rect roiRect(0, 0, 48, 96);

Mat ROI = Mat(img, roiRect);
Mat ROI_clone = Mat(img, roiRect).clone();

computeGradient of ROI(isContinious = false; isSubmatrix = true) outputs following gradImg:

image description

ROI_clone(isContinious = true; isSubmatrix = false):

image description