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

int main(int argc,char *argv[]){

	IplImage *image = 0;
	CvCapture *capture = 0;
	char fname[255];
	capture = cvCaptureFromCAM(0);
	
	if(capture){
		cvNamedWindow("snapshot",1);

		while( 1 ){
			if( !(image = cvQueryFrame(capture)) )
			    break;

			cvShowImage("snapshot", image);

			if( cvWaitKey(10) >= 0)
				break;
		}
	
		// ファイル名を求める
		printf("filename :");
		if(scanf("%s",fname)!=0){
			cvSaveImage(fname,image);
			printf("save image as %s\n",fname);
		}

		cvReleaseCapture(&capture);
		cvDestroyWindow("snapshot");
	}

	return 0;
}
// snapshot.c ends here