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. SQL Server 里的递归查询

    http://www.360doc.com/content/13/0607/11/8463843_291221684.shtml

  2. 【转】angular指令入坑

    独立作用域和函数参数 通过使用本地作用域属性,你可以传递一个外部的函数参数(如定义在控制器$scope中的函数)到指令.这些使用&就可以完成.下面是一个例子,定义一个叫做add的本地作用域属性 ...

  3. MySQL流程函数

    #如果value是真,返回t:否则返回f if(value,t f) #如果value1不为空,返回value1,否则返回value2 ifnull(value1,value2) #如果value1是 ...

  4. 启动项目的时候报驱动错误: not support oracle driver 1.0

    问题:今天在使用pom导入oracle14的包时候发现怎么都下载不过来.网上查了一下发现是因为Oracle驱动需要官方授权,所以在pom.xml文件直接配置,无法下载成功. 解决方法就是下载oracl ...

  5. Page

    <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> <met ...

  6. Oracle入门

    一.Oracle数据库简介 Oracle数据库的主要特点 :支持多用户.大事务量的事务处理:数据安全性和完整性控制:支持分布式数据处理:可移植性. Oracle数据库基于客户端/服务器技术:数据库服务 ...

  7. error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory

    zabbix3.2启动有如下报错: # service zabbix_server startStarting zabbix_server:  /home/zabbix-server/sbin/zab ...

  8. 关于ubuntu16.04中mysql root登陆不了的情况下(大多是未设置密码的情况)

    1.先将当前用户改成 root用户:sudo su 2.进入安装路径,我的是:cd /etc/mysql/ 3.打开debian.cnf : gedit debian.cnf 4.找到:user pa ...

  9. winform设置文本框宽度 根据文字数量和字体返回宽度

    _LinkLabel.Width = TextRenderer.MeasureText(_LinkLabel.Text, _LinkLabel.Font).Width;

  10. Expert 诊断优化系列------------------冤枉磁盘了

    现在很多用户被数据库的慢的问题所困扰,又苦于花钱请一个专业的DBA成本太高.软件维护人员对数据库的了解又不是那么深入,所以导致问题迟迟不能解决,或只能暂时解决不能得到根治.开发人员解决数据问题基本又是 ...