![](/img/trans.png)
[英]how to display the frame difference output of all the frames in video using matlab
[英]Frames missing while reading video frame by frame in matlab
該代碼檢測面部並將其裁剪並存儲在數據庫文件夾中。數據庫文件夾中缺少面部圖像11和12。 是什么原因?
clc;
clear all;
%read video file
obj=vision.VideoFileReader('basu_converted.avi');
%read frame by frame
for k=1:100
videoFrame = step(obj);
FaceDetect = vision.CascadeObjectDetector;%using viola jones algorithm
BB = step(FaceDetect,videoFrame);
figure(1),imshow(videoFrame)
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',3,'LineStyle','-','EdgeColor','r');
end
%crop and save detected face images
for i = 1:size(BB,1)
J= imcrop(videoFrame,BB(i,:));
I=rgb2gray(imresize(J,[292,376]));
filename = ['G:\matlab_installed\bin\database\' num2str(i+k*(size(BB,1))) '.jpg'];
imwrite(I,filename);
end
end
我注意到您對圖像進行索引時出錯。 BB
的大小可變,因此您不能使用它來線性化索引。 而不是num2str(i+k*(size(BB,1)))
我將使用一個計數器,該計數器在每次迭代時遞增。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.