getDaimlerPeopleDetectorを使っての人検出。getDefaultPeopleDetectorを使った人検出は
こちら。
■入力画像
■サンプルコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
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) |
■実行結果
誤検出はあるが、getDefaultPeopleDetectorでの検出に比べると漏れは少なくなる印象。