I am playing around with the SVM-HOG pipeline for pedestrian detection using OpenCV in python.
I have a lot of images of different sizes, some are small(e.g. 21×32), and some are larger(e.g. 127×264).
I first defined my HOG descriptor as hog = cv2.HOGDescriptor()
When I compute the HOG features by calling h = hog.compute(image)
I found that when the image is smaller than 64*128, the descriptor won't be able to compute the features, instead, it just terminates the program.
The original paper used 64*128 sized images, but I think it also stated it is ok to use images with the same aspect ratio which is 1:2 (correct me if I'm wrong).
My question is that is 64*128 the smallest size that a HOG descriptor can compute the feature on? because I tried to compute HOG features on images resized to 32*64, and it won't work.
for entries in os.listdir(dir_path):
if entries.endswith(".jpg"):
img = cv2.imread(os.path.join(test_path, entries))
rects, scores = hog.detectMultiScale(img, winStride=(4,4), padding=(8,8), scale=1.05)
sc = [score[0] for score in scores]
for i in range(len(rects)):
r = rects[i]
rects[i][2] = r[0]+r[2]
rects[i][3] = r[1]+r[3]
pick =[]
pick = non_max_suppression(rects, probs = sc, overlapThresh = 0.3)
for (x,y,w,h) in pick:
cv2.rectangle(img, (x, y), (w, h), (0, 255, 0), 1)
cv2.imshow("A",img)