视频加载与摄像头的使用
#include<opencv2/opencv.hpp>
#include<iostream>
using namespace std;
using namespace cv;
int main()
{
VideoCapture video;
video.open("C:/opencv/video.mp4");
if (!video.isOpened())
{
cout << "请检查视频文件" << endl;
return -1;
}
cout << "视频频率=" << video.get(CAP_PROP_FPS) << endl;
cout << "视频长度=" << video.get(CAP_PROP_FRAME_HEIGHT) << endl;
while (1)
{
Mat frame;
video >> frame;
if (frame.empty())
{
break;
}
imshow("video", frame);
uchar c = waitKey(1000 / video.get(CAP_PROP_FPS));
if (c = "q")
{
break;
}
}
return 0;
}
代码中设置了查错功能,以及对于视频频率与宽度数据的输出
代码有报错(之后会有更新)