繁体   English   中英

使用opencv将stdafx.h文件包含在C ++程序中的目的是什么?

[英]What is the purpose of including the stdafx.h file in a C++ program using opencv

这是一个示例代码。 如果我删除stdafx.h文件,该程序将无法编译。

stdafx.h文件

'#pragma once

'#include "targetver.h"

'#include <stdio.h>
'#include <tchar.h>

Capture.ccp

// Capture.cpp:定义控制台应用程序的入口点。 //

'#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;
}

stdafx.h文件的目的是什么 - 顺便说一下这个文件是自动生成的。

非常感谢

它是编译器预编译头的一部分,可以加快构建速度。

正如peterchen所说,它用于加速构建并添加一些Windows内容。 这包括完全视觉工作室特定 ,如果您希望您的程序是跨平台的,则不应使用,这是Open Cv库的情况(您可以在windows,linux下使用opencv ......)。

你的编译错误信息是什么?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM