First with haar-cascade method face and eyes are detected (but eye detection is not applicable to all pictures, its even identifying more than 2 eyes or just 1 eye)
then with cv2.medianBlur(img,5) and cv2.Canny(img, 100, 100), input image is smoothened and edges are detected
next i have to apply hough circles to locate iris position inside eyes but fails.. 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.medianBlur(img,5)''' 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 : cv2.rectangle(edges,(ex,ey),(ex+ew,ey+eh),(255,0,0),2)
circles = cv2.HoughCircles(edges,cv2.cv.CV_HOUGH_GRADIENT,1,20,param1=50,param2=10,minRadius=2,maxRadius=15)
circles = np.uint16(np.around(circles))
for i in circles[0,:]:
cv2.circle(edges,(i[0],i[1]),i[2],(0,255,0),2)
cv2.circle(edges,(i[0],i[1]),2,(0,0,255),3)
print "Drawn Rectangles." cv2.imshow('image',edges) cv2.waitKey(0) cv2.destroyAllWindows()