OpenCV 自动调取摄像头并显示屏幕

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/eagle_or_snail/article/details/80870489
#include <opencv2/opencv.hpp>  
using namespace cv;  

int main( )  
{  
	//【1】读入视频
	//VideoCapture capture("1.avi");
        //从摄像头读入视频,参数0就代表读入的是摄像头
        VideoCapture capture(0);
	//【2】循环显示每一帧
	while(1)  
	{  
		Mat frame;//定义一个Mat变量,用于存储每一帧的图像
		capture>>frame;  //读取当前帧
		imshow("读取视频",frame);  //显示当前帧
		waitKey(30);  //延时30ms
	}  
	return 0;     
}  

猜你喜欢

转载自blog.csdn.net/eagle_or_snail/article/details/80870489