opencv下如何使用摄像头,
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include "opencv/cxcore.hpp"
#include "highgui.h"
#include "cv.h"
using namespace std;
int main()
{
CvCapture* capture = 0;
cout << "open camera" << endl;
while (1){
capture = cvCaptureFromCAM(0);
IplImage* iplImg = cvQueryFrame(capture);
if (!iplImg)
{
return 0;
}
cvShowImage("photo", iplImg);
cvWaitKey(1);
}
cout << "close camera" << endl;
return 0;
}