Opencv中的webCam

来源:互联网 发布:tensorflow mnist 例子 编辑:程序博客网 时间:2024/06/06 20:45
//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(){system("color 2E");VideoCapture cap(0);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);}}

0 0
原创粉丝点击