I wrote matlab code for detecting face from video.But it is detecting face from single frame.It is showing cropped faces for single frame.i want to detect and crop face from multiple frames.Here is my code
clc;
clear all;
%read frames from video
obj=VideoReader('vtu.avi');
img = read(obj,1);
figure(1),imshow(img);
%detect face using vision.CascadeObjectDetector
FaceDetect = vision.CascadeObjectDetector;
BB = step(FaceDetect,img);
figure(2),imshow(img);
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',3,'LineStyle','-','EdgeColor','r');
end
%crop faces
for i = 1:size(BB,1)
J= imcrop(img,BB(i,:));
figure(3),subplot(2,2,i);imshow(J);
end
You need an extra loop:
for index=1:1:obj.numberofframes
img = read(mov,index);
... ...
% do face detection and crop for 'img' here
... ...
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With