c++ opencv调用摄像头程序

// opencv_test.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include
#pragma comment(lib,"opencv_core246d.lib")  
#pragma comment(lib,"opencv_highgui246d.lib")  
#pragma comment(lib,"opencv_imgproc246d.lib")
int test()
{
    int i;
    IplImage* img=NULL;
    CvCapture* capture=cvCaptureFromCAM(0);
    cvWaitKey(1);
    printf("after capturing\n");
    cvNamedWindow("result",1);
    for(i=0;i<10000;++i)
    {
        printf("frame %d\n",i);
        img=cvRetrieveFrame(capture);
        cvShowImage("result",img);
        cvWaitKey(1);
    }
    printf("done\n");
    cvWaitKey(3000);
    cvReleaseCapture(&capture);
    return 0;
}


int _tmain(int argc, _TCHAR* argv[])
{
    test();
    return 0;
}

你可能感兴趣的:(c++ opencv调用摄像头程序)