Need help with my eye tracking code.
4 views (last 30 days)
Show older comments
The below code tracks the eyes and convert it to gray scale for further process. But it only detects eyes when I am looking directly at webcam. If I look away, it stops tracking and won't start again, even if I start looking at the camera later. What modifications can be done to make it track eyes without stopping?
%clear
clc;
clear all;
close all;
%acquire video from webcam
cam = webcam('iBall Face2Face Webcam C8.0');
for idx = 1:1000
% acquire a single image
rgbImage = snapshot(cam);
%face detection
FDetect = vision.CascadeObjectDetector;
Fdetector.MergeThreshold = 100;
%show image
bbx = step(FDetect,rgbImage);
out = insertObjectAnnotation(rgbImage,'rectangle',bbx,'Face');
%eye detection
EyeDetect = vision.CascadeObjectDetector('EyePairBig');
Fdetector.MergeThreshold = 1000;
BBE = step(EyeDetect,out);
out = insertObjectAnnotation(out,'rectangle',BBE,'eye');
% rgb to gray
BBB = imcrop(out,BBE);
Eyes=rgb2gray(BBB);
level=0.3;
Ithresh=imbinarize(Eyes,level);
imshow(Ithresh);
%end
end
0 Comments
Answers (0)
See Also
Categories
Find more on Eye Tracking 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!