Ask Your Question
0

HOG:How much to resize image when calculating HOG features?

asked 2016-05-27 01:04:14 -0600

kevgeo gravatar image

I am trying to make a function in c++ using opencv(2.4.9) which will be similar to the extractHOGFeatures function of MATLAB.

I need to know whether there is way to compute the HOG features without explicitly resizing the image in OpenCV. If I don't resize the image, I get an error.

Assertion failed ((unsigned)pt.x <= (unsigned)(grad.cols - blockSize.width) && (unsigned)pt.y <= (unsigned)(grad.rows - blockSize.height)) in getBlock, file /build/buildd/opencv-2.4.8+dfsg1/modules/objdetect/src/hog.cpp, line 630 terminate called after throwing an instance of 'cv::Exception' what(): /build/buildd/opencv-2.4.8+dfsg1/modules/objdetect/src/hog.cpp:630: error: (-215) (unsigned)pt.x <= (unsigned)(grad.cols - blockSize.width) && (unsigned)pt.y <= (unsigned)(grad.rows - blockSize.height) in function getBlock

So I generally resize the image to 64x128.

But I would like to know how MATLAB resizes the image with their function extractHOGFeatures.

Here is my program- https://drive.google.com/open?id=0B3j...

So two main questions are- 1. How does MATLAB resize the image to compute HOG Features? 2. Is there a way to compute the HOG features without resizing the image in OpenCV?

edit retag flag offensive close merge delete

Comments

1

the default hog windowSize is 64x128 (which is perfect for persons, but not so much for e.g. cars). you can either fit your images to that size, or fit the windowSize to your images (should still be a factor of 8, iirc) by e.g.

HOGDescriptor hog;
hog.windowSize = Size(32,32); // train patches should have same size.

was that, what you mean ?

berak gravatar imageberak ( 2016-05-27 01:46:17 -0600 )edit

Hey berak, actually I resolved that error, the window size I was using was bigger than the image. I just wanted to know what the default windowSize in MATLAB is since I want to create a function in OpenCV similar to the extractHOGFeatures function. So is the default size for windowSize normally 64x128?

kevgeo gravatar imagekevgeo ( 2016-05-27 04:56:01 -0600 )edit
1

if you could make a quick comment, how you did that - then we'd have an answer here !

berak gravatar imageberak ( 2016-05-27 04:58:31 -0600 )edit
1

sorry, i can't help you with matlab topics. (but the default size in opencv's HOGDescriptor is 64x128)

berak gravatar imageberak ( 2016-05-27 04:59:59 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-05-31 01:47:15 -0600

kevgeo gravatar image

Thanks berak for the default window size. Actually I made a simple mistake where the window size was bigger than image,thus the error.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-05-27 01:04:14 -0600

Seen: 1,562 times

Last updated: May 27 '16