0

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: enter image description here.

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.

Community
  • 1
  • 1
Miranda
  • 565
  • 1
  • 10
  • 27
  • Uploading the image and what you have obtained will be of help... – Jeru Luke Jan 30 '17 at 17:50
  • Please see my edit with the error that I get, and image I've been using. – Miranda Jan 30 '17 at 18:01
  • [THIS PAGE](http://docs.opencv.org/2.4/modules/gpu/doc/object_detection.html) has some of the variables you are looking for – Jeru Luke Feb 03 '17 at 17:24
  • I've seen this page, but I'm not sure about the meaning of nLevels they way it has been described and appreciate if someone can explain it to me. I had to eventually implement hog, since this function was of no use to me. But, I'm still curious about what to do with the error that I get, and why It doesn't work on a block of image. – Miranda Feb 03 '17 at 23:09

0 Answers0