Created
June 23, 2016 16:16
-
-
Save bc080401210/7178836dbe7cbba1a492c8b7231a5ed3 to your computer and use it in GitHub Desktop.
detect big Eyes Pair from a live web cam feed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear all; | |
close all; | |
clc; | |
%% initalize camera | |
vidDevice = imaq.VideoDevice('winvideo', 1, 'YUY2_320x240', ... % Acquire input video stream | |
'ROI', [1 1 320 240], ... | |
'ReturnedColorSpace', 'rgb'); | |
% vidDevice = imaq.VideoDevice('winvideo', 1, 'YUY2_640x480', ... % Acquire input video stream | |
% 'ROI', [1 1 640 480], ... | |
% 'ReturnedColorSpace', 'rgb'); | |
vidInfo = imaqhwinfo(vidDevice); | |
se = strel('square', 3); % morphological filter for noise removal | |
hVideoIn = vision.VideoPlayer('Name', 'Final Video', ... % Output video player | |
'Position', [100 100 vidInfo.MaxWidth+20 vidInfo.MaxHeight+30]); | |
nFrame = 0; % Frame number initialization | |
botheye = vision.CascadeObjectDetector('EyePairBig'); | |
for i=1:100 | |
rgbFrame = step(vidDevice); % Acquire single frame | |
rgbFrame = flip(rgbFrame,2); | |
gray_x = rgb2gray(rgbFrame); | |
bbox_eye = step(botheye,gray_x); | |
if(size(bbox_eye,1)>0) | |
vOut2 = insertObjectAnnotation(rgbFrame,'rectangle'... | |
,bbox_eye(1,:),'EYE','Color','blue'); | |
end | |
step(hVideoIn, vOut2); | |
end | |
release(vidDevice); | |
release(hVideoIn); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment