您的位置:首页 > 编程语言 > C语言/C++

Opencv&C++获取摄像头

2015-03-14 15:21 260 查看
#include <stdio.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace cv;
using namespace std;

int main()
{
//抓取摄影栈
VideoCapture cap(0);

//尝试开放摄影栈
if (!cap.isOpened()) return -1;

//用矩阵记录抓取的每张frame
Mat frame;

//建立一个视窗,名称为camera
namedWindow("camera", 1);

for (;;)
{
//把取得的影像放置到矩阵中
cap >> frame;

//演示frame到camera名称的视窗
imshow("frame", frame);

if (waitKey(30) >= 0) break;
}
system("PAUSE");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  OpenCV c++ 摄像头