-1

I try to compute gradient map using HOGDescriptor. My code:

HOGDescriptor hog;
hog.compute(faceROI,ders,Size(32,32),Size(0,0),locs);
Mat grad;
Mat sec;
hog.computeGradient(frame_gray, grad, angleofs);

imshow("1", frame_gray);
imshow("2", grad); //here program fails: Unhandled exception at memory location
imshow("3", angleofs); //grad.data = "". Why??

I cant find goot examples of using HOGDescriptor::computeGradient.

Help please!

2 Answers 2

7

To visualize OpenCv's HOGDescriptor::Calculate(..), use this, it's amazing.

0
0

imshow("2", grad); fails because imshow expects that grad image is a 1, 3 or 4 channel image whereas it is a 2 channel image.

First channel contains the gradient in x direction whereas the second channel contains the gradient in y. You should split the channels in two images to visualize them:

Mat grad_channel[2];
split(grad, grad_channel);
imshow("grad_x", grad_channel[0]);
imshow("grad_y", grad_channel[1]);

Best

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.