How To Detect The Eye of this image?
3 次查看(过去 30 天)
显示 更早的评论
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/150719/image.jpeg)
1. read image
2. convert rgb2gray
3. filter
4. how do I automatically track the eye?
5. how do I crop that region
1 个评论
anjana sharma
2013-8-14
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/???
回答(3 个)
Image Analyst
2013-1-26
What is snapshop? This is a MATLAB forum only.
2 个评论
Image Analyst
2013-1-26
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.
Pasupathi T
2013-5-27
编辑:Walter Roberson
2014-2-21
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 个评论
Image Analyst
2013-5-27
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.
KHUSHBU PANCHAL
2014-11-5
IT IS NOT WORKING PROPERLY AND GIVING ERROR.. @ pic=img; im=frame;
2 个评论
kalani ekanayake
2015-5-13
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
2015-5-13
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!