opencv 读取视频或者摄像头

 opencv 读取视频主要用到cv::VideoCapture 类

#include<iostream>
//#include<string>
//#include<sstream>
#include<opencv2/core.hpp>
#include<opencv2/highgui.hpp>

int main() {
//读取视频或摄像头
//  cv::VideoCapture capture(0)  0表示打开摄像头
// cv::VideoCapture capture("in.avi") 表示打开一个视频
cv::VideoCapture capture(0);
while (true){
	cv::Mat frame;
	capture >> frame;
	cv::imshow("读取视频", frame);
	cv::waitKey(1);
}

system("pause");
return 0;
}

猜你喜欢

转载自blog.csdn.net/SenPaul/article/details/83181104