【问题标题】:Detecting frames for which a face appears in a video检测视频中出现人脸的帧
【发布时间】:2023-03-30 22:11:01
【问题描述】:

我需要检测视频中出现人脸的帧数。我使用 MathWorks 站点 (http://www.mathworks.in/help/vision/examples/face-detection-and-tracking-using-camshift.html) 中提供的 CAMShift 算法查看了示例代码。有没有办法知道一张脸是否出现在特定的框架中?

我是 MatLab 的新手。我假设如果没有检测到人脸,step 函数将返回一个错误值(条件失败 - 类似于 C)。有没有可能的解决方案?我认为使用 MinSize 也是一种可能的解决方案。

我不担心计算负担 - 尽管同样需要更快的方法。我当前的代码如下:

clc;
clear all;

videoFileReader = vision.VideoFileReader('Teapot.mp4', 'VideoOutputDataType', 'uint8', 'ImageColorSpace', 'Intensity');
video = VideoReader('Teapot.mp4');
numOfFrames = video.NumberOfFrames;
faceDetector    = vision.CascadeObjectDetector();
opFolder = fullfile(cd, 'Face Detected Frames');

frameCount     = 0;
shotCount      = 0;

while ~isDone(videoFileReader)

    videoFrame      = step(videoFileReader);
    bbox            = step(faceDetector, videoFrame);
    framCount = frameCount + 1;

    for i = 1:size(bbox,1)
        shotCount = shotCount + 1;
        rectangle('Position',bbox(i,:),'LineWidth', 2, 'EdgeColor', [1 1 0]);
        videoOut = insertObjectAnnotation(videoFrame,'rectangle',bbox,'Face');
        progIndication = sprintf('Face has been detected in frame %d of %d frames', shotCount, numOfFrames);
        figure, imshow(videoOut), title(progIndication);
    end
end
release(videoFileReader);

【问题讨论】:

  • 在这种情况下,如果没有找到任何东西,我希望bbox 返回空。 (在您知道其中没有面孔的图像上试一试!)。
  • 我不认为它是这样工作的。 Cascade Object 肯定会尝试检测视频中的人脸。它可能会返回尽可能小的 bbox 大小。我尝试使用没有任何面孔的视频。这就是它似乎正在做的事情......
  • 真的吗?因为我只是在我的工作区中使用随机选择的图像进行了尝试,它返回为空。 (您可以使用isempty 在您的程序中进行检查)。
  • 好的。我会用我的程序试一试,然后告诉你。感谢您的帮助!
  • 实际上我尝试了相同的程序,其中包含一个没有任何面孔的视频,它仍然显示矩形。我没有意识到这实际上可能是最小的矩形大小。

标签: matlab image-processing computer-vision face-detection matlab-cvst


【解决方案1】:

您可以使用vision.CascadeObjectDetector 对象来检测任何特定帧中的人脸。如果它没有检测到任何人脸,它的step 方法将返回一个空数组。问题是人脸检测算法并不完美。有时它会检测到误报,即。 e.检测没有人脸的人脸。您可以尝试减轻我设置 MinSizeMaxSize 属性的影响,假设您知道您希望找到的面孔大小。

【讨论】:

    猜你喜欢
    • 2019-04-26
    • 1970-01-01
    • 2022-07-18
    • 1970-01-01
    • 2014-04-12
    • 2016-02-25
    • 2016-08-09
    • 2015-10-12
    • 2014-01-13
    相关资源
    最近更新 更多