2016-07-22 23 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