2017-02-15 1 views
1

웹캠을 사용하는 사람들을 탐지하려고합니다.
나는 이미 비디오를 사용하는 사람들을 탐지하려고 노력했으며 효과가 있었다.
비디오에서 웹캠으로 변경하면 감지가 작동하지 않습니다.
사람 찾기 WEBCAM을 사용하여 opencv

웹캠을 지원하려면 어떻게해야합니까? 그것은 일반 비디오와 함께 작동하는 경우 처리 된 프레임이 현저하게 (즉, 너무 많은 소음, 너무 큰 사람 등) 변화하지 않는 한 웹캠 작동하지 왜

def inside(r, q): 
    rx, ry, rw, rh = r 
    qx, qy, qw, qh = q 
    return rx > qx and ry > qy and rx + rw < qx + qw and ry + rh < qy + qh 

    def draw_detections(img, rects, thickness = 1): 
for x, y, w, h in rects: 
    # the HOG detector returns slightly larger rectangles than the real objects. 
    # so we slightly shrink the rectangles to get a nicer output. 
    pad_w, pad_h = int(0.15*w), int(0.05*h) 
    cv2.rectangle(img, (x+pad_w, y+pad_h), (x+w-pad_w, y+h-pad_h), (0, 255, 0), thickness) 
if __name__ == '__main__': 

hog = cv2.HOGDescriptor() 
hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector()) 
cap = cv2.VideoCapture(0) 
while True: 
    ret,frame=cap.read() 
    found,w=hog.detectMultiScale(frame, winStride=(8,8), padding=(32,32), scale=1.05) 
    draw_detections(frame,found) 
    cv2.imshow('feed',frame) 
    if cv2.waitKey(1) & 0xFF == ord('e'): 
      break 
cap.release() 
cv2.destroyAllWindows() 
+0

비디오 및 웹캠에서 샘플 인물 이미지를 게시 할 수 있습니까? – Micka

답변

관련 문제