Professional Documents
Culture Documents
Jayasakthi
Jayasakthi
JAYASAKTHI S
CODE:
eyeDetector = vision.CascadeObjectDetector('EyePairBig');
cam = webcam;
captureDuration = 10;
figure;
set(gcf, 'Name', 'Real-time Eye Detection and Capture', 'NumberTitle', 'off');
captureTimer = tic;
while toc(captureTimer) <= captureDuration
img = snapshot(cam);
if ~isempty(bbox)
img = insertObjectAnnotation(img, 'rectangle', bbox, 'Eyes');
imwrite(eyeRegion, 'captured_eyes.jpg');
figure;
imshow(eyeRegion);
title('Captured Eyes');
pause(1);
close(gcf);
end
imshow(img);
drawnow;
end
clear cam;
close all;
OUTPUT:
2. Webcam Initialization:
- A webcam object is created using the `webcam` function to capture live video frames.
3. Figure Initialization:
- A figure is created to display the live video feed and the captured eye region.
6. Adjustment:
- You can adjust the `captureDuration` variable according to the desired duration for
capturing eyes.
The code demonstrates a simple real-time eye detection and capture system using a
webcam and MATLAB's Computer Vision System Toolbox. It leverages the Viola-Jones
object detection framework for eye detection and provides visual feedback with
rectangles drawn around the detected eyes in the live video feed. The captured eye
regions are saved to an image file during the specified duration.