视频分析模块主要包含两个函数,一个是VideoAnalysis::setup(....),其主要功能就是确定测试的视频是视频文件或摄像头输入亦或是采用命令行参数;第二个函数是VideoAnalysis::start(),其主要功能初始化视频处理、设置视频获取方式以及开始视频捕获功能等。

1、VideoAnalysis::setup(....)

该函数的代码如下:

  1. bool VideoAnalysis::setup(int argc, const char **argv)
  2. {
  3. bool flag = false;
  4. const char* keys =
  5. "{hp|help|false|Print help message}"
  6. "{uf|use_file|false|Use video file}"
  7. "{fn|filename||Specify video file}"
  8. "{uc|use_cam|false|Use camera}"
  9. "{ca|camera|0|Specify camera index}"
  10. "{co|use_comp|false|Use mask comparator}"
  11. "{st|stopAt|0|Frame number to stop}"
  12. "{im|imgref||Specify image file}" ;
  13. cv::CommandLineParser cmd(argc, argv, keys);
  14. ////////////use_command
  15. if (argc <= 1 || cmd.get<bool>("help") == true)
  16. {
  17. cout << "Usage: " << argv[0] << " [options]" << endl;
  18. cout << "Avaible options:" << endl;
  19. cmd.printParams();
  20. return false;
  21. }
  22. ////////////use_file
  23. use_file = cmd.get<bool>("use_file");
  24. if (use_file)
  25. {
  26. filename = cmd.get<string>("filename");
  27. if (filename.empty())
  28. {
  29. cout << "Specify filename" << endl;
  30. return false;
  31. }
  32. flag = true;
  33. }
  34. ////////////use_camera
  35. use_camera = cmd.get<bool>("use_cam");
  36. if (use_camera)
  37. {
  38. cameraIndex = cmd.get<int>("camera");
  39. flag = true;
  40. }
  41. ////////////use_comp
  42. if (flag == true)
  43. {
  44. use_comp = cmd.get<bool>("use_comp");
  45. if (use_comp)
  46. {
  47. frameToStop = cmd.get<int>("stopAt");
  48. imgref = cmd.get<string>("imgref");
  49. if (imgref.empty())
  50. {
  51. cout << "Specify image reference" << endl;
  52. return false;
  53. }
  54. }
  55. }
  56. return flag;
  57. }

它的主要流程如下图所示:

2、VideoAnalysis::start()

该函数的代码如下:

  1. void VideoAnalysis::start()
  2. {
  3. //cout << "Press 'ESC' to stop..." << endl;
  4. do
  5. {
  6. videoCapture = new VideoCapture;
  7. frameProcessor = new FrameProcessor;
  8. frameProcessor->init();
  9. frameProcessor->frameToStop = frameToStop;
  10. frameProcessor->imgref = imgref;
  11. videoCapture->setFrameProcessor(frameProcessor);///setFrameProcessor
  12. if (use_file)
  13. videoCapture->setVideo(filename);///setVideo
  14. if (use_camera)
  15. videoCapture->setCamera(cameraIndex);///setCamera
  16. videoCapture->start();///start
  17. if (use_file || use_camera)
  18. break;
  19. frameProcessor->finish();
  20. int key = cvWaitKey(500);
  21. if (key == KEY_ESC)
  22. break;
  23. delete frameProcessor;
  24. delete videoCapture;
  25. }
  26. while (1);
  27. delete frameProcessor;
  28. delete videoCapture;
  29. }

它的主要流程如下图所示:

背景建模技术(四):视频分析(VideoAnalysis)模块的更多相关文章

  1. 背景建模技术(二):BgsLibrary的框架、背景建模的37种算法性能分析、背景建模技术的挑战

    背景建模技术(二):BgsLibrary的框架.背景建模的37种算法性能分析.背景建模技术的挑战 1.基于MFC的BgsLibrary软件下载 下载地址:http://download.csdn.ne ...

  2. 背景建模技术(三):背景减法库(BGS Library)的基本框架与入口函数main()的功能

    背景减法库(BGS Library = background subtraction library)包含了37种背景建模算法,也是目前国际上关于背景建模技术研究最全也最权威的资料.本文将更加详细的介 ...

  3. 背景建模技术(六):帧处理(FrameProcessor)模块

    前面几篇文章简单介绍了BgsLibrary的入口函数.视频分析和视频捕获模块,本文将简单介绍帧处理模块,即对每一帧进行处理的函数,也就是真正调用背景建模算法的接口处. 下面贴出源码供大家分析: #in ...

  4. 背景建模技术(七):预处理(PreProcessor)模块

    预处理(PreProcessor)模块是BgsLibrary中一个必选的模块,是真正进入背景建模算法的“预处理”过程,其主要功能包括‘去模糊’.‘获得灰度图’.'应用Canny算子‘等可选模块. 下面 ...

  5. 【计算机视觉】背景建模--Vibe 算法优缺点分析

    一.Vibe 算法的优点 Vibe背景建模为运动目标检测研究邻域开拓了新思路,是一种新颖.快速及有效的运动目标检测算法.其优点有以下两点: 1.思想简单,易于实现.Vibe通常随机选取邻域20个样本为 ...

  6. 背景建模技术(五):视频捕获(VideoCapture)模块

    本次对“视频捕获(VideoCapture)模块”做出分析,给出源代码和对应的程序流程框架. 视频捕获模块的主要功能是设置视频或相机参数,并读取设置配置参数,最后进入帧处理模块的process进程,该 ...

  7. 浅析软件工程中的UML建模技术

    一.基本信息 标题:浅析软件工程中的UML建模技术 时间:2018 出版源:电子世界 领域分类:软件工程:UML建模技术:需求分析 二.研究背景 问题定义:软件工程中UML建模技术的研究 难点:明确软 ...

  8. [MOC062066]背景建模资料收集整理

    一.相关博客 背景建模相关资料收集,各个链接都已给出. 资料,不可能非常完整,以后不定期更新. -----------------切割线----------------- 这个哥们总结的非常好啊,看完 ...

  9. 3、UML建模技术

    UML(统一建模语言)是当前软件开发中使用最为广泛的建模技术之一,通过使用UML可以构造软件系统的需求模型(用例模型).静态模型.动态模型和架构模型 UML类图 1.UML类图图示 在UML中,类使用 ...

随机推荐

  1. 第一模块·开发基础-第1章 Python基础语法

    Python开发工具课前预习 01 Python全栈开发课程介绍1 02 Python全栈开发课程介绍2 03 Python全栈开发课程介绍3 04 编程语言介绍(一) 05 编程语言介绍(二)机器语 ...

  2. lesson 14 A noble gangster

    lesson 14 A noble gangster there was a ++time++ 时期 times 时期/年代 in times of peace a sum of + money 一笔 ...

  3. 查找 二叉树中 k1 到 k2区间的节点

    vector<int> res; int key1, key2; void traverse(TreeNode * root){//采用前序遍历 if(root == NULL) retu ...

  4. 承压计算:模拟+double

    标题:承压计算 X星球的高科技实验室中整齐地堆放着某批珍贵金属原料. 每块金属原料的外形.尺寸完全一致,但重量不同.金属材料被严格地堆放成金字塔形. 7                         ...

  5. LeetCode 169. Majority Element - majority vote algorithm (Java)

    1. 题目描述Description Link: https://leetcode.com/problems/majority-element/description/ Given an array ...

  6. 阿里校招内推C++岗位编程题第一题 空格最少的字符串

    给定一个字符串S和有效单词的字典D,请确定可以插入到S中的最小空格数,使得最终的字符串完全由D中的有效单词组成.并输出解. 如果没有解则应该输出n/a 例如: 输入: S = “ilikealibab ...

  7. UML建模语言入门 -- 静态图详解 类图 对象图 包图 静态图建模实战

    发现个好东西思维导图, 最近开始用MindManager整理博客 . 作者 :万境绝尘  转载请注明出处 : http://blog.csdn.net/shulianghan/article/deta ...

  8. iOS开发给UIView添加动画Animation

    self.testView需要添加动画的view 1.翻转动画 [UIView beginAnimations:@"doflip" context:nil]; [UIView se ...

  9. PokeCats开发者日志(十一)

      现在是PokeCats游戏开发的第六十天的上午,易版权的状态变为了待收证,但愿不久就能送到了吧.

  10. YaoLingJump开发者日志(一)

      写完PokeCats之后意犹未尽,还想做一个更加有趣的游戏,比如说像超级玛丽那样.   游戏的主角就选"瑶玲"了,这是我小时候最喜欢的动画片<瑶玲啊瑶玲>的女主角. ...