add this line : import cv2.cv as cv
and change circles
circles = cv2.HoughCircles(gray,cv.CV_HOUGH_GRADIENT)
i.e. cv.CV_HOUGH_GRADIENT
in place of cv2.CV_HOUGH_GRADIENT
This will solve the AttributeError
that you were getting but still you'll get a type error, you'll have to provide arguments for dp
and minDist
(arguments at pos 3 and pos 4) and that you can give accordingly.(Here I've given 1 and 10)
#!/usr/local/bin/python
import cv2
import cv2.cv as cv
import numpy as np
img = cv2.imread("test.jpg")
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
circles = cv2.HoughCircles(gray,cv.CV_HOUGH_GRADIENT, 1, 10)
also please see a similar problem solved here:
http://answers.opencv.org/question/1497/errors-with-cv2houghcircles/