How can i resolve the light issue in image processing??

3 views (last 30 days)
i am writing a code for finding eye blink of a person by using the value of person closed and open eye.... for this i am using a webcam for finding user realtime images but when i calculating a value light issue(sunlight etc ) make my value wrong... please help me to control the light issue in my project.... here is my code...
das = input('Do you want to start Driver Assistance System Y/N ', 's');
das;
vid = videoinput('winvideo', 2, 'YUY2_640x480');
set(vid, 'ReturnedColorSpace', 'RGB');
preview(vid);
disp('please open your eyes and press Enter.');
pause;
img = getsnapshot(vid);
faceDetector = vision.CascadeObjectDetector;
bboxes = step(faceDetector, img);
img = imcrop(img,bboxes);
pic=img;
imshow(pic)
imframe=30;
pic1=rgb2gray(pic);
se=strel('square',1);
%bw = edge(pic1,'canny',0.01);
eye_dil=imdilate(pic1,se);
d=imcrop(eye_dil,[1 49 250 105]);
imshow(d)
sumd(1,imframe)=sum(sum(d));
sumc1=sum(sum(d))
disp('please close your eyes and press Enter.');
pause;
img = getsnapshot(vid);
bboxes = step(faceDetector, img);
img = imcrop(img,bboxes);
pic=img;
imshow(pic)
imframe=30;
pic1=rgb2gray(pic);
se=strel('square',1);
%bw = edge(pic1,'canny',0.01);
eye_dil=imdilate(pic1,se);
d=imcrop(eye_dil,[1 49 250 105]);
imshow(d)
sumd(1,imframe)=sum(sum(d));
sumc2=sum(sum(d))
s=sumc2-sumc1
w=s/3;
x=sumc2+w
q=20 ;
for i=1:q
pause(1);
img = getsnapshot(vid);
bboxes = step(faceDetector, img);
if bboxes ~= 0
img = imcrop(img,bboxes);
pic=img;
imframe=30;
pic1=rgb2gray(pic);
se=strel('square',1);
%bw = edge(pic1,'canny',0.01);
eye_dil=imdilate(pic1,se);
d=imcrop(eye_dil,[1 49 250 105]);
sumd(1,imframe)=sum(sum(d));
sumc3=sum(sum(d))
pause(1);
img = getsnapshot(vid);
bboxes = step(faceDetector, img);
if bboxes ~= 0
img = imcrop(img,bboxes);
pic=img;
imframe=30;
pic1=rgb2gray(pic);
se=strel('square',1);
%bw = edge(pic1,'canny',0.01);
eye_dil=imdilate(pic1,se);
d=imcrop(eye_dil,[1 49 250 105]);
sumd(1,imframe)=sum(sum(d));
sumc4=sum(sum(d))
if sumc3 < x && sumc4 < x
disp('eyes closed')
end
end
end
end
end
end
  3 Comments
Image Analyst
Image Analyst on 7 Jun 2015
With the cursor in the editor window, type control-a (to select all the text) then type control-i (to properly indent everything).

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 7 Jun 2015

Categories

Find more on Get Started with MATLAB 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!