Ask Your Question

Michael Martin's profile - activity

2015-09-06 16:22:54 -0600 received badge  Enthusiast
2015-09-05 08:47:12 -0600 received badge  Self-Learner (source)
2015-09-05 08:44:49 -0600 answered a question Is this expected HOG outcome?

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

2015-09-04 07:16:32 -0600 commented answer Is this expected HOG outcome?

Found the answer to "why" has to do with submatrices and the resulting gradient image. I will post an extended version. 48 hour answer block ;)

2015-09-03 09:08:17 -0600 received badge  Student (source)
2015-09-03 05:06:15 -0600 asked a question Is this expected HOG outcome?

Hi, HOGDescriptor::compute() somehow does not behave as expected for me. It generates different output for the same window(see code). Is there a explanation for?

Mat imgRaw = imread("...", 1);

//Cut two areas of imgRaw that:
    //sliding window fits once
Mat singleWindow = Mat(imgRaw, Rect(1, 0, 48, 96)).clone();

    //sliding window  fits twice and the secound fit is equal to the singleWindow
Mat doubleWindow = Mat(imgRaw, Rect(0, 0, 49, 96)).clone();

vector<float> singleDescri, doubleDescri;

//standard HOG: block(16,16), bStride(8,8), cell(8,8), 9 bins
HOGDescriptor d(Size(48,96), Size(16,16), Size(8,8), Size(8,8), 9);

//using a winStride of one. No padding.
d.compute(singleWindow, singleDescri, Size(1, 1));
d.compute(doubleWindow, doubleDescri, Size(1, 1));

//SINGLE vector contains 1980 values - ((96/8)-1) * ((48/8-1)) * 4 * 9
//DOUBLE vector contains 3960 values
//secound half of DOUBLE should be equal SINGLE
//appeares that the first 396 vales are different, little but different
//as the HOG vector is calculated col by col this is exactly the first col of the window - ((96/8)-1) * 4 * 9