-
Opencv 简单视频播放器
- #include <iostream>
- #include <string>
- #include <cstdlib>
- using namespace std;
-
- #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[])
- {
-
- if (argc != 2)
- {
- cerr << "Usage: VideoPlayer.exe VideoFilename." << endl;
- exit(1);
- }
-
-
- 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
-
-
- 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);
- }
-
-
- Mat frame;
- bool stop(false);
- int delay = 1000 / FpsOfVideo;
- namedWindow("Extracted Frame");
-
- while (!stop)
- {
-
- if (!capture.read(frame))
- {
- break;
- }
- imshow("Extracted Frame", frame);
-
- if (waitKey(delay) >= 0)
- {
- stop = true;
- }
- }
-
-
-
- capture.release();
-
- return 0;
- }
-
相关阅读:
Java实现寻找最小的k个数
Java实现寻找最小的k个数
foruok安晓辉的《程序员,你好哇》,都很不错
DataSnap的如果网络断线,如何恢复?
配置QSslConfiguration让客户端程序跳过本地SSL验证
Linux升级OpenSSL版本
FMX+Win32,窗口无法保持原样,应该是个bug
[Nhibernate]二级缓存
EventBus(事件总线)
elasticsearch集群搭建实例
-
原文地址:https://www.cnblogs.com/daochong/p/7954214.html
Copyright © 2020-2023
润新知