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

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 Kommentare

I think you have far too many "end" statements. You need to take your program and tell the MATLAB editor to apply smart indentation to it.
how it can apply?
With the cursor in the editor window, type control-a (to select all the text) then type control-i (to properly indent everything).

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Import and Export finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 7 Jun. 2015

Kommentiert:

am 7 Jun. 2015

Community Treasure Hunt

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

Start Hunting!

Translated by