#include "stdafx.h"
#include <cv.h>
#include <highgui.h>
int _tmain(int argc, _TCHAR* argv[])
{
CvCapture* capture = 0;
capture = cvCreateCameraCapture(-1);//只有一个摄像头使用-1;
if(!capture)
{
return -1;
}
IplImage* bgr_frame;
cvNamedWindow("CQ",0);
while (1)
{
if(!capture)
break;
bgr_frame = cvQueryFrame(capture);
cvShowImage("CQ",bgr_frame);
char c = cvWaitKey(33);
if(27 == c)
break;
}
cvReleaseCapture(&capture);
cvDestroyAllWindows();
return 0;
}
#include "stdafx.h"
#include <cxcore.hpp>
#include <highgui.h>
#include <string>
using namespace std;
using namespace cv;
int _tmain(int argc, _TCHAR* argv[])
{
VideoCapture capture(-1);
Mat CMat,CMat_handle;
namedWindow("test");
while (true)
{
capture >> CMat;
CMat.copyTo(CMat_handle);
imshow("test", CMat_handle);
if (waitKey(30)>=0)
{
break;
}
}
return 0;
}
</pre><pre class="cpp" name="code">