How To Detect The Eye of this image?

1 view (last 30 days)
john john
john john on 26 Jan 2013
Commented: Image Analyst on 13 May 2015
Hi guys I am doing eye tracking in real time in snapshop i need help with image processing, any best suggestion to track the eye and crop it automatically?
this is my image
1. read image
2. convert rgb2gray
3. filter
4. how do I automatically track the eye?
5. how do I crop that region
  1 Comment
anjana sharma
anjana sharma on 14 Aug 2013
Hi John, I m also doing my work on detecting eye in any entered image.I hve tried but the cropping and coordinates are well for one image but not general for any other image.I m tryng something with horizontal projection but not able to detect the coordinates with high intensity i.e eyes in the upper region of the image.if u pls getsomethng pls help me out. i m already stuck/???

Sign in to comment.

Answers (3)

Image Analyst
Image Analyst on 26 Jan 2013
What is snapshop? This is a MATLAB forum only.
  2 Comments
john john
john john on 26 Jan 2013
ops snapshot what i mean sir..
Image Analyst
Image Analyst on 26 Jan 2013
You need to find an iris locating algorithm. Check the File Exchange and Vision Bib for suitable algorithms - we don't provide that kind of major research for you here. Once you have code and need some help on things like syntax, error messages, etc. then that's the kind of thing we mostly provide help on.

Sign in to comment.


Pasupathi T
Pasupathi T on 27 May 2013
Edited: Walter Roberson on 21 Feb 2014
hai Image Analyst,
i am doing project using MATALB for drowsiness detection of driver..so far i have done something..
1.Image is captured in real time thru webcam
2.Images are converted into frames
3. and then stored in some location
i am struggling in detecting eyes and finding drowsy...herewith i have attached my code... please correct it and help me to get the output
clc ; % clearing the command window
%%%%%%%%%%%
n = input(' Enter the number of photos to be taken: ');
intervel = input(' Enter the time(seconds) gap between succeessive photos: ');
photosave = input(' Do you want to save the files(y/n): ','s');
disp('Please wait...');
%%%%%%%%%%
outputFolder = fullfile(cd, 'frames');
if ~exist(outputFolder, 'dir')
mkdir(outputFolder);
end
%%%%%%%%%%
obj = videoinput('winvideo',1);
preview(obj);
disp('Press Enter to start after webcam initialization.');
pause;
disp('First shot will taken after 1 second');
pause(1);
%%%%%%%%%%
for i=1:n
img=getsnapshot(obj);
image(img);
if(photosave == 'y')
outputBaseFileName = sprintf('fr%d.png',i);
outputFullFileName = fullfile(outputFolder, outputBaseFileName);
imwrite(img,outputFullFileName,'jpg');
end
pause(intervel);
end
closepreview;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
pic=img;
im=frame;
t=0.12;
pic_rgb=rgb2gray(pic);
ca=im2bw(pic_rgb,t);
c=~ca;
%Morphology On B&W Image to Detect Location Of Eyes
se=strel('square',1);
eye_dil=imdilate(c,se);
d=imcrop(eye_dil,[110 105 110 33]);
figure(1),
imshow(d),
%%figure(1)
subplot(3,1,1),imshow(pic);
subplot(3,1,2),imshow(eye_dil);
% % For subplot
sumd(1,im)=sum(sum(d));
subplot(3,1,3), plot(sumd);
xlabel('Frame Numbers');
ylabel('Pixel Values');
%for store and decision
sumc1=sum(sum(d));
drowsyFrames =0;
if sumc1<(20)
disp('eye is closed')
% Increment the number of frames where the eye is closed.
drowsyFrames = drowsyFrames +1;
% Check to see if it's been closed for the past 5 frames.
if drowsyFrames >= 5
disp('drowsy')
else
% It's been closed less than 5 frames, so this is a normal eyeblink.
disp('normal')
end
else
disp('eye is open')
drowsyFrames = 0; % Reset counter when the eye is open.
end
disp('The program successfully taken the photos');
disp('Done.');
  1 Comment
Image Analyst
Image Analyst on 27 May 2013
I don't have a webcam hooked up to this computer. I suggest you also look in VisionBib for algorithms to see if they do it the way that you do.

Sign in to comment.


KHUSHBU PANCHAL
KHUSHBU PANCHAL on 5 Nov 2014
IT IS NOT WORKING PROPERLY AND GIVING ERROR.. @ pic=img; im=frame;
  2 Comments
kalani ekanayake
kalani ekanayake on 13 May 2015
Hi, have you find any solution for this? I'm also looking for doing a similaer thing to detect sleepyness eyes. can you please help me to start with?
Image Analyst
Image Analyst on 13 May 2015
kalani, did you see my link where a bunch of papers on drowsiness detection are listed? There is nothing in MATLAB for that so you'll have to write your own using algorithms listed in those papers from lower level MATLAB functions.

Sign in to comment.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!