【问题标题】:video face detection using dlib使用 dlib 进行视频人脸检测
【发布时间】:2016-07-16 22:53:05
【问题描述】:

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

下面是代码sn-p

// 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();
    }

【问题讨论】:

    标签: c++ video face-detection dlib


    【解决方案1】:

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

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

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

    你应该只改变

    cv::VideoCapture cap(0);
    

    进入

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

    【讨论】:

      【解决方案2】:

      如果您的帧很大,那么检测速度会很慢。因此,最好调整帧大小,然后执行跟踪/检测过程。

      【讨论】:

        猜你喜欢
        • 2021-03-22
        • 2017-06-01
        • 2017-10-11
        • 2017-12-24
        • 2017-07-19
        • 2016-08-09
        • 2018-06-09
        • 2017-01-18
        • 2017-10-18
        相关资源
        最近更新 更多