I am using OpenCV hogdescriptor to compute the hog descriptor of different blocks of an image.
import cv2
im = cv2.imread('test.jpg',0)
dim = (450,274)
im = cv2.resize(im.astype(float), dim, interpolation = cv2.INTER_LINEAR)
winSize = (68,112)
blockSize = (34,28)
blockStride = (17,14)
cellSize = (17,14)
nbins = 9
hog =cv2.HOGDescriptor(winSize,blockSize,blockStride,cellSize,nbins)
hist=hog.compute(im[1:69,1:113].astype('uint8'))
The problem is that the code doesn't work when I try to calculate hog descriptor for a portion of the image, but when I switch to the whole image it works. I am not sure what I'm doing wrong.
My question: is there something wrong with the choice of parameters? Do, I need to change the value of other parameters like nlevels
?
My second question is about the choice of other parameters like derivAperture
,
winSigma
, histogramNormType
, L2HysThreshold
, gammaCorrection
, and nlevels
, can I simply use the values in this post? Is the value of winSigma
in the mentioned post large for a block of (68,112) size? In particular, I am not sure about the role that nlevels
plays, for example what happens if I change it to 1?
I also checked this post, but it is not useful for me since it is not using hogdescriptor.
Edit: Here is the image I'm using:
.
I tried 2 other images, and it doesn't work on those images as well. The code works up to the last line, but when it reaches hog.compute it stops with this message: This application has requested the Runtime to terminate it in an unusual way.