title: python opencv shape detection
body: <p>For a school project I'm trying to recognize a hexagon shape in a video capture using python and opencv. The problem is that when I use this code, it never finds a hexagon. I haven't found a reason why it isn't working so I hope someone can help me.</p>
  
  <p>The code:</p>
  
  <pre><code>import numpy as np
  import cv2
  
  stop_cascade = cv2.CascadeClassifier('cascade.xml')
  
  cap = cv2.VideoCapture(0)
  
  while(True):
      ret, img = cap.read()
      lower = np.array([0,0,0])
      upper = np.array([20,20,20])
      mask = cv2.inRange(img, lower, upper)
      contours, h = cv2.findContours(mask, 1, 2)
      contours.sort(key = len)
  
      for contour in contours[-3:]:
          approx = cv2.approxPolyDP(contour,0.1*cv2.arcLength(contour,True),True)
          if len(approx) == 6:
              print "hexagon"
  
      cv2.imshow('image', mask)
  
      if cv2.waitKey(1) &amp; 0xFF == ord('q'):
          break
  
  cap.release()
  cv2.destroyAllWindows()
  </code></pre>
  
  <p>Thanks in advance</p>
  
  <p>Edit:
  To be a little more specific. I've tried mulitple different hexagons but when I print the len(approx) it is never higher then 4. Is this a fault in my object or is it that I have an error in finding the contours i don't know about?</p>