c++ - 使用 dlib 进行视频人脸检测

标签 c++ video face-detection dlib

我正在尝试制作一个离线视频人脸检测程序。我已经使用示例代码进行人脸检测,效果很好。但是由于 dlib 库不能直接在视频上工作(或者我不知道它是否可以),我正在为图像人脸检测程序提供帧。对于 20-30 帧视频之类的小视频,它工作正常,但如果给定更大的视频,它就会出现缓冲区溢出错误。我是否必须明确删除数据或清除一些动态内存?还是它只处理很少的人脸检测图像?

下面是代码片段

// Loop over all the images provided on the command line.
    for (int i = 1; i <= 629; ++i)
    {
        //cout << "processing image " << endl;
        array2d<unsigned char> img;
        //load_image(img, argv[i]);
    sprintf(image, "./frame/frame%d.jpg",i);
    load_image(img, image);

        pyramid_up(img);

        // Now tell the face detector to give us a list of bounding boxes
        // around all the faces it can find in the image.
        std::vector<rectangle> dets = detector(img);

        //cout << "Number of faces detected: " << dets.size() << endl;
    //cout<<i<<"\t"<<dets.size()<<endl;
        // Now we show the image on the screen and the face detections as
        // red overlay boxes.
        win.clear_overlay();
        win.set_image(img);
        win.add_overlay(dets, rgb_pixel(255,0,0));

        //cout << "Hit enter to process the next image..." << endl;
        //cin.get();
    }

最佳答案

Dlib 有一个 OpenCV 集成。您可以使用OpenCV函数读取视频文件并使用Dlib进行人脸检测

这是一个关于这种集成的示例

http://dlib.net/webcam_face_pose_ex.cpp.html

你应该只改变

cv::VideoCapture cap(0);

进入

cv::VideoCapture videoCapture;
videoCapture.open(fileName);

关于c++ - 使用 dlib 进行视频人脸检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36283368/

相关文章:

c++ - 从 open cv 中的图像序列创建视频

Python - 无法检测面部和眼睛?

c++ - 当画面中没有人脸时,OpenCV 中的人脸检测器变慢

c++ - MPI_Waitall 实际上是如何工作的

c++ - C++ 和 Mathematica 之间的 IPC?

html - 用于触摸屏的带有图像回退的背景视频

Android FaceDetector.Face Euler 角度一直为0

c++ - 不确定 Typedef 和类的位置

c++ - QProgressDialog 在暂停期间不绘制

javascript - 如何显示其他网站的视频内容