Hi , I have an idea to use openmv to make a eye-tracker,but encounter difficulties in find the iris. here is the code, it’s seems that iris can’t not be found using the way of img.findcircle(),but find the left area of eye instead(the white of the eye),or it may be something wrong the parameter i take?
import sensor, time, image
# Reset sensor
sensor.reset()
# Sensor settings
sensor.set_contrast(3)
sensor.set_gainceiling(16)
# Set resolution to VGA.
sensor.set_framesize(sensor.VGA)
# Bin/Crop image to 200x100, which gives more details with less data to process
sensor.set_windowing((220, 190, 200, 100))
sensor.set_pixformat(sensor.GRAYSCALE)
# Load Haar Cascade
# By default this will use all stages, lower stages is faster but less accurate.
eyes_cascade = image.HaarCascade("eye", stages=24)
print(eyes_cascade)
# FPS clock
clock = time.clock()
while (True):
clock.tick()
# Capture snapshot
img = sensor.snapshot()
# Find eyes !
# Note: Lower scale factor scales-down the image more and detects smaller objects.
# Higher threshold results in a higher detection rate, with more false positives.
eyes = img.find_features(eyes_cascade, threshold=0.5, scale_factor=1.5)
# Find iris
for e in eyes:
print(e)
for c in img.find_circles(e,threshold = 1500, x_margin = 8, y_margin = 8, r_margin = 10,r_min = 1, r_max = 10, r_step = 1):
img.draw_circle(c.x(), c.y(), c.r(), color = (148, 0, 0))
print('find iris')
img.draw_cross(e[0], e[1])
pupil = img.find_eye(e)
#img.draw_rectangle(e)
img.draw_cross(pupil[0], pupil[1])
print(pupil[0])
print(pupil[1])