Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import cv2
  2. import numpy as np
  3.  
  4. img = cv2.imread('eye-01.jpg',0)
  5. img = cv2.medianBlur(img,5)
  6. cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)
  7.  
  8. circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,20,
  9. param1=50,param2=85,minRadius=100,maxRadius=200)
  10.  
  11. circles = np.uint16(np.around(circles))
  12. for i in circles[0,:]:
  13. # draw the outer circle
  14. cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2)
  15. # draw the center of the circle
  16. cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3)
  17.  
  18. plt.imshow(cimg)
  19. plt.title('detected circles')
  20. plt.show()
  21. print(circles.shape)
  22. print(len(circles[0]))
  23. print(len(img[0]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement