Eye status using histogram

Hello i'm doing a project for fatigue detection in real time the problem that i get is with eye status, i want to use histogram to compare between open eye and close eye and then find the difference between them so i can detect eye blink,i found a code that is very helpful, the problem is i want to save a reference image which is (open eye) from the camera , and then compare it with other frames , how can i do that? i want the reference image saved from real time stored in other location so it can't overwrite with other image.
please help

1 Comment

Im1 = imread('Eeye1.jpg'); Im2 = imread('Eeye.jpg');
Im1 = rgb2gray(Im1); Im2 = rgb2gray(Im2);
% convert images to type double (range from from 0 to 1 instead of from 0 to 255) Im1 = im2double(Im1); Im2 = im2double(Im2);
% Calculate the Normalized Histogram of Image 1 and Image 2 hn1 = imhist(Im1)./numel(Im1); hn2 = imhist(Im2)./numel(Im2);
% Calculate the histogram error f = sum((hn1 - hn2).^2); f; %display the result to console subplot(3,4,[9 10 11 12]); plot(1:size(hn1,1),mean(hn1,2),'b'); hold on plot(1:size(hn2,1),mean(hn2,2),'r');
this is the code i use it for histogram

Sign in to comment.

Answers (3)

Image Analyst
Image Analyst on 20 May 2016
When the driving first starts, take the histogram average over many frames - like for a minute or so. The idea being that when they first start driving, their eyes will be open most of the time. Then after a certain number of frames, save out that average histogram.
Or just read how other people have successfully done it here: http://www.visionbib.com/bibliography/motion-f725.html#Driver%20Monitoring,%20Eyes,%20Gaze

2 Comments

but how can i convert that to image? like the code?
You can use MATLAB to write it yourself. Or you can contact the authors and ask if you can buy their code.

Sign in to comment.

asd
asd on 22 Nov 2016
If you looking for the simplest method for the real time detection of the eye blinking which can be simply implemented. you find it in the blog (Designing a simple eye-blink detection algorithm for EEG). I hope this is what you want.

3 Comments

Image Analyst
Image Analyst on 22 Nov 2016
Edited: Image Analyst on 22 Nov 2016
I had to Google the sentence to find it because you forgot to include it. Here is the link
Some observations. In method 1 you used simple thresholding but rejected it because it couldn't detect long blinks and had false positives because of noise. In method 2 you say you get good results by filtering and thresholding but then say it's bad because it takes too long. However in method 4, cross correlation you say it's a good method. But doing a low pass filter with conv() takes the same amount of time as doing a cross correlation because they're essentially the same operation. Actually the low pass filter could be slightly faster if you did a simple box filter. So I don't see any reason why method 4 is better than method 2.
Then you say you abandoned the 4 prior methods you tested in favor of this final implementation: "I then decided to focus on the detection of the blink onset and then to simply suppose that the eye blink last another 400ms, and to flag all the frames that fall within this timeline. Very simple, no filters, reliable." Read that over again -- that's no algorithm at all. All you said was that you want to "focus on the detection of the blink onset". Well, ALL of your other methods also wanted to find where the blink started and stopped. You give no details about this at all. There is nothing anyone can implement from that description. Opening up your supplied MATLAB code, it appears that the algorithm calls the signal a blink if channel 1 is below -75 and then calls the end of the blink as 450 ms past the start of the blink. Well this is essentially just a simple thresholding like in method 1 that you rejected. Moreover, your final method may also miss long blinks which was one of the reasons you rejected method 1. So your final method should also be rejected because it seems to have both of the problems that method 1 had and was rejected for. I think it would help us understand if your explanation somehow addressed those apparent contradictions.
And of course this method is not a video method of watching the driver's eyes. It's based on the driver being hooked up to an EEG instrument (scalp wires or perhaps a "helmet"), which could be a drawback in driver monitoring over simple video surveillance methods.
I am doing the project on Drowsiness Driver Detection using MatLab code. Here is the program for completely Eye opened and closed coding. Please can anyone help me for opened,closed, half closed and or about to close the eyes.
@Vaishnavi M Pastay, you said "Here is the program for completely Eye opened and closed coding." but you forgot to attach it or say where someone could get it. Are you talking about your own code, or the web site @asd mentioned but forgot to include (though I managed to find it and put the link for it in my comment above)?

Sign in to comment.

Vaishnavi M Pastay
Vaishnavi M Pastay on 10 Jun 2021
And it also detect wearing a spectacule.

Categories

Asked:

on 20 May 2016

Commented:

on 10 Jun 2021

Community Treasure Hunt

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

Start Hunting!