Improve speed/performance of HOG SVM classifier

Viewed 501

I am trying to detect people in a video. Initially I came up with this simple code.

hog = cv2.HOGDescriptor()
hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())

def detectPeople(foreground):
    start = time.time()
    rects, weights = hog.detectMultiScale(foreground, winStride=(2, 2), padding=(8, 8), scale=1.05)
    rects = np.array([[x, y, x + w, y + h] for (x, y, w, h) in rects])
    people = non_max_suppression(rects, probs=None, overlapThresh=0.65)
    end = time.time()

I do detectPeople for every frame in the video. These are the timing results for the first five frames.

time:  0.9525866508483887
time:  0.9560775756835938
time:  0.9591171741485596
time:  0.9400520324707031
time:  0.9048192501068115

That's ridiculously close to 1 second a frame. With a video of 25 fps for 10 seconds that'll take 4 minutes!!! Any pointers on this matter is appreciated.

0 Answers
Related