우선 통합코덱을 다운받는다.

K-Life   http://www.codecguide.com/

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

#include<stdio.h>
#include<time.h>

//재정의 Direct 사용이라는데...
typedef struct CvVideoWriter CvVideoWriter;

void main(void){

 // 시간받아오기
 char Time[30];
 time_t timer = time(NULL);
 tm* calTime = localtime(&timer);
 sprintf(Time, "%d월%d일%2d시%2d분%2d초.avi", (calTime->tm_mon+1), (calTime->tm_mday), (calTime->tm_hour), (calTime->tm_min), (calTime->tm_sec) );
 
 IplImage *img1 = 0;
 CvCapture *cap1 = cvCaptureFromCAM(0);
 img1 = cvQueryFrame( cap1 );

 cvNamedWindow( "microsoft1", 0 );
 cvResizeWindow("microsoft1", 640, 480);

 CvVideoWriter *writer = 0;
 int width = 640;
 int height = 480;
 double frame = 20;

// writer = cvCreateVideoWriter(Time, CV_FOURCC('D','I','V','3'), frame, cvSize( width, height), 1);
// writer = cvCreateVideoWriter(Time, CV_FOURCC('M','J','P','G'), frame, cvSize( width, height), 1);
 
 writer = cvCreateVideoWriter(Time,-1, frame, cvSize( width, height));

 puts("\n\n START \n\n");

 while(1){

  cvGrabFrame( cap1 );
  img1 = cvQueryFrame( cap1 );
  
  cvWriteFrame( writer, img1 );
  cvShowImage("microsoft1", img1);

  if(cvWaitKey(10) >= 0) break;

 }

 cvReleaseVideoWriter(&writer);

 cvReleaseCapture(&cap1);

 cvDestroyWindow("microsoft1");
 

 puts("\n\n END \n\n");

}

'OpenSTUDY > CameraVision' 카테고리의 다른 글

YUV color space (one way of encoding RGB information)  (0) 2012.01.09
캠 두개 실행  (0) 2011.11.08
OpenCV 한글 메뉴얼  (0) 2011.11.07
CCD & CMOS  (0) 2011.11.05
Apply Canny edge  (0) 2011.11.05

+ Recent posts