티스토리 뷰

Computer/OpenCV

OpenCV_002_ToGray

DogBull 2008.07.19 20:10

#include <cv.h>
#include <highgui.h>

#include <stdio.h>

#pragma comment(lib, "cxcore.lib")
#pragma comment(lib, "cv.lib")
#pragma comment(lib, "highgui.lib")
#pragma comment(lib, "cvcam.lib")

const static char gWinName[]=    "NoName";

void main(){
    IplImage* image=    NULL;
    CvCapture* capture=    cvCaptureFromCAM(0);

    cvNamedWindow(gWinName, 0);
    cvResizeWindow(gWinName, 400, 300);

    IplImage* gray=    NULL;
    {
        cvGrabFrame(capture);
        image=    cvRetrieveFrame(capture);

        gray=    cvCreateImage(cvGetSize(image), IPL_DEPTH_8U, 1);
        gray->origin=    image->origin;
    }
    
    while(true){
        cvGrabFrame(capture);
        image=    cvRetrieveFrame(capture);
        cvCvtColor(image, gray, CV_RGB2GRAY);
        cvShowImage(gWinName, gray);

        if( cvWaitKey(1)>=0 ){
            break;
        }
    }
    
    cvReleaseCapture(&capture);
    cvDestroyWindow(gWinName);
}

'Computer > OpenCV' 카테고리의 다른 글

OpenCV_002_ToGray  (0) 2008.07.19
OpenCV_001_Install  (0) 2008.07.18
1. OpenCV 설명 및 셋팅  (0) 2007.07.31
댓글
Total
170,486
Today
25
Yesterday
86