question in use img.findcircle() to find the iris

Discussion related to "under the hood" OpenMV topics.
scnuelc
Posts: 7
Joined: Sun May 20, 2018 9:06 am

question in use img.findcircle() to find the iris

Postby scnuelc » Tue Jul 31, 2018 4:52 am

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?

Code: Select all

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])
User avatar
kwagyeman
Posts: 2291
Joined: Sun May 24, 2015 2:10 pm

Re: question in use img.findcircle() to find the iris

Postby kwagyeman » Tue Jul 31, 2018 10:52 am

Hi, does the find_features() method find the eyes first? Please verify that part works.
Nyamekye,
scnuelc
Posts: 7
Joined: Sun May 20, 2018 9:06 am

Re: question in use img.findcircle() to find the iris

Postby scnuelc » Sat Aug 04, 2018 1:15 am

Yeah, the find_features() method can find the eyes sometimes, actually the find_circle method can find the cr(the white spot reflect by the irlight),but can't find iris,just show like thisImage, i set the findcircle() r_max parameter bigger,and the circle it detect is wrong like this Image , if you have any advise sugguest?

By the way, I also try to use openmv to make a model of Venous visualization,but get troble in the edge extraction using the canny or morph demoImageImageImage, is there any way for i to write my own algorithm like niblack for openmv?

thanks for your reply
best wishes
User avatar
kwagyeman
Posts: 2291
Joined: Sun May 24, 2015 2:10 pm

Re: question in use img.findcircle() to find the iris

Postby kwagyeman » Sat Aug 04, 2018 12:10 pm

Yes, if you download the build system and tweak anything:

https://github.com/openmv/openmv/wiki

Let me know once you get it installed and I'll walk you through how to add customs methods to the python user interface level.
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 8 guests