title: Opencv Python, shape recognition (bad quality picture)
body: <p>I'm using the following code to detect certain shapes in an image:</p>
  
  <pre><code>import cv2
  import numpy as np
  
  img = cv2.imread("006.jpg")
  
  grey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  
  ret,thresh = cv2.threshold(grey,127,255,1)
  
  cv2.imshow('img',thresh)
  cv2.waitKey(0)
  
  contours, h = cv2.findContours(thresh, 1, cv2.CHAIN_APPROX_SIMPLE)
  contours.sort(key = len)
  for contour in contours:
  
      approx = cv2.approxPolyDP(contour, 0.01*cv2.arcLength(contour, True), True)
  
      #star - &gt; yellow
      if len(approx) == 10:
          cv2.drawContours(img, [contour],0, (0,255,255), -1)
  
      #circle -&gt; black
      elif len(approx) &gt;= 11:
          cv2.drawContours(img, [contour], 0, (0,0,0), -1)
  
      #triangle -&gt; green
      elif len(approx) == 3:
          cv2.drawContours(img,[contour],0,(0,255,0),-1)
  
      #square -&gt; blue
      elif len(approx) == 4:
          cv2.drawContours(img, [contour],0, (255,0,0),-1)
  
      #pentagon -&gt; red
      elif len(approx) == 5:
          cv2.drawContours(img, [contour],0, (0,0,255), -1)
  
  cv2.imshow('img',img)
  cv2.waitKey(0)
  </code></pre>
  
  <p>This code works well for images on my computer, but when i print out the image, take a picture off it 
  and try to run the code on it again (as here: <a href="http://nl.tinypic.com/view.php?pic=2rgdgzq&amp;s=8#.VGjISfmG91Y" rel="nofollow">image</a>) it doesn't work as well as it should.</p>
  
  <p>I already tried using blurs and canny but I'm not able to smoothen my second picture enough.</p>
  
  <p>I hope someone can help!</p>