The program which i have written works fine if i keep the object almost still in front of the camera But if i try to displace it a little then the video window stops responding.

asked 2015-05-22 06:30:12 -0600

updated 2015-05-22 06:33:45 -0600

berak gravatar image
import cv2
import numpy as np
import cv2.cv as cv


cap = cv2.VideoCapture(0)

while(True):

    ret,frame =cap.read()
    img = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
   # img = cv2.imread('soda.png',0)
    img = cv2.medianBlur(img,5)


    circles = cv2.HoughCircles(img,cv.CV_HOUGH_GRADIENT,1,250,param1=70,param2=30,minRadius=0,maxRadius=0)

    circles = np.uint64(np.around(circles))
    for i in circles[0,:]:
        # draw the outer circle
        cv2.circle(img,(i[0],i[1]),i[2],(0,255,0),2)
        # draw the center of the circle
        cv2.circle(img,(i[0],i[1]),2,(0,0,255),3)

    cv2.imshow('detected circles',img)
    if cv2.waitKey(60) & 0xFF == ord('q'):
      break       



cap.release()        
cv2.destroyAllWindows()
edit retag flag offensive close merge delete

Comments

I think it is a problem of empty circles

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-05-22 06:57:32 -0600 )edit