title: Blob detection not working
body: <p>I'm trying to detect blobs in an image but its not working somehow. Basically I want to determine number of circles.</p>
  
  <p>Code:</p>
  
  <pre><code>import cv2
  import numpy as np
  import sys
  # Read image
  im = cv2.imread("K.jpg", cv2.IMREAD_GRAYSCALE)
  
  # Setup SimpleBlobDetector parameters.
  params = cv2.SimpleBlobDetector_Params()
  
  # Change thresholds
  params.minThreshold = 10
  params.maxThreshold = 200
  
  # Filter by Area.
  params.filterByArea = True
  params.minArea = 50
  
  # Filter by Circularity
  params.filterByCircularity = True
  params.minCircularity = 0.75
  
  # Filter by Convexity
  params.filterByConvexity = True
  params.minConvexity = 0.87
  
  # Filter by Inertia
  params.filterByInertia = True
  params.minInertiaRatio = 0.7
  
  detector = cv2.SimpleBlobDetector_create(params)
  
  
  # Detect blobs.
  keypoints = detector.detect(im)
  print len(keypoints)
  # Draw detected blobs as red circles.
  # cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures
  # the size of the circle corresponds to the size of blob
  
  im_with_keypoints = cv2.drawKeypoints(im, keypoints, np.array([]), (0, 0, 255),
                                        cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
  
  # Show blobs
  cv2.imshow("Keypoints", im_with_keypoints)
  if cv2.waitKey(0) and 0xff==27:
      cv2.destroyAllWindows()
  </code></pre>
  
  <p>Here's the input image:</p>
  
  <p><a href="https://i.stack.imgur.com/2T33d.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2T33d.jpg" alt="Image"></a></p>