title: Why does one circle go undetected by HoughCircles? How does minDist work?
body: <p>I was trying to detect circles in the following image using <a href="https://docs.opencv.org/3.1.0/dd/d1a/group__imgproc__feature.html#ga47849c3be0d0406ad3ca45db65a25d2d" rel="nofollow noreferrer">HoughCircles</a>.</p>
  
  <p><a href="https://i.stack.imgur.com/6AWPx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6AWPx.jpg" alt="enter image description here"></a></p>
  
  <p>Here is the code that I was tuning to find all the circles.</p>
  
  <pre><code>    import cv2
      import numpy as np
  
  
      img = cv2.imread("images/coins.jpg", 0)
  
      cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)
  
      minDist = 247
  
      circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,minDist,
                                  param1=170,param2=80,minRadius=0,maxRadius=0)
  
  
      print(circles)
  
      #print("Number of circles detected ", circles.length)
  
  
      circles = np.uint16(np.around(circles))
  
      for i in circles[0,:]:
          # draw the outer circle
          cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2)
          # draw the center of the circle
          cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3)
  
  
      cv2.imshow('detected circles',cimg)
      cv2.waitKey(0)
      cv2.destroyAllWindows()
  </code></pre>
  
  <p>For everything I tried, I was not able to detect one coin. The detected circles looked as follows.</p>
  
  <p><a href="https://i.stack.imgur.com/Rjnd7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rjnd7.png" alt="enter image description here"></a></p>
  
  <p>I have three questions here:</p>
  
  <ul>
  <li>What could be the reason that the second coin from the left in the first row was not detected?</li>
  <li>What does the <code>minDist</code> parameter do? Could you explain how it works? I read the documentation but could not understand.</li>
  <li>What do <code>minRadius</code> and <code>maxRadius</code> of <code>zero</code> mean here?</li>
  </ul>