Hi, here is a sample code. If I remove the stdafx.h file, the program wont compile.
stdafx.h file
'#pragma once
'#include "targetver.h"
'#include <stdio.h>
'#include <tchar.h>
Capture.ccp
// Capture.cpp : Defines the entry point for the console application. //
'#include "stdafx.h"
'#include "string.h"
'#include "cv.h"
'#include "highgui.h"
int _tmain(int argc, char ** argv[])
{
CvCapture * pCapture = 0;
IplImage * pVideoFrame = 0;
int i;
char filename[50];
//Initialize vieo capture
pCapture = cvCaptureFromCAM( CV_CAP_ANY );
if( !pCapture )
{
fprintf(stderr, "failed to initialize video capture\n");
return -1;
}
//Capture three video frames and write them as files
for(i=0;i<20;i++)
{
pVideoFrame = cvQueryFrame( pCapture );
if( !pVideoFrame )
{
fprintf(stderr, "failed to get a video frame\n");
}
//Write the captured video frame as an image file
sprintf(filename, "VideoFrame%d.jpg", i+1);
if( !cvSaveImage(filename, pVideoFrame))
{
fprintf(stderr, "faile dto write image file %s\n", filename);
}
//IMPORTANT : Don't release or modify the image returned
//from cvQueryFrame() !
}
//Terminate video capture and free capture resources
cvReleaseCapture( &pCapture );
return 0;
}
What is the purpose of the stdafx.h file - this file by the way is generated automatically.
Many Thanks