title: HOG people detection opencv using WEBCAM
body: <p>I am trying to detect people using a webcam. <br>
  I have already tried detecting people using a video and it worked. <br>
  When I change it from video to webcam the detection does not work. <br></p>
  
  <p>What should be done in order to support webcam? </p>
  
  <pre><code>    def inside(r, q):
      rx, ry, rw, rh = r
      qx, qy, qw, qh = q
      return rx &gt; qx and ry &gt; qy and rx + rw &lt; qx + qw and ry + rh &lt; 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) &amp; 0xFF == ord('e'):
             break
  cap.release()
  cv2.destroyAllWindows()
  </code></pre>