0
votes

My project is to extract the invariant features of iris of a missing person and compare it with the found people to find the match.

I successfully applied haar-cascade to detect face and eyes then applied smooth() and canny() for removing noise and edge detection

Now am stuck with hough circle to detect the pupil and center of pupil , ie iris position.. I've to adjust the parameters of hough circle for each image so that it detect the pupil..And i've no idea how'll i get the center and proceed to extract the invariant feature of iris.. please help!

here is my code

import numpy as np
import cv2
face_cascade =cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
eye_cascade = cv2.CascadeClassifier('haarcascade_eye_tree_eyeglasses.xml')
img = cv2.imread('sheikha.jpg',0)
img = cv2.bilateralFilter(img, 5, 175, 175) 
edges = cv2.Canny(img, 100, 100)
faces = face_cascade.detectMultiScale(
        img, scaleFactor=1.3, minNeighbors=5, minSize=(30, 30))
print "Detected %d faces." % len(faces)
print "Drawing rectangles..."
for (x, y, w, h) in faces:
        cv2.rectangle(img, (x, y), (x + w, y + h), (0,255,0), 2)
        eyes = eye_cascade.detectMultiScale(img, scaleFactor=1.3, minNeighbors=5,minSize=(10,10))
        for (ex,ey,ew,eh) in eyes :
            #if neye < 3:
            imgCrop = edges[ey:ey+eh,ex:ex+ew]           
            circles = cv2.HoughCircles(imgCrop,cv2.cv.CV_HOUGH_GRADIENT,1,60,param1=90,param2=10,minRadius=10,maxRadius=20) 
            circles = np.uint16(np.around(circles))
            for i in circles[0,:]:
                cv2.circle(imgCrop,(i[0],i[1]),i[2],(255,255,0),2)

print "Drawn Rectangles."
#cv2.imshow('edge',edges)
cv2.imshow('image',imgCrop)
cv2.waitKey(0)
cv2.destroyAllWindows()
1
Where is the image being used? - Jeru Luke
Actually this is just a part of my project when it goes right I'll combine with the main code of project .. so this code have to work for different pictures .. picture depends on user who upload it.. this code I upload is for a picture only .. when I give another picture it is not detecting pupil and that's my problem - sheikha
a few sample images would help - Jeru Luke
@JeruLuke for one image circles =cv2.HoughCircles(imgCrop,cv2.cv.CV_HOUGH_GRADIENT,1,60,param1=90,param2=10,minRadius=10,maxRadius=20) detect the pupil and this doesnt work for any other images - sheikha

1 Answers

0
votes

If you expect Hough algorithm to produce the same result every time, you have to feed it with a similar image every time. Basically what you want to do is preprocess the image of the pupil, so that for Hough all of them look almost identically. Check out Otsu's Thresholding, Adaptive Threhsolding and all the cool stuff around that, like bluring, unsharp masking, clahe, etc.

Remember to control the image together with the code on every step of preprocessing - it can easily get out of hand and messy. Compare the images visually and look for a well defined (ideally without noise and other circles), similarily looking binary image of the pupil, to know if Hough will see the images as almost identical, and thus detect circles with the same parameters.

Another idea would be to abandon the Hough idea altogether. Look at Finding Contours and their features (link1; link2). Can't say without the data, but it's definitely an alternative to be aware of.