背景建模技术(四):视频分析(VideoAnalysis)模块
视频分析模块主要包含两个函数,一个是VideoAnalysis::setup(....),其主要功能就是确定测试的视频是视频文件或摄像头输入亦或是采用命令行参数;第二个函数是VideoAnalysis::start(),其主要功能初始化视频处理、设置视频获取方式以及开始视频捕获功能等。
1、VideoAnalysis::setup(....)
该函数的代码如下:
- bool VideoAnalysis::setup(int argc, const char **argv)
- {
- bool flag = false;
- const char* keys =
- "{hp|help|false|Print help message}"
- "{uf|use_file|false|Use video file}"
- "{fn|filename||Specify video file}"
- "{uc|use_cam|false|Use camera}"
- "{ca|camera|0|Specify camera index}"
- "{co|use_comp|false|Use mask comparator}"
- "{st|stopAt|0|Frame number to stop}"
- "{im|imgref||Specify image file}" ;
- cv::CommandLineParser cmd(argc, argv, keys);
- ////////////use_command
- if (argc <= 1 || cmd.get<bool>("help") == true)
- {
- cout << "Usage: " << argv[0] << " [options]" << endl;
- cout << "Avaible options:" << endl;
- cmd.printParams();
- return false;
- }
- ////////////use_file
- use_file = cmd.get<bool>("use_file");
- if (use_file)
- {
- filename = cmd.get<string>("filename");
- if (filename.empty())
- {
- cout << "Specify filename" << endl;
- return false;
- }
- flag = true;
- }
- ////////////use_camera
- use_camera = cmd.get<bool>("use_cam");
- if (use_camera)
- {
- cameraIndex = cmd.get<int>("camera");
- flag = true;
- }
- ////////////use_comp
- if (flag == true)
- {
- use_comp = cmd.get<bool>("use_comp");
- if (use_comp)
- {
- frameToStop = cmd.get<int>("stopAt");
- imgref = cmd.get<string>("imgref");
- if (imgref.empty())
- {
- cout << "Specify image reference" << endl;
- return false;
- }
- }
- }
- return flag;
- }
它的主要流程如下图所示:
2、VideoAnalysis::start()
该函数的代码如下:
- void VideoAnalysis::start()
- {
- //cout << "Press 'ESC' to stop..." << endl;
- do
- {
- videoCapture = new VideoCapture;
- frameProcessor = new FrameProcessor;
- frameProcessor->init();
- frameProcessor->frameToStop = frameToStop;
- frameProcessor->imgref = imgref;
- videoCapture->setFrameProcessor(frameProcessor);///setFrameProcessor
- if (use_file)
- videoCapture->setVideo(filename);///setVideo
- if (use_camera)
- videoCapture->setCamera(cameraIndex);///setCamera
- videoCapture->start();///start
- if (use_file || use_camera)
- break;
- frameProcessor->finish();
- int key = cvWaitKey(500);
- if (key == KEY_ESC)
- break;
- delete frameProcessor;
- delete videoCapture;
- }
- while (1);
- delete frameProcessor;
- delete videoCapture;
- }
它的主要流程如下图所示:
背景建模技术(四):视频分析(VideoAnalysis)模块的更多相关文章
- 背景建模技术(二):BgsLibrary的框架、背景建模的37种算法性能分析、背景建模技术的挑战
背景建模技术(二):BgsLibrary的框架.背景建模的37种算法性能分析.背景建模技术的挑战 1.基于MFC的BgsLibrary软件下载 下载地址:http://download.csdn.ne ...
- 背景建模技术(三):背景减法库(BGS Library)的基本框架与入口函数main()的功能
背景减法库(BGS Library = background subtraction library)包含了37种背景建模算法,也是目前国际上关于背景建模技术研究最全也最权威的资料.本文将更加详细的介 ...
- 背景建模技术(六):帧处理(FrameProcessor)模块
前面几篇文章简单介绍了BgsLibrary的入口函数.视频分析和视频捕获模块,本文将简单介绍帧处理模块,即对每一帧进行处理的函数,也就是真正调用背景建模算法的接口处. 下面贴出源码供大家分析: #in ...
- 背景建模技术(七):预处理(PreProcessor)模块
预处理(PreProcessor)模块是BgsLibrary中一个必选的模块,是真正进入背景建模算法的“预处理”过程,其主要功能包括‘去模糊’.‘获得灰度图’.'应用Canny算子‘等可选模块. 下面 ...
- 【计算机视觉】背景建模--Vibe 算法优缺点分析
一.Vibe 算法的优点 Vibe背景建模为运动目标检测研究邻域开拓了新思路,是一种新颖.快速及有效的运动目标检测算法.其优点有以下两点: 1.思想简单,易于实现.Vibe通常随机选取邻域20个样本为 ...
- 背景建模技术(五):视频捕获(VideoCapture)模块
本次对“视频捕获(VideoCapture)模块”做出分析,给出源代码和对应的程序流程框架. 视频捕获模块的主要功能是设置视频或相机参数,并读取设置配置参数,最后进入帧处理模块的process进程,该 ...
- 浅析软件工程中的UML建模技术
一.基本信息 标题:浅析软件工程中的UML建模技术 时间:2018 出版源:电子世界 领域分类:软件工程:UML建模技术:需求分析 二.研究背景 问题定义:软件工程中UML建模技术的研究 难点:明确软 ...
- [MOC062066]背景建模资料收集整理
一.相关博客 背景建模相关资料收集,各个链接都已给出. 资料,不可能非常完整,以后不定期更新. -----------------切割线----------------- 这个哥们总结的非常好啊,看完 ...
- 3、UML建模技术
UML(统一建模语言)是当前软件开发中使用最为广泛的建模技术之一,通过使用UML可以构造软件系统的需求模型(用例模型).静态模型.动态模型和架构模型 UML类图 1.UML类图图示 在UML中,类使用 ...
随机推荐
- 第一模块·开发基础-第1章 Python基础语法
Python开发工具课前预习 01 Python全栈开发课程介绍1 02 Python全栈开发课程介绍2 03 Python全栈开发课程介绍3 04 编程语言介绍(一) 05 编程语言介绍(二)机器语 ...
- lesson 14 A noble gangster
lesson 14 A noble gangster there was a ++time++ 时期 times 时期/年代 in times of peace a sum of + money 一笔 ...
- 查找 二叉树中 k1 到 k2区间的节点
vector<int> res; int key1, key2; void traverse(TreeNode * root){//采用前序遍历 if(root == NULL) retu ...
- 承压计算:模拟+double
标题:承压计算 X星球的高科技实验室中整齐地堆放着某批珍贵金属原料. 每块金属原料的外形.尺寸完全一致,但重量不同.金属材料被严格地堆放成金字塔形. 7 ...
- LeetCode 169. Majority Element - majority vote algorithm (Java)
1. 题目描述Description Link: https://leetcode.com/problems/majority-element/description/ Given an array ...
- 阿里校招内推C++岗位编程题第一题 空格最少的字符串
给定一个字符串S和有效单词的字典D,请确定可以插入到S中的最小空格数,使得最终的字符串完全由D中的有效单词组成.并输出解. 如果没有解则应该输出n/a 例如: 输入: S = “ilikealibab ...
- UML建模语言入门 -- 静态图详解 类图 对象图 包图 静态图建模实战
发现个好东西思维导图, 最近开始用MindManager整理博客 . 作者 :万境绝尘 转载请注明出处 : http://blog.csdn.net/shulianghan/article/deta ...
- iOS开发给UIView添加动画Animation
self.testView需要添加动画的view 1.翻转动画 [UIView beginAnimations:@"doflip" context:nil]; [UIView se ...
- PokeCats开发者日志(十一)
现在是PokeCats游戏开发的第六十天的上午,易版权的状态变为了待收证,但愿不久就能送到了吧.
- YaoLingJump开发者日志(一)
写完PokeCats之后意犹未尽,还想做一个更加有趣的游戏,比如说像超级玛丽那样. 游戏的主角就选"瑶玲"了,这是我小时候最喜欢的动画片<瑶玲啊瑶玲>的女主角. ...