// ConsoleApplication1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;
// 测试视频, 摄像头接口
int main()
{
// 可以直接在构造函数中提供文件名
VideoCapture cap;
cap.open("C:\\Users\\Administrator\\Desktop\\面试\\show.mp4");
if (cap.isOpened() == false) return -1;
int width = cap.get(CV_CAP_PROP_FRAME_WIDTH); // 视频宽度
int height = cap.get(CV_CAP_PROP_FRAME_HEIGHT); // 视频高度
int frameRate = cap.get(CV_CAP_PROP_FPS); // 帧率
int frames = cap.get(CV_CAP_PROP_FRAME_COUNT); // 总帧数
cout << "width = " << width << endl;
cout << "height = " << height << endl;
cout << "frameRate = " << frameRate << endl;
cout << "frames = " << frames << endl;
Mat frame;
while (1) {
cap >> frame;
if (frame.empty() == true) break;
imshow("video", frame);
waitKey(30);
}
cap.release();
return 0;
}