Matlab:致力于使用 'Detect and Track Multiple Face' 获取检测到的人脸
Matlab: Working on obtaining detected face using 'Detect and Track Multiple Face'
目前我尝试运行示例Detect and Track Multiple Face。当我尝试如下裁剪检测到的面部图像时:
.....
while keepRunning
.....
displayFrame = insertMarker(displayFrame, tracker.Points);
for I=1:size(bboxes,1)
J = imcrop(displayFrame, tracker.Bboxes(I, :));
imshow(J);
cropfile = sprint('crop %d.jpg, I);
imwrite(J, cropfile, 'jpg');
end
.....
然而,当主题不在视野中时,会出现“index is out of bounds because size(tracker.Bboxes)=[0,4].
的错误
当你不在 frame
中时,边界框是空的;你应该在循环之前检查它
if ~isempty(bboxes)
for I=1:size(bboxes,1)
J = imcrop(displayFrame, tracker.Bboxes(I, :));
imshow(J);
cropfile = strcat('crop', num2str(I));
cropfilefull =[cropfile,'.jpg'];
imwrite(J, cropfilefull, 'jpg');
end
end
对我有用
目前我尝试运行示例Detect and Track Multiple Face。当我尝试如下裁剪检测到的面部图像时:
.....
while keepRunning
.....
displayFrame = insertMarker(displayFrame, tracker.Points);
for I=1:size(bboxes,1)
J = imcrop(displayFrame, tracker.Bboxes(I, :));
imshow(J);
cropfile = sprint('crop %d.jpg, I);
imwrite(J, cropfile, 'jpg');
end
.....
然而,当主题不在视野中时,会出现“index is out of bounds because size(tracker.Bboxes)=[0,4].
的错误当你不在 frame
中时,边界框是空的;你应该在循环之前检查它
if ~isempty(bboxes)
for I=1:size(bboxes,1)
J = imcrop(displayFrame, tracker.Bboxes(I, :));
imshow(J);
cropfile = strcat('crop', num2str(I));
cropfilefull =[cropfile,'.jpg'];
imwrite(J, cropfilefull, 'jpg');
end
end
对我有用