【问题标题】:How to split cascades levels in dlib frontal face detector?如何在 dlib 正面人脸检测器中拆分级联级别?
【发布时间】:2016-07-25 22:39:47
【问题描述】:

跟进:openface/issue/157

我正在尝试将 dlib 正面人脸检测器中的五级级联拆分为三级(正面、正面但向左旋转和正面但向右旋转)

Evgeniy 建议在 C++ 中拆分检测器。我不熟悉C++。当我查看frontal_face_detector.h 时,get_serialized_frontal_faces 返回一个 base64 编码对象。

我学习了如何将现有检测器保存到 .svm 文件中:

#include <dlib/image_processing/frontal_face_detector.h>
#include <iostream>

using namespace dlib;
using namespace std;

int main()
{   
    frontal_face_detector detector = get_frontal_face_detector(); 

    dlib::serialize("new_detector.svm") << detector;  

    std::cout<<"End of the Program"<<endl;
    return 0;   
}

那么如何拆分级联并将新检测器保存到.svm 文件中?

还可以通过将金字塔级别从 降低到frontal_face_detector.h 中的较低值来提高检测器性能吗?

【问题讨论】:

    标签: c++ dlib


    【解决方案1】:

    只需阅读object detector documentation,您就会找到解释。 这是将检测器分成几部分,重建原始并限制金字塔级别的代码:

    #include <dlib/image_processing/frontal_face_detector.h>
    #include <iostream>
    #include <string>
    
    using namespace dlib;
    using namespace std;
    
    int main()
    {   
        frontal_face_detector detector = get_frontal_face_detector(); 
    
        dlib::serialize("current.svm") << detector;
    
        std::vector<frontal_face_detector> parts;
        // Split into parts and serialize to disk
        for (unsigned long i = 0; i < detector.num_detectors(); ++i)
        {
            dlib::frontal_face_detector part(detector.get_scanner(), detector.get_overlap_tester(), detector.get_w(i));
            dlib::serialize("part" + std::to_string(i) + ".svm") << part;
            parts.push_back(part);
        }
    
        // Reconstruct original detector
        frontal_face_detector reconstructed(parts);
        dlib::serialize("reconstructed.svm") << reconstructed;
    
        // Create detector that will work only on one level of pyramid
        typedef dlib::scan_fhog_pyramid<dlib::pyramid_down<6> > image_scanner_type;
        image_scanner_type scanner;
        scanner.copy_configuration(detector.get_scanner());
        scanner.set_max_pyramid_levels(1); //try setting to 2, 3...
        frontal_face_detector one_level_detector = dlib::object_detector<image_scanner_type>(scanner, detector.get_overlap_tester(), detector.get_w());
    
        std::cout<<"End of the Program"<<endl;
        return 0;   
    }
    

    不,将金字塔等级从 更改为任何其他值都没有多大帮助,因为 6 不是金字塔等级的限制,而是金字塔中比例的比例:

    6 = 5/6

    5 = 4/5

    ...

    【讨论】:

    • 谢谢。那行得通。如果我错了,请纠正我: 1. 根据这个comment,part - 0 是前视,part - 2 是左视,part - 3 是右视,依此类推。 2.如果我只想左看右看,我需要将part 1和part 2推回parts vector并重建它。
    • 另外,默认正面人脸检测器中的 max_pyramid_levels 是多少?对我来说 set_max_pyramid_levels(8) 为small face 和相对large face 工作。
    • @vijayenthiransubramaniam,我记得,它是无限的(1000 左右)
    猜你喜欢
    • 2017-01-18
    • 2016-10-26
    • 2013-10-23
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 2015-11-01
    • 2011-05-25
    相关资源
    最近更新 更多