我编写了用于从视频中检测人脸的 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
最佳答案
你需要一个额外的循环:
for index=1:1:obj.numberofframes
img = read(mov,index);
... ...
% do face detection and crop for 'img' here
... ...
end
关于用于从多帧和裁剪人脸检测人脸的 matlab 代码?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22331753/