Per project requirements, I set-up an environment where I could control some key variables:
- Distance from the eye to the lens of the camera
- Discrete amount of light that iluminates the frame (on/off)
Using the videos obtanied from the environment, to save on time and computing power, I checked for valid video-frames. I created a script that could recognize when the flash is on by checking the white-pixel average of each frame:
Since the pupil contracts non-instantaneously, I would save all the frames from that point until the flash turns off again, and then I can safely say that the pupil may contract in those frames.Using the output frames from the last script, the next script tries to find the eyes, specifically the iris. This script uses one (1) filter for all the videos in the a set. For example, the filter corresponding to the set "Lay-down and fixed" is this image:
For every video I read a frame, process the frame, and set up a marker (the little white and black square near the pupil) where the image best correlates with the filter (it's not necessary and even undesirable that the marker is in the exact middle of the pupil):After finding our marker, I walk a horizontal line across the pupil until it finds white again. Then, for every frame, I log the "blackness" of the image. If the image is lighter, it means that the pupil has contracted:
Every row corresponds a unique video. The numbering resets after each set of videos, each set has their own filter.