title: Python and OpenCV. How do I detect all (filled)circles/round objects in an image?
body: <p>I am trying to make a program which opens an image, scans it for circles/round shapes and returns the coordinates so that I can use the <code>cv.Circle</code> function to draw circles over the circle detected. </p>
  
  <p>My question is: How do I get the coordinates/radii of the circles detected in an image using <code>cv.HoughCircles()</code> ? </p>
  
  <p>Using <a href="https://stackoverflow.com/questions/2933284/opencv-python-houghcircles-error">this</a> page, I found out how to detect the circles (which took me a lot of time to find out since I don't understand terms like threshold and the OpenCV documentation for Python is really poor, almost none). Unfortunately, on that page it didn't show how to extract the information of each circle detected from the <code>CvMat</code> created. How do I extract that information/is there some other way(eg. with <code>MemoryStorage()</code> ) ?</p>
  
  <p>This is my code so far:</p>
  
  <pre><code>import cv, opencv
  
  def main():
  
  
      im = cv.LoadImageM("Proba.jpg")
  
      gray = cv.CreateImage(cv.GetSize(im), 8, 1)
      edges = cv.CreateImage(cv.GetSize(im), 8, 1)
  
      cv.CvtColor(im, gray, cv.CV_BGR2GRAY)
      cv.Canny(gray, edges, 50, 200, 3)
      cv.Smooth(gray, gray, cv.CV_GAUSSIAN, 9, 9)
  
      storage = cv.CreateMat(im.rows, 1, cv.CV_32FC3)
  
      cv.HoughCircles(edges, storage, cv.CV_HOUGH_GRADIENT, 2, gray.height/4, 200, 100)
      # Now, supposing it found circles, how do I extract the information?
      print storage.r
  
  
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>Also, what value do the last two parameters of <code>HoughCircles</code> need to have in order for me to detect really small circles (like 3mm on the screen) ?</p>
  
  <p>Thank you all for your time and effort trying to help me!</p>
  
  <p>The image I'm working with is this:<img src="https://i.stack.imgur.com/NvSZL.jpg" alt="enter image description here"></p>