Skip to content

Commit

Permalink
completed circle detection with certain errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Anirudh-C committed May 13, 2018
1 parent 2b1beeb commit feee738
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions DFA/shapes/circle_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@
import numpy as np

def DetectCircles(image):
houghcircles = cv2.HoughCircles(image, cv2.HOUGH_GRADIENT,1,20,param1=50,param2=30,minRadius=35,maxRadius=60)
minpercent = 0.13
maxpercent = 0.33
height,width = image.shape[:2]
minValue = min(height,width)
maxValue = max(height,width)
min_radius = int(minpercent * minValue/2)
max_radius = int(maxpercent * maxValue/2)
houghcircles = cv2.HoughCircles(image, cv2.HOUGH_GRADIENT,1,20,param1=50,param2=30,minRadius=min_radius,maxRadius=max_radius)
houghcircles = np.uint16(np.around(houghcircles))
return houghcircles

def test():
img = cv2.imread(sys.argv[1],0)
img = cv2.medianBlur(img,5)
editimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)
for i in DetectCircles(img)[0,:]:
cv2.circle(editimg,(i[0],i[1]),i[2],(0,255,0),2)
cv2.circle(editimg,(i[0],i[1]),2,(0,0,255),3)
cv2.imshow('detected circles',editimg)
cv2.circle(img,(i[0],i[1]),i[2],(0,255,0),2)
cv2.circle(img,(i[0],i[1]),2,(0,0,255),3)
cv2.imshow('detected circles',img)
cv2.waitKey(0)
cv2.destroyAllWindows()

Expand Down

0 comments on commit feee738

Please sign in to comment.