一帧一帧地读取视频流。

  • VideoCapture sequence(file_video);
  • sequence >> image.

#include <opencv2/core/core.hpp>
#include <opencv2/videoio/videoio.hpp>
#include <opencv2/highgui/highgui.hpp> #include <iostream> using namespace cv;
using namespace std; static void help(char** argv)
{
cout << "\nThis sample shows you how to read a sequence of images using the VideoCapture interface.\n"
<< "Usage: " << argv[0] << " <image_mask> (example mask: example_%02d.jpg)\n"
<< "Image mask defines the name variation for the input images that have to be read as a sequence. \n"
<< "Using the mask example_%02d.jpg will read in images labeled as 'example_00.jpg', 'example_01.jpg', etc."
<< endl;
} int main(int argc, char** argv)
{
cv::CommandLineParser parser(argc, argv, "{help h||}{@image| ../data/768x576.avi |}");
if (parser.has("help"))
{
help(argv);
return 0;
}
string first_file = parser.get<string>("@image");
cout << "first_file = " << first_file << endl; if(first_file.empty())
{
help(argv);
return 1;
} // Jeff --> read video stream.
VideoCapture sequence(first_file); if (!sequence.isOpened())
{
cerr << "Failed to open the image sequence!\n" << endl;
return 1;
} Mat image;
namedWindow("Image sequence | press ESC to close", 1); for(;;)
{
// Read in image from sequence
sequence >> image; // If no image was retrieved -> end of sequence
if(image.empty())
{
cout << "End of Sequence" << endl;
break;
} // Jeff --> we may control the speed here.
imshow("Image sequence | press ESC to close", image);
if(waitKey(500) == 27)
break;
} return 0;
}

[OpenCV] Samples 11: image sequence的更多相关文章

  1. [OpenCV] Samples 10: imagelist_creator

    yaml写法的简单例子.将 $ ./ 1 2 3 4 5 命令的参数(代表图片地址)写入yaml中. 写yaml文件. 参考:[OpenCV] Samples 06: [ML] logistic re ...

  2. [OpenCV] Samples 16: Decompose and Analyse RGB channels

    物体的颜色特征决定了灰度处理不是万能,对RGB分别处理具有相当的意义. #include <iostream> #include <stdio.h> #include &quo ...

  3. [OpenCV] Samples 13: opencv_version

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

  4. [OpenCV] Samples 06: [ML] logistic regression

    logistic regression,这个算法只能解决简单的线性二分类,在众多的机器学习分类算法中并不出众,但它能被改进为多分类,并换了另外一个名字softmax, 这可是深度学习中响当当的分类算法 ...

  5. [OpenCV] Samples 03: cout_mat

    操作Mat元素时:I.at<double>(1,1) = CV_PI; /* * * cvout_sample just demonstrates the serial out capab ...

  6. [OpenCV] Samples 03: kmeans

    注意Mat作为kmeans的参数的含义. 扩展:高维向量的聚类. 一.像素聚类 #include "opencv2/highgui.hpp" #include "open ...

  7. [OpenCV] Samples 06: logistic regression

    logistic regression,这个算法只能解决简单的线性二分类,在众多的机器学习分类算法中并不出众,但它能被改进为多分类,并换了另外一个名字softmax, 这可是深度学习中响当当的分类算法 ...

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

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

  9. [OpenCV] Samples 12: laplace

    先模糊再laplace,也可以替换为sobel等. 变换效果后录成视频,挺好玩. #include "opencv2/videoio/videoio.hpp" #include & ...

随机推荐

  1. 【原创】还原Hyper-V 到一个新的虚拟机

    Context: I need to restore VM31 backup (via 'Windows Server Backup' tool) as another new Hyper-V mac ...

  2. Yii2中的零碎知识点

    PHP最佳实践 1 PHP获取时间戳:echo  time(); 时间戳转换 date('Y-m-d H:i:s', $时间戳); 2 linux 显示命令 ls 显示所有文件夹 查看命令:tail ...

  3. 集合的扩展方法ForEach的使用

    List<, , , , }; list.ForEach(p => Console.WriteLine(p)); 或者 List<, , , , }; list.ForEach(p ...

  4. Intel VT-x 基本概念

    看IaaS 资料时,捎带研究下硬件虚拟化,主要参考<基于intel VT-x 的Xen 全虚拟化实现>,<intel 开发手册 第三卷 19/20章> Intel VT 是in ...

  5. jenkins + Git 搭建持续集成环境

    持续集成通过自动化构建.自动化测试以及自动化部署加上较高的集成频率保证了开发系统中的问题能迅速被发现和修复,降低了集成失败的风险,使得系统在开发中始终保持在一个稳定健康的集成状态.jenkins是目前 ...

  6. [.net 面向对象编程基础] (8) 基础中的基础——修饰符

    [.net 面向对象编程基础] (8) 基础中的基础——修饰符 在进入C#面向对象核心之前,我们需要先对修饰符有所了解,其实我们在前面说到变量和常量的时候,已经使用了修饰符,并且说明了变量和常量的修改 ...

  7. html嵌套MP4、PDF的简单方案

    你需要一个jquery.media插件,http://malsup.com/jquery/media/ 然后: <html><head><script src=" ...

  8. Android移动APP开发笔记——最新版Cordova 5.3.1(PhoneGap)搭建开发环境

    引言 简单介绍一下Cordova的来历,Cordova的前身叫PhoneGap,自被Adobe收购后交由Apache管理,并将其核心功能开源改名为Cordova.它能让你使用HTML5轻松调用本地AP ...

  9. nanoTime对volatile 测试的一种写法

    今天脑筋有点搭牢,想了半天才看出为什么以下两段代码效果是相同的... 第一种好处是可以直接批量复制黏贴system.out,  不用改什么东西 private static long i;  priv ...

  10. IOS 公共类-数字处理

    1.写一个方法,调用的时候交换两个数的值 -(void) swap:(int*)a andNumber:(int*)b{ int temp = *a; *a = *b; *b = temp; } 调用 ...