Advertisement
Guest User

Untitled

a guest
Oct 7th, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. import numpy as np
  2. import cv2
  3. import cv2.cv
  4.  
  5. cap = cv2.VideoCapture(0)
  6.  
  7. while(True):
  8. # Capture frame-by-frame
  9. ret, frame = cap.read()
  10.  
  11. # Our operations on the frame come here
  12. gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
  13.  
  14. # Display the resulting frame
  15.  
  16. circles = cv2.HoughCircles(gray,cv2.cv.CV_HOUGH_GRADIENT,1,20,param1=50,param2=30,minRadius=10,maxRadius=15)
  17. # print circles
  18. if circles is not None:
  19. print circles
  20. circles = np.uint16(np.around(circles))
  21. for i in circles[0,:]:
  22. # draw the outer circle
  23. cv2.circle(gray,(i[0],i[1]),i[2],(246,11,11),1)
  24. # draw the center of the circle
  25. cv2.circle(gray,(i[0],i[1]),2,(246,11,11),1)
  26.  
  27.  
  28. cv2.imshow('frame',gray)
  29. if cv2.waitKey(1) & 0xFF == ord('q'):
  30. break
  31.  
  32.  
  33.  
  34.  
  35. # When everything done, release the capture
  36. cap.release()
  37. cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement