Hi
I am very new to MATLAB in fact its been only a day or so.I am trying to implement face detection using exsisting functions and i am able to come across code provided by matlab. It works perfectly fine but i want to change it to detect faces in live video stream below is my code.
clear all
clc
%Detect objects using Viola-Jones Algorithm
%To detect Face
FDetect = vision.CascadeObjectDetector;
%Read the input image
vidDevice = imaq.VideoDevice('winvideo', 1, 'YUY2_640x480', ... % Acquire input video stream
'ROI', [1 1 640 480], ...
'ReturnedColorSpace', 'rgb');
vidInfo = imaqhwinfo(vidDevice);
nFrame = 0
while(nFrame<20)
rgbFrame = step(vidDevice); % Acquire single frame
rgbFrame = flipdim(rgbFrame,2);
%Returns Bounding Box values based on number of objects
BB = step(FDetect,rgbFrame);
figure,
imshow(rgbFrame);
hold on
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',5,'LineStyle','-','EdgeColor','r');
end
title('Face Detection');
nFrame=nFrame+1;
end
hold off;
What it does is that my webcam gets on correctly and detects face correctly but instead of having one figure for every frame it creates a new figure :).I tried to use the function refresh(figure) but not getting it right.I am pretty sure i am doing it in a horrible way so that is why i am here to seek help.
Thanks anyways