OpenCV 学习笔记(5) 使用opencv打开笔记本摄像头

#include "stdafx.h"
#include <opencv2opencv.hpp>
#include <iostream>
#include <string>
using namespace cv;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
	cvNamedWindow("我的摄像头", CV_WINDOW_AUTOSIZE);
	//captue = cvCaptureFromCAM(0);
	VideoCapture captue(0);//创建一个摄像头对象并且指定摄像头编号,只有一个写0就可以
	//captue = cvCreateCameraCapture(0);
 
	Mat frame;
	while (1)
	{
		captue >> frame;
		imshow("我的摄像头", frame);
		waitKey(30);
	}
	return 0;
}

  

原文地址:https://www.cnblogs.com/kekeoutlook/p/11079933.html