本文整理汇总了C++中cv::Ptr::load方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::load方法的具体用法?C++ Ptr::load怎么用?C++ Ptr::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv::Ptr
的用法示例。
在下文中一共展示了Ptr::load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
void load( std::string model_path )
{
eigenfaceRecognizor->load( model_path + "/eigenface.xml");
fisherfaceRecognizor->load( model_path + "/fisherface.xml");
LBPHRecognizor->load( model_path + "/LBPH.xml");
}
示例2: main
int main(int argc, char **argv)
{
bool try_flip = false;
std::string scale_param = "--scale=";
size_t scale_param_length = scale_param.length();
std::string cascade_param = "--cascade=";
size_t cascade_param_length = cascade_param.length();
std::string nested_cascade_param = "--nested-cascade=";
size_t nested_cascade_param_length = nested_cascade_param.length();
std::string try_flip_param = "--try-flip=";
size_t try_flip_param_length = try_flip_param.length();
std::string name_input;
double scale = 1.0;
cv::Mat frame;
cv::Mat frame_copy;
cv::Mat image;
cv::CascadeClassifier cascade;
cv::CascadeClassifier nested_cascade;
CvCapture *capture = 0;
g_face_recognition.getUseHelp();
// Load trained model.
g_model = cv::createLBPHFaceRecognizer();
g_model->load(g_save_model_path);
std::cout << "*************************" << std::endl
<< " Load model finished " << std::endl
<< "*************************" << std::endl
<< std::endl;
// Load command line parameters.
for (int i = 1; i < argc; i++) {
std::cout << "Processing " << i << " " << argv[i] << std::endl;
if (cascade_param.compare(0,
cascade_param_length,
argv[i],
cascade_param_length) == 0) {
g_name_cascade.assign(argv[i] + cascade_param_length);
std::cout << "Cascade name: " << g_name_cascade
<< std::endl;
}
else if (nested_cascade_param.compare(0,
nested_cascade_param_length,
argv[i],
nested_cascade_param_length) == 0) {
if (argv[i][nested_cascade_param.length()] == '=') {
g_name_nested_cascade.assign(argv[i] +
nested_cascade_param.length() + 1);
}
if (!nested_cascade.load(g_name_nested_cascade)) {
std::cerr << "Load nested cascade classifier failed!"
<< std::endl;
}
}
else if (scale_param.compare(0,
scale_param_length,
argv[i],
scale_param_length) == 0) {
if(!sscanf(argv[i] + scale_param.length(), "%lf", &scale) ||
scale < 1) {
scale = 1;
}
std::cout << "Scale: " << scale << std::endl;
}
else if (try_flip_param.compare(0,
try_flip_param_length,
argv[i],
try_flip_param_length) == 0) {
try_flip = true;
std::cout << " Try to flip image horizontally."
<< std::endl;
}
else if (argv[i][0] == '-') {
std::cerr << "Unknown option %s" << argv[i] << std::endl;
}
else {
name_input.assign(argv[i]);
}
}
if (!cascade.load(g_name_cascade)) {
std::cerr << "Load cascade classifier failed!" << std::endl;
g_face_recognition.getUseHelp();
return -1;
}
if (name_input.empty() || (isdigit(name_input.c_str()[0]) &&
name_input.c_str()[1]) == '\0') {
capture = cvCaptureFromCAM(name_input.empty() ? 0 :
name_input.c_str()[0] - '0');
int camera = name_input.empty() ? 0 : name_input.c_str()[0] - '0';
if (!capture) {
std::cerr << "Capture from CAM " << camera << "doesn't work!"
<< std::endl;
}
}
else if (name_input.size()) {
image = cv::imread(name_input, 1);
if (image.empty()) {
//.........这里部分代码省略.........