opencv怎么打开usb摄像头
2个回答
展开全部
//Program to display a video from attached default camera device
#include<iostream>
#include<opencv2/opencv.hpp>
using namespace std;
using namespace cv;
char *window_name = "Video";
int main()
{
VideoCapture cap(0); //此处默认USB摄像头
if (!cap.isOpened())
{
cerr << "webCam could't be opened successfully" << endl;
return EXIT_FAILURE;
}
namedWindow(window_name);
while (char(waitKey(1)) != 'q'&&cap.isOpened())
{
Mat frame;
cap >> frame;
if (frame.empty())
{
cout << "Video over" << endl;
break;
}
imshow(window_name, frame);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询