opencvのHOGDescriptorとSVM(getDaimlerPeopleDetector)で人検出

getDaimlerPeopleDetectorを使っての人検出。getDefaultPeopleDetectorを使った人検出は
こちら。

■入力画像
HOGDescriptor_getDaimlerPeopleDetector input

■サンプルコード

import cv2
im = cv2.imread("people.jpg")

# Calculation of HoG feature quantity
hog = cv2.HOGDescriptor((48,96), (16,16), (8,8), (8,8), 9)

#Create Human Identifier with HoG feature quantity + SVM
hog.setSVMDetector(cv2.HOGDescriptor_getDaimlerPeopleDetector())


#widStride :Window movement amount
#padding   :Extended range around the input image
#scale     :scale
hogParams = {'winStride': (8, 8), 'padding': (32, 32), 'scale': 1.05}

#Detected person coordinate by the created identifier device 
human, r = hog.detectMultiScale(im, **hogParams)

#Surround a person's area with a red rectangle
for (x, y, w, h) in human:
    cv2.rectangle(im, (x, y),(x+w, y+h),(0,50,255), 3)

#show image
cv2.imshow("results human detect by getDaimlerPeopleDetector",im)
cv2.waitKey(0)

■実行結果
HOGDescriptor_getDaimlerPeopleDetector output

誤検出はあるが、getDefaultPeopleDetectorでの検出に比べると漏れは少なくなる印象。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA