2016-07-22 22 views
1

追问:openface/issue/157如何在dlib正面人脸检测器中分割级联级别?

我试图在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

通过将金字塔等级从< 6>降低到frontal_face_detector.h的较低值,探测器性能也会提高?

回答

5

刚刚阅读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; 
} 

和NO,改变从< 6金字塔等级>为任何其他值不会有太大的帮助,因为是金字塔等级没有限制,但其在金字塔的尺度比例:

6 = 5/6

5 = 4/5

...

+0

谢谢。这工作。 纠正我,如果我错了: 1.根据这[评论](https://github.com/davisking/dlib/blob/master/dlib/image_processing/frontal_face_detector.h#L29),部分-0是前看,第二部分是留着看,第三部分是正确的看,等等。 2.如果我只想左看右看,我需要将第1部分和第2部分推回到零件向量并重构它。 –

+0

另外,什么是默认的正面人脸检测器中的max_pyramid_levels?对我来说,set_max_pyramid_levels(8)适用于[小脸](https://github.com/cmusatyalab/openface/blob/master/images/examples/clapton-2.jpg)和比较[大脸](https:// github.com/cmusatyalab/openface/blob/master/images/examples/lennon-2.jpg)。 –

+0

@vijayenthiransubramaniam,据我所知,它是无限的(1000左右) – Evgeniy