Opencv 简单视频播放器
- // C++ header and namespace
- #include <iostream>
- #include <string>
- #include <cstdlib>
- using namespace std;
- // Opencv header and namespace
- #include <opencv2/core/core.hpp>
- #include <opencv2/highgui/highgui.hpp>
- #include <opencv2/imgproc/imgproc.hpp>
- #include <opencv2/video/video.hpp>
- using namespace cv;
- bool JumpToFrame(false);
- int main(int argc, char* argv[])
- {
- //!< Check out Input video
- if (argc != 2)
- {
- cerr << "Usage: VideoPlayer.exe VideoFilename." << endl;
- exit(1);
- }
- //!< Check out Open Video
- VideoCapture capture(argv[1]);
- if (!capture.isOpened())
- {
- return 1;
- }
- #pragma region InfoOfVideo
- long NumberOfFrame = static_cast<long>(capture.get(CV_CAP_PROP_FRAME_COUNT));
- double HeightOfFrame = capture.get(CV_CAP_PROP_FRAME_HEIGHT);
- double WidthOfFrame = capture.get(CV_CAP_PROP_FRAME_WIDTH);
- double FpsOfVideo = capture.get(CV_CAP_PROP_FPS);
- cout << "The name of the input video is " << argv[1] << "." << endl;
- cout << "NumberOfFrame : " << NumberOfFrame << endl;
- cout << "HeightOfFrame : " << HeightOfFrame << endl;
- cout << "WidthOfFrame : " << WidthOfFrame << endl;
- cout << "FpsOfVieo : " << FpsOfVideo << endl;
- #pragma endregion
- // !< JumpToFrame function
- while (JumpToFrame)
- {
- double Position = 0.0;
- cout << "Please input the number of frame which you want jump to!" << endl;
- cin >> Position;
- capture.set(CV_CAP_PROP_POS_FRAMES, Position);
- }
- // !< Delay between each frame in ms corresponds to video frame rate(fps)
- Mat frame;
- bool stop(false);
- int delay = 1000 / FpsOfVideo;
- namedWindow("Extracted Frame");
- while (!stop)
- {
- //read next frame if any
- if (!capture.read(frame))
- {
- break;
- }
- imshow("Extracted Frame", frame);
- //introduce a delay or press key to stop
- if (waitKey(delay) >= 0)
- {
- stop = true;
- }
- }
- // !< Close the video file.
- // Not required since called by destructor
- capture.release();
- return 0;
- }
Opencv 简单视频播放器的更多相关文章
- 使用VideoView实现简单视频播放器
转载请注明出处:http://blog.csdn.net/hejjunlin/article/details/39471397 VideoView内部封装好了Mediaplayer.Android框架 ...
- QT-简易视频播放器
一直没找到理由去学一下QT,由于工作原因之后的工作内容会用到QT,于是这两天摸索了下:早上临时决定先做个视频播放器玩一下,于是先用qml发现不会用,无果,于是放弃了使用qml,等之后系统的看一下Jav ...
- 转:最简单的基于 DirectShow 的视频播放器
50行代码实现的一个最简单的基于 DirectShow 的视频播放器 本文介绍一个最简单的基于 DirectShow 的视频播放器.该播放器对于初学者来说是十分有用的,它包含了使用 DirectSho ...
- 【转】100行代码实现最简单的基于FFMPEG+SDL的视频播放器
FFMPEG工程浩大,可以参考的书籍又不是很多,因此很多刚学习FFMPEG的人常常感觉到无从下手.我刚接触FFMPEG的时候也感觉不知从何学起. 因此我把自己做项目过程中实现的一个非常简单的视频播放器 ...
- 最简单的基于FFMPEG+SDL的视频播放器 ver2 (採用SDL2.0)
===================================================== 最简单的基于FFmpeg的视频播放器系列文章列表: 100行代码实现最简单的基于FFMPEG ...
- 最简单的基于DirectShow的示例:视频播放器自定义版
===================================================== 最简单的基于DirectShow的示例文章列表: 最简单的基于DirectShow的示例:视 ...
- 最简单的基于DirectShow的示例:视频播放器图形界面版
===================================================== 最简单的基于DirectShow的示例文章列表: 最简单的基于DirectShow的示例:视 ...
- 最简单的基于DirectShow的示例:视频播放器
===================================================== 最简单的基于DirectShow的示例文章列表: 最简单的基于DirectShow的示例:视 ...
- 最简单的基于libVLC的例子:最简单的基于libVLC的视频播放器(图形界面版)
===================================================== 最简单的基于libVLC的例子文章列表: 最简单的基于libVLC的例子:最简单的基于lib ...
随机推荐
- [Debug] Debugger Statements
For example you have the following code; function reverse(str) { let reversed = ""; for (l ...
- Finding Lane Lines on the Road
Finding Lane Lines on the Road The goals / steps of this project are the following: Make a pipeline ...
- Mybatis的mapper接口在Spring中实例化过程
在spring中使用mybatis时一般有下面的配置 <bean id="mapperScannerConfigurer" class="org.mybatis.s ...
- POJ2182 Lost Cows 树状数组
题意:有编号1~n乱序排列的奶牛,给出了每一个奶牛前小于自己编号的奶牛数目 维护一个树状数组,下标是编号,值为$0/1$标识是否存在,很显然最后一个牛的编号是知道的,我们在树状数组上二分出前缀和为小于 ...
- conda 激活环境失败解决办法
https://stackoverflow.com/questions/41746137/conda-environment-is-discoverable-but-not-activateable- ...
- Python回归分析五部曲(三)—一元非线性回归
(一)基础铺垫 一元非线性回归分析(Univariate Nonlinear Regression) 在回归分析中,只包括一个自变量和一个因变量,且二者的关系可用一条曲线近似表示,则称为一元非线性回归 ...
- codeforces#1165 F2. Microtransactions (hard version) (二分+贪心)
题目链接: https://codeforces.com/contest/1165/problem/F2 题意: 需要买$n$种物品,每种物品$k_i$个,每个物品需要两个硬币 每天获得一个硬币 有$ ...
- Codeforces 808 E. Selling Souvenirs(三分)
E. Selling Souvenirs 题意: n件物品,有重量和价值,重量只有三种1,2,3.问取不超过m重量的物品的价值总和最大是多少.(n<=1e5,w<=3e5) 思路: n*w ...
- 在Linux下使用rm -rf /*后会怎样?
每个工作过的码农,也许不知道分布式,也许不知道高并发,但想必都知道这句鼎鼎大名的代码.本人对此也是比较好奇的,不妨用虚拟机试试看 首先是普通角色: 普通角色把拥有权限的文件全都删掉了后,其他文件的提示 ...
- TensorFlow错误ValueError: No gradients provided for any variable
使用TensorFlow训练神经网络的时候,出现以下报错信息: Traceback (most recent call last): File "gan.py", line 1 ...