I'm developing a proof of concept algorithm for iris-related biometrics. I'd like to be able to test it on a series of images, but in order to do so, I need to know the iris boundaries. Following the techniques used here, I've filtered and intelligently thresholded the image (Otsu's method), which leaves me just the dark circle of the pupil. I've attempted to use OpenCV's HoughCircles
method, but the non-C(++) documentation is sparse. Here is my code so far for this section.:
# Convert PIL to openCV type
cvImage = cv.CreateImageHeader(inputImage.size, cv.IPL_DEPTH_8U, 1)
cv.SetData(cvImage, inputImage.tostring())
self.cvSize = cv.GetSize(cvImage)
# Create storage for circles (there should only be one)
storage = cv.CreateMat(50, 1, cv.CV_32FC3)
# Get circles (why doesn't this work?)
circles = cv.HoughCircles(cvImage,storage,cv.CV_HOUGH_GRADIENT,2,(self.cvSize[0])/4,200,100);
The final line is the line in question. I followed several posts spread across the internet (most of which are for C/C++ or 5+ years old) and managed to come up with that line. It doesn't return any errors. How do I access the results? Do I access circles
or storage
. How do I access them? I've tried suggestions from this question, but, as the asker said, the cvMat
type isn't iterable, so it won't work. It seems like it would be less work to write my own Circular Hough Transform rather than deal with the sparse documentation of this library, but I think its something simple that I'm missing.
On a side note, how might I optimize the parameters to always return a fitting circle for a pupil in a reasonable amount of time?