1.首先需要安装gflags

sudo apt-get install gflags

2.自定义glags标志(customflags.hpp)

/*
// Copyright (c) 2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*////
#pragma once#include <string>
#include <cstdlib>
#include <vector>
#include <gflags/gflags.h>
#include <iostream>#ifdef _WIN32
#include <os/windows/w_dirent.h>
#else
#include <dirent.h>
#endifstd::string GetEnv( const std::string & var ) {const char * val = std::getenv( var.c_str() );if ( val == 0 ) {return "";}else {return val;}
}const std::string DEFAULT_PATH = GetEnv("INTEL_CVSDK_DIR");/// @brief message for help argument
static const char help_message[] = "Print a usage message.";/// @brief message for images argument
static const char video_message[] = "Optional. Path to an video file. Default value is \"cam\" to work with camera.";/// @brief message for model argument
static const char face_detection_model_message[] = "Required. Path to an .xml file with a trained face detection model.";
static const char age_gender_model_message[] = "Optional. Path to an .xml file with a trained age gender model.";
static const char head_pose_model_message[] = "Optional. Path to an .xml file with a trained head pose model.";
static const char emotions_model_message[] = "Optional. Path to an .xml file with a trained emotions model.";
static const char facial_landmarks_model_message[] = "Optional. Path to an .xml file with a trained facial landmarks model.";/// @brief message for plugin argument
static const char plugin_message[] = "Plugin name. For example MKLDNNPlugin. If this parameter is pointed, " \
"the demo will look for this plugin only.";/// @brief message for assigning face detection calculation to device
static const char target_device_message[] = "Specify the target device for Face Detection (CPU, GPU, FPGA, or MYRIAD). " \
"The demo will look for a suitable plugin for a specified device.";/// @brief message for assigning age gender calculation to device
static const char target_device_message_ag[] = "Specify the target device for Age Gender Detection (CPU, GPU, FPGA, or MYRIAD). " \
"The demo will look for a suitable plugin for a specified device.";/// @brief message for assigning head pose calculation to device
static const char target_device_message_hp[] = "Specify the target device for Head Pose Detection (CPU, GPU, FPGA, or MYRIAD). " \
"The demo will look for a suitable plugin for a specified device.";/// @brief message for assigning emotions calculation to device
static const char target_device_message_em[] = "Specify the target device for Emotions Detection (CPU, GPU, FPGA, or MYRIAD). " \
"The demo will look for a suitable plugin for a specified device.";/// @brief message for assigning facial landmarks calculation to device
static const char target_device_message_lm[] = "Specify the target device for Facial Landmarks Detection (CPU, GPU, FPGA, or MYRIAD). " \
"The demo will look for a suitable plugin for device specified.";/// @brief message for the maximum number of simultaneously processed faces for Age Gender net
static const char num_batch_ag_message[] = "Specify number of maximum simultaneously processed faces for Age Gender Detection (default is 16).";/// @brief message for the maximum number of simultaneously processed faces for Head Pose net
static const char num_batch_hp_message[] = "Specify number of maximum simultaneously processed faces for Head Pose Detection (default is 16).";/// @brief message for the maximum number of simultaneously processed faces for Emotions net
static const char num_batch_em_message[] = "Specify number of maximum simultaneously processed faces for Emotions Detection (default is 16).";/// @brief message for the maximum number of simultaneously processed faces for Facial Landmarks net
static const char num_batch_lm_message[] = "Specify number of maximum simultaneously processed faces for Facial Landmarks Detection (default is 16).";/// @brief message for dynamic batching support for AgeGender net
static const char dyn_batch_ag_message[] = "Enable dynamic batch size for AgeGender net.";/// @brief message for dynamic batching support for HeadPose net
static const char dyn_batch_hp_message[] = "Enable dynamic batch size for HeadPose net.";/// @brief message for dynamic batching support for Emotions net
static const char dyn_batch_em_message[] = "Enable dynamic batch size for Emotions net.";/// @brief message for dynamic batching support for Facial Landmarks net
static const char dyn_batch_lm_message[] = "Enable dynamic batch size for Facial Landmarks net.";/// @brief message for performance counters
static const char performance_counter_message[] = "Enables per-layer performance report.";/// @brief message for clDNN custom kernels desc
static const char custom_cldnn_message[] = "Required for clDNN (GPU)-targeted custom kernels. "\
"Absolute path to the xml file with the kernels desc.";/// @brief message for user library argument
static const char custom_cpu_library_message[] = "Required for MKLDNN (CPU)-targeted custom layers. " \
"Absolute path to a shared library with the kernels impl.";/// @brief message for probability threshold argument
static const char thresh_output_message[] = "Probability threshold for detections.";/// @brief message raw output flag
static const char raw_output_message[] = "Inference results as raw values.";/// @brief message no wait for keypress after input stream completed
static const char no_wait_for_keypress_message[] = "No wait for key press in the end.";/// @brief message no show processed video
static const char no_show_processed_video[] = "No show processed video.";/// @brief message for driver recognition mode
static const char drecog_message[] = "Enable driver recognition mode";/// @brief message for asynchronous mode
static const char async_message[] = "Enable asynchronous mode";// dlib facial landmarks detection
static const char dlib_lm_message[] = "Enable dlib's facial landmark detections";// camera cover detection
static const char cover_message[] = "Enable camera cover detection";/// \brief Define flag for showing help message <br>
DEFINE_bool(h, false, help_message);/// \brief Define parameter for set image file <br>
/// It is a required parameter
DEFINE_string(i, "cam", video_message);/// \brief Define parameter for face detection model file <br>
/// It is a required parameter
DEFINE_string(m, "", face_detection_model_message);/// \brief Define parameter for face detection  model file <br>
/// It is a required parameter
DEFINE_string(m_ag, "", age_gender_model_message);/// \brief Define parameter for face detection  model file <br>
/// It is a required parameter
DEFINE_string(m_hp, "", head_pose_model_message);/// \brief Define parameter for face detection model file <br>
/// It is a required parameter
DEFINE_string(m_em, "", emotions_model_message);/// \brief Define parameter for facial landmarks detection model file <br>
/// It is an optional parameter
std::string fp_lm = (INTEL_CVSDK_VER <= 5 ? DEFAULT_PATH + std::string("/deployment_tools/intel_models/landmarks-regression-retail-0009/FP32/landmarks-regression-retail-0009.xml") : DEFAULT_PATH + std::string("/deployment_tools/tools/model_downloader/Retail/object_attributes/landmarks_regression/0009/dldt/landmarks-regression-retail-0009.xml"));
DEFINE_string(m_lm, fp_lm, facial_landmarks_model_message);/// \brief Define parameter for facial landmarks detection model file <br>
/// It is an optional parameterstd::string fp_reid = ((INTEL_CVSDK_VER == 5) ? DEFAULT_PATH + std::string("/deployment_tools/intel_models/face-reidentification-retail-0095/FP32/face-reidentification-retail-0095.xml") : (INTEL_CVSDK_VER == 4 ) ? DEFAULT_PATH + std::string("/deployment_tools/intel_models/face-reidentification-retail-0071/FP32/face-reidentification-retail-0071.xml") : DEFAULT_PATH + std::string("/deployment_tools/tools/model_downloader/Retail/object_reidentification/face/mobilenet_based/dldt/face-reidentification-retail-0095.xml"));
DEFINE_string(m_reid, fp_reid, facial_landmarks_model_message);/// \brief target device for face detection <br>
DEFINE_string(d, "CPU", target_device_message);/// \brief target device for AgeGender net <br>
DEFINE_string(d_ag, "CPU", target_device_message_ag);/// \brief target device for HeadPose net <br>
DEFINE_string(d_hp, "CPU", target_device_message_hp);/// \brief target device for Emotions net <br>
DEFINE_string(d_em, "CPU", target_device_message_em);/// \brief target device for Facial Landmarks net <br>
DEFINE_string(d_lm, "CPU", target_device_message_lm);/// \brief target device for Facial Landmarks net <br>
DEFINE_string(d_reid, "CPU", target_device_message_lm);/// \brief maximum batch size for AgeGender net <br>
DEFINE_uint32(n_ag, 16, num_batch_ag_message);/// \brief enable dynamic batch size for AgeGender net <br>
DEFINE_bool(dyn_ag, false, dyn_batch_ag_message);/// \brief maximum batch size for HeadPose net <br>
DEFINE_uint32(n_hp, 16, num_batch_hp_message);/// \brief enable dynamic batch size for HeadPose net <br>
DEFINE_bool(dyn_hp, false, dyn_batch_hp_message);/// \brief maximum batch size for Emotions net <br>
DEFINE_uint32(n_em, 16, num_batch_em_message);/// \brief enable dynamic batch size for Emotions net <br>
DEFINE_bool(dyn_em, false, dyn_batch_em_message);/// \brief maximum batch size for Facial Landmarks net <br>
DEFINE_uint32(n_lm, 16, num_batch_em_message);/// \brief enable dynamic batch size for Facial Landmarks net <br>
DEFINE_bool(dyn_lm, false, dyn_batch_em_message);/// \brief enable per-layer performance report <br>
DEFINE_bool(pc, false, performance_counter_message);/// @brief clDNN custom kernels path <br>
/// Default is ./lib
DEFINE_string(c, "", custom_cldnn_message);/// @brief Absolute path to CPU library with user layers <br>
/// It is a optional parameter
DEFINE_string(l, "", custom_cpu_library_message);/// \brief Flag to output raw scoring results<br>
/// It is an optional parameter
DEFINE_bool(r, false, raw_output_message);/// \brief Flag to output raw scoring results<br>
/// It is an optional parameter
DEFINE_double(t, 0.5, thresh_output_message);/// \brief Flag to disable keypress exit<br>
/// It is an optional parameter
DEFINE_bool(no_wait, false, no_wait_for_keypress_message);/// \brief Flag to disable processed video showing<br>
/// It is an optional parameter
DEFINE_bool(no_show, false, no_show_processed_video);/// \brief Flag to enable driver recognition from database
/// It is an optional parameter
DEFINE_bool(d_recognition, false, drecog_message);/// \brief Flag to enable aynchronous execution<br>
/// It is an optional parameter
DEFINE_bool(async, false, async_message);///CustomDEFINE_bool(dlib_lm, false, "Acti");DEFINE_string(fg, "", "Path to gallery");DEFINE_bool(cover, false, "Acti");/**
* \brief This function shows a help message
*/static void showUsage() {std::cout << std::endl;std::cout << "interactive_face_detection [OPTION]" << std::endl;std::cout << "Options:" << std::endl;std::cout << std::endl;std::cout << "    -h                         " << help_message << std::endl;std::cout << "    -i \"<path>\"                " << video_message << std::endl;std::cout << "    -m \"<path>\"                " << face_detection_model_message<< std::endl;std::cout << "    -m_ag \"<path>\"             " << age_gender_model_message << std::endl;std::cout << "    -m_hp \"<path>\"             " << head_pose_model_message << std::endl;std::cout << "    -m_em \"<path>\"             " << emotions_model_message << std::endl;std::cout << "    -m_lm \"<path>\"             " << facial_landmarks_model_message << std::endl;std::cout << "      -l \"<absolute_path>\"     " << custom_cpu_library_message << std::endl;std::cout << "          Or" << std::endl;std::cout << "      -c \"<absolute_path>\"     " << custom_cldnn_message << std::endl;std::cout << "    -d \"<device>\"              " << target_device_message << std::endl;std::cout << "    -d_ag \"<device>\"           " << target_device_message_ag << std::endl;std::cout << "    -d_hp \"<device>\"           " << target_device_message_hp << std::endl;std::cout << "    -d_em \"<device>\"           " << target_device_message_em << std::endl;std::cout << "    -d_lm \"<device>\"           " << target_device_message_lm << std::endl;std::cout << "    -n_ag \"<num>\"              " << num_batch_ag_message << std::endl;std::cout << "    -n_hp \"<num>\"              " << num_batch_hp_message << std::endl;std::cout << "    -n_em \"<num>\"              " << num_batch_em_message << std::endl;std::cout << "    -n_lm \"<num>\"              " << num_batch_lm_message << std::endl;std::cout << "    -dyn_ag                    " << dyn_batch_ag_message << std::endl;std::cout << "    -dyn_hp                    " << dyn_batch_hp_message << std::endl;std::cout << "    -dyn_em                    " << dyn_batch_em_message << std::endl;std::cout << "    -dyn_lm                    " << dyn_batch_lm_message << std::endl;std::cout << "    -dlib_lm                   " << dlib_lm_message << std::endl;std::cout << "    -async                     " << async_message << std::endl;std::cout << "    -no_wait                   " << no_wait_for_keypress_message << std::endl;std::cout << "    -no_show                   " << no_show_processed_video << std::endl;std::cout << "    -pc                        " << performance_counter_message << std::endl;std::cout << "    -r                         " << raw_output_message << std::endl;std::cout << "    -t                         " << thresh_output_message << std::endl;std::cout << "    -cover                     " << cover_message << std::endl;
}

3.最后在调用文件中,

#include "customflags.hpp"

引用相关变量时,需要加上 FLAGS_,比如以上定义的-cover,引用时为 FLAGS_cover

利用gflags自定义标志的使用方法相关推荐

  1. 第8.15节 Python重写自定义类的__repr__方法

    一. 引言 前面两节分别介绍了Python类中的__str__和__repr__方法的作用和语法,所有新式类都支持这两个方法,因为object类实现了这两个方法,但实际上各位开发者在自定义类的过程中, ...

  2. 利用 IHttpHandler 自定义 HTTP 处理程序

    本文内容 引入 IHttpHandler 概述 演示创建自定义 HTTP 处理程序 创建自定义 HTTP 处理程序 映射文件扩展名 测试自定义 HTTP 处理程序 参考资料 引入 当新建一个名为 We ...

  3. [WCF权限控制]利用WCF自定义授权模式提供当前Principal[实例篇]

    在<原理篇>中我们谈到:如果采用自定义安全主体权限模式,我们可以通过自定义AuthorizationPolicy或者ServiceAuthorizationManager实现对基于当前认证 ...

  4. ati自定义分辨率_真三国无双7游戏自定义分辨率的修改方法

    这是一个真三国无双7游戏自定义分辨率的修改方法介绍,一个非常详细的教程,玩家研究并且分享的,告诉玩家如何在游戏中修改自己需要的分辨率来迎合自己的本身的电脑,使游戏的画面效果达到最好,很实用的一个教程, ...

  5. QVariant类及QVariant与自定义数据类型转换的方法

    这个类型相当于是Java里面的Object,它把绝大多数Qt提供的数据类型都封装起来,起到一个数据类型"擦除"的作用.比如我们的 table单元格可以是string,也可以是int ...

  6. 利用文件头标志判断文件类型

    简介 我们都知道,文件的扩展名是用来识别文件类型的.通过给他指定扩展名,我们可以告诉自己,也告诉操作系统我们想用什么方式打开这个文件.比如我么会把.jpg的文件默认用图片显示软件打开,.zip 文件会 ...

  7. [WCF权限控制]利用WCF自定义授权模式提供当前Principal[原理篇]

    在<通过扩展自行实现服务授权>一文中,我通过自定义CallContextInitializer的方式在操作方法之前之前根据认证用户设置了当前线程的安全主体,从而实现授权的目的.实际上,WC ...

  8. java反射实现自定义json转对象方法-忽略字段大小写、字段个数

    java反射实现自定义json转对象方法-忽略字段大小写.字段个数 开发过程中经常会遇到json转对象,可以使用FastJson或者Gson自带的工具类进行转换,但当遇到json与对象属性名称大小写不 ...

  9. php车辆静电贴,怎样清除车窗玻璃上的贴纸 及汽车前挡标志静电贴使用方法

    很多车主的车辆前挡风玻璃因为贴了车辆年检标志,几年下来已经有点阻挡视线了,但因为车玻璃上贴有太阳膜,又不能用锐利的塑料铲铲除.但新标志又不能不贴.有没有比较方便的方法,改变车辆挡风玻璃大花脸? 这里推 ...

  10. 怎么用python找论文_如何利用Python绘制学术论文图表方法

    论文中图表形式多样,常用的处理工具有excel.MATLAB以及Python等,excel自处理的方法有两个缺陷: 1.当数据较多时,容易出现excel"翻白眼"的现象: 2.需要 ...

最新文章

  1. 在Ring3上实现文件碎甲(解锁)功能
  2. 数据库范式1NF 2NF 3NF BCNF
  3. CSS的Grid网格布局
  4. (BAE)jetty8+struts2导致 welcome-file-list 失效
  5. 【NLP】如何在文本分类任务中Fine-Tune BERT
  6. DataFormatString格式化字符串的总结
  7. pytorch中切换虚拟环境
  8. 林锐 高质量c语言编程下载,新年献礼:Go语言深度入门手册
  9. 人脸识别撞脸名画_范冰冰深夜晒自拍撞脸荷兰名画,三万元名牌包抢镜,两套餐具亮了...
  10. JSP页面处理和输出
  11. tcl之变量-简单变量
  12. 图书管理系统(大一C语言大作业 包含主要结构体,文件操作, 如数据的修改 查询 删除等)
  13. 三端食堂售饭管理系统
  14. springboot使用junit5/junit4
  15. CATIA怎么约束快捷键_CATIA快捷键设置详解
  16. 0基础能不能转行做网络安全?网络安全人才发展路线
  17. 微信小程序 断网异常处理
  18. 白领失眠危害大 如何拯救上班族?
  19. ES2015 Proxy 对比 defineProperty
  20. 深搜(不撞南墙不回头),迷宫问题

热门文章

  1. poi实现word转html并返回html内容(Java版)
  2. python 爬取地址的经度和纬度,并在地图画出散点图/热力图
  3. PPP项目群管理模式的实践探索——以浙江交工富阳PPP项目群为例
  4. 系列学习 Gateway 之第 5 篇 —— 搭建高可用网关(完结)
  5. Intellij idea 最新版永久破解
  6. 毕业设计 python图像检索系统设计与实现
  7. E盾网络验证企业版个人版离线版加密防破解易语言源码加密对接好的自绘界面3
  8. 某易易盾滑块流程加参数分析
  9. 中级软件设计师JAVA
  10. 鼠标连点器同时点多个位置_C++自制鼠标连点器