[OpenCV] Background subtraction
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的更多相关文章
- [OpenCV] Samples 15: Background Subtraction and Gaussian mixture models
不错的草稿.但进一步处理是必然的,也是难点所在. Extended: 固定摄像头,采用Gaussian mixture models对背景建模. OpenCV 中实现了两个版本的高斯混合背景/前景分割 ...
- 【计算机视觉】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 ...
- [OpenCV] Samples 13: opencv_version
cv::CommandLineParser的使用. I suppose CommandLineParser::has("something") should be true whe ...
- 利用opencv进行移动物体检测
进行运动物体检测就是将动态的前景从静态的背景中分离出来.将当前画面与假设是静态背景进行比较发现有明显的变化的区域,就可以认为该区域出现移动的物体.在实际情况中由于光照阴影等因素干扰比较大,通过像素直接 ...
- OpenCV 2.4.9 学习笔记(1)—— 基本功能结构
一些关于OpenCV(2.4.9版本)的学习笔记,作为记录,以免自己忘了. 安装与配置 OpenCV的下载.安装以及在各个平台(Windows/Linux等)配置网上有很多的资料,自己就不用存了.需要 ...
- 开源软硬一体OpenCV AI Kit(OAK)
开源软硬一体OpenCV AI Kit(OAK) OpenCV 涵盖图像处理和计算机视觉方面的很多通用算法,是非常有力的研究工具之一,且稳居开发者最喜爱的 AI 工具/框架榜首. 1.会不会被USA禁 ...
- ViBe(Visual Background extractor)背景建模或前景检测
ViBe算法:ViBe - a powerful technique for background detection and subtraction in video sequences 算法官网: ...
- 目标检测之vibe---ViBe(Visual Background extractor)背景建模或前景检测
ViBe算法:ViBe - a powerful technique for background detection and subtraction in video sequences 算法官网: ...
- [Python] python vs cplusplus
一些学习过程中的总结的两种语言的小对比,帮助理解OO programming. Continue... 字典 序列 --> 字典 Python: def get_counts(sequence) ...
随机推荐
- 异常处理_Maven多模块web项目整合ssm+dubbo
异常如下: [ERROR][org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader. ...
- HDU--洗衣服
洗衣服 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- JS 的事件委托机制
以前写上图所示的鼠标点击触发事件,一般都是用如下所示的给每一个表示列表的标签绑定一个click事件(演示用的例子的框架是React): 毫无疑问,这样是比较繁琐的,以后维护修改改个函数名什么的还不方便 ...
- git学习笔记一
一.概念理解 1.理解工作区和暂存区以及版本库 工作区我理解就是我们创建的程序所在的文件夹,比如test文件夹.其中有个.git文件,这个就是版本库,其中版本库中有个区域叫暂存区或叫索引. 截自廖雪峰 ...
- MySQL修改root密码的多种方法
不知道在cmd模式下是不是区分大小写,我大写成功了,小写没成功,不知是我拼写的错误,还是区分大小写!!?? 方法1: 用SET PASSWORD命令 mysql -u root mysql> S ...
- python 根据现有文件树创建文件树
# -*- coding: utf-8 -*- import os, errno def fileName(path):#获取文件夹 str = '' for i in range(1,len(pat ...
- android-plugmgr源代码分析
android-plugmgr是一个Android插件加载框架,它最大的特点就是对插件不需要进行任何约束.关于这个类库的介绍见作者博客,市面上也有一些插件加载框架,但是感觉没有这个好.在这篇文章中,我 ...
- 安装 mysql-5.7.5-m15-winx64
win7 64位下如何安装配置mysql-5.7.5-m15-winx64 距离上次安装MySQL已经过去好久了.步骤这些,有可能会忘记.简单记录一下吧.(参考了一些网络上的博客.) 1.mysql- ...
- 再探.NET的PE文件结构(安全篇)
一.开篇 首先写在前面,这篇文章源于个人的研究和探索,由于.NET有自己的反射机制,可以清楚的将源码反射出来,这样你的软件就很容易被破解,当然这篇文章不会说怎么样保护你的软件不被破解,相反是借用一个软 ...
- 浅析MSIL中间语言——PE文件结构篇
一.开篇 开篇我想讲一下于本文无关的话题,其实我很想美化一下自己博客园一直没时间弄,无意间找了博客园李宝亨的博客园里面有一篇分享自己主题的文章,我就将这个模板暂时用作我的blog主题,我要讲述一个关于 ...