Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import cv2
- import cv2.cv
- cap = cv2.VideoCapture(0)
- while(True):
- # Capture frame-by-frame
- ret, frame = cap.read()
- # Our operations on the frame come here
- gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
- # Display the resulting frame
- circles = cv2.HoughCircles(gray,cv2.cv.CV_HOUGH_GRADIENT,1,20,param1=50,param2=30,minRadius=10,maxRadius=15)
- # print circles
- if circles is not None:
- print circles
- circles = np.uint16(np.around(circles))
- for i in circles[0,:]:
- # draw the outer circle
- cv2.circle(gray,(i[0],i[1]),i[2],(246,11,11),1)
- # draw the center of the circle
- cv2.circle(gray,(i[0],i[1]),2,(246,11,11),1)
- cv2.imshow('frame',gray)
- if cv2.waitKey(1) & 0xFF == ord('q'):
- break
- # When everything done, release the capture
- cap.release()
- cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement