본문 바로가기

프로그래밍/OpenCV

캠(카메라)영상 출력

#include "stdafx.h"
#include <cv.h>
#include <highgui.h>
int _tmain(int argc, _TCHAR* argv[])
{
     IplImage* image = 0;

    CvCapture* capture = cvCaptureFromCAM(0); //캠(카메라)받기
    cvNamedWindow( "camera", 0 );
    cvResizeWindow( "camera", 320, 240 ); //윈도우 창크기 변경

    while(1) {
        cvGrabFrame( capture );//캠에서 프레임 얻기
        image = cvRetrieveFrame( capture ); //image에 저장

        cvShowImage( "camera", image );//image 출력

        if( cvWaitKey(10) >= 0 )
           break;           
    }
 
    cvReleaseCapture( &capture );
    cvDestroyWindow( "camera" );

 return 0;
}