cv::CommandLineParser的使用。

I suppose CommandLineParser::has("something") should be true when the command line has --something in it.

./a.out -h
./a.out --help

打印keys的相关内容。

#include <opencv2/core/utility.hpp>
#include <iostream> using namespace std; const char* keys =
{
"{ b build | | print complete build info }"
"{ h help | | print this help }"
}; int main(int argc, const char* argv[])
{
cv::CommandLineParser parser(argc, argv, keys); if (parser.has("help"))
{
parser.printMessage();
}
else if (!parser.check())
{
parser.printErrors();
}
else if (parser.has("build"))
{
std::cout << cv::getBuildInformation() << std::endl;
}
else
{
std::cout << "Welcome to OpenCV " << CV_VERSION << std::endl;
} return 0;
}

  

一个更好的例子

For example, define:

String keys = "{N count||}";

Call:

  $ ./my-app -N=
# or
$ ./my-app --count=20 // 注意等号的应用

Keys赋值:

const string keys =
"{help h usage ? | | print this message }"
"{@image1 | | image1 for compare }"
"{@image2 |<none>| image2 for compare }"
"{@repeat |1 | number }"
"{path |/home/unsw | path to file }"
"{fps | -1.0 | fps for output video }"
"{N count |100 | count of objects }"
"{ts timestamp | | use time stamp }"
;

如此解析:

    cv::CommandLineParser parser(argc, argv, keys);
parser.about("Application name v1.0.0");
if (parser.has("help"))
{
parser.printMessage();
return ;
}
int N = parser.get<int>("N");
cout << "N = " << N << endl;
double fps = parser.get<double>("fps");
string path = parser.get<string>("path");
cout << "path: " << path << endl;
time_t use_time_stamp = parser.has("timestamp");
string img1 = parser.get<string>();
cout << "img1: " << img1 << endl;
string img2 = parser.get<string>();
cout << "img2: " << img2 << endl;
int repeat = parser.get<int>();
cout << "repeat: " << repeat << endl;
if (!parser.check())
{
parser.printErrors();
return ;
}

运行结果:

没毛病!

[OpenCV] Background subtraction的更多相关文章

  1. [OpenCV] Samples 15: Background Subtraction and Gaussian mixture models

    不错的草稿.但进一步处理是必然的,也是难点所在. Extended: 固定摄像头,采用Gaussian mixture models对背景建模. OpenCV 中实现了两个版本的高斯混合背景/前景分割 ...

  2. 【计算机视觉】ViBe - a powerful technique for background detection and subtraction in video sequences

    转自:http://blog.csdn.net/stellar0/article/details/8777283 作者:星zai ViBe算法:ViBe - a powerful technique ...

  3. [OpenCV] Samples 13: opencv_version

    cv::CommandLineParser的使用. I suppose CommandLineParser::has("something") should be true whe ...

  4. 利用opencv进行移动物体检测

    进行运动物体检测就是将动态的前景从静态的背景中分离出来.将当前画面与假设是静态背景进行比较发现有明显的变化的区域,就可以认为该区域出现移动的物体.在实际情况中由于光照阴影等因素干扰比较大,通过像素直接 ...

  5. OpenCV 2.4.9 学习笔记(1)—— 基本功能结构

    一些关于OpenCV(2.4.9版本)的学习笔记,作为记录,以免自己忘了. 安装与配置 OpenCV的下载.安装以及在各个平台(Windows/Linux等)配置网上有很多的资料,自己就不用存了.需要 ...

  6. 开源软硬一体OpenCV AI Kit(OAK)

    开源软硬一体OpenCV AI Kit(OAK) OpenCV 涵盖图像处理和计算机视觉方面的很多通用算法,是非常有力的研究工具之一,且稳居开发者最喜爱的 AI 工具/框架榜首. 1.会不会被USA禁 ...

  7. ViBe(Visual Background extractor)背景建模或前景检测

    ViBe算法:ViBe - a powerful technique for background detection and subtraction in video sequences 算法官网: ...

  8. 目标检测之vibe---ViBe(Visual Background extractor)背景建模或前景检测

    ViBe算法:ViBe - a powerful technique for background detection and subtraction in video sequences 算法官网: ...

  9. [Python] python vs cplusplus

    一些学习过程中的总结的两种语言的小对比,帮助理解OO programming. Continue... 字典 序列 --> 字典 Python: def get_counts(sequence) ...

随机推荐

  1. MySql UDF 调用外部程序和系统命令

    1.mysql利用mysqludf的一个mysql插件可以实现调用外部程序和系统命令 下载lib_mysqludf_sys程序:https://github.com/mysqludf/lib_mysq ...

  2. PHP定界符使用技巧

    为什么要使用定界符 : 因为PHP是一个Web编程语言,在编程过程中难免会遇到用echo来输出大段的html和javascript脚本的情况,如果用传统的输出方法——按字符串输出的话,肯定要有大量的转 ...

  3. win10调用局域网内xp系统上的打印机

    首先在xp系统上配置允许远程连接,然后设置账户密码,最后配置打印机,允许共享. 打开自己win10 ,win+R ,输入\\目标电脑ip\打印机名,确定,输入账户,密码. win+X - P-进入控制 ...

  4. windows上面捕获声卡数据

    转自:http://shanewfx.github.io/blog/2013/08/14/caprure-audio-on-windows/ 前一段时间接到一个任务,需要采集到声卡的输出信号,以便与麦 ...

  5. 关于c++的 vector 容器的使用及创建方法

    1.vector向量容器的使用,vector具有自动管理的功能,可以进行元素的查找删除 创建方法: (1)  vector<int > v; 创建了一个v的容器,没指定容量: (2)  v ...

  6. 【腾讯Bugly干货分享】微信mars 的高性能日志模块 xlog

    本文来自于腾讯bugly开发者社区,未经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/581c2c46bef1702a2db3ae53 Dev Club 是一个交流移动 ...

  7. Hadoop学习笔记—6.Hadoop Eclipse插件的使用

    开篇:Hadoop是一个强大的并行软件开发框架,它可以让任务在分布式集群上并行处理,从而提高执行效率.但是,它也有一些缺点,如编码.调试Hadoop程序的难度较大,这样的缺点直接导致开发人员入门门槛高 ...

  8. iTextSharp 116秒处理6G的文件

    前言: 有一家印刷企业专为米兰新娘,微微新娘,金夫人这样的影楼印刷婚纱相册.通过一个B2B销售终端软件,把影楼的相片上传到印刷公司的服务器,服务器对这些图片进行处理. 比如: 1)为每个图片生成订单条 ...

  9. Hibernate的三种状态及对象生命周期

        理解Hibernate的三种状态,更利于理解Hibernate的运行机制,这些可以让你在开发中对疑点问题的定位产生关键性的帮助. 三种状态 临时状态(Transient):在通过new关键字, ...

  10. 我的LESS编译方案

    背景 近期项目前端决定使用less,简单介绍一下,详细信息有兴趣查看官方文档(http://www.lesscss.net/article/home.html) LESSCSS是一种动态样式语言,属于 ...