- #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;
- }
posted on
2017-12-02 14:41
baraka
阅读(
1088)
评论()
编辑
收藏
举报