首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何分割dlib正面探测器的级联级?

如何分割dlib正面探测器的级联级?
EN

Stack Overflow用户
提问于 2016-07-22 11:11:41
回答 1查看 1.9K关注 0票数 2

跟进:开篇/第157期

我正试图将dlib正面检测器中的五层梯级分解为三层(前、前看但左转,前看但右转一)。

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

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

代码语言:javascript
复制
#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文件中呢?

此外,通过将金字塔级别从<6>降低到detector.h中的较低值,检测器的性能会提高吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-22 13:41:31

只要读一读目标检测器文档,你就能找到解释。下面的代码将检测器分成几个部分,重建原始的金字塔级和限制金字塔级别:

代码语言:javascript
复制
#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不是金字塔级别的限制,而是金字塔中比例的比例:

6= 5/6

5= 4/5

..。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38525007

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档