我试图将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降低到6,检测器性能也会提高。 frontal_face_detector.h中的较低值?
答案 0 :(得分:6)
请阅读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;
}
并且否,将金字塔等级从&lt; 6&gt;改变。任何其他值都没有多大帮助,因为 6 不是金字塔等级的限制,而是它在金字塔中的比例:
6 = 5/6
5 = 4/5
...