我编写了用于从视频中检测人脸的matlab代码。但它是从单帧检测人脸。它显示单帧的裁剪人脸。我想从多个帧中检测并裁剪人脸。这是我的代码< /强>
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
答案 0 :(得分:2)
你需要一个额外的循环:
for index=1:1:obj.numberofframes
img = read(mov,index);
... ...
% do face detection and crop for 'img' here
... ...
end