我正在使用本教程来开始在VS 2008上使用OpenCV 2.4.6:
http://docs.opencv.org/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.html

我遵循了所有说明(我的OpenCV不在默认的Program Files(x86)文件夹中,它位于

C:\opencv_built

与本教程不同,我放置了非常简单的代码,只是为了确保所有包含的文件都可以访问以及是否成功构建等:
#include "stdafx.h"

#include <iostream> // for standard I/O
#include <string>   // for strings
#include <iomanip>  // for controlling float print precision
#include <sstream>  // string to number conversion

#include <opencv2/imgproc/imgproc.hpp>  // Gaussian Blur
#include <opencv2/core/core.hpp>        // Basic OpenCV structures (cv::Mat, Scalar)
#include <opencv2/highgui/highgui.hpp>  // OpenCV window I/O
using namespace std;
using namespace cv;

double getPSNR ( const Mat& I1, const Mat& I2);
Scalar getMSSIM( const Mat& I1, const Mat& I2);


int main(int argc, char *argv[])
{
    return 0;
}

但是当我尝试构建时,出现致命错误:
fatal error C1083: Cannot open include file: 'opencv2/imgproc/imgproc.hpp': No such file or directory   c:\Users\Administrator\Documents\Visual Studio 2008\Projects\firstopencv\firstopencv\firstopencv.cpp    17

这显然是指以下行:
#include <opencv2/imgproc/imgproc.hpp>  // Gaussian Blur

我不知道在哪里可以找到dll文件,或者下一步该怎么做?我知道这一定很容易,但是我已经搜索了任何dll文件,例如。



但没有任何搜索结果。

最佳答案

1. 检查您的 \ vc10 文件夹的路径。应该是:

C:\opencv_built\build\x86\vc10

要么
C:\opencv_built\x86\vc10

2. 转到
Start>Edit environment variables for your account>Under System variables > New...

变量名称: OPENCV_DIR

变量值:在此处插入您从第1步开始的路径。

3. 打开Visual Studio,创建新项目,转到属性页

4. 下C / C++>其他包含目录

插入$(OPENCV_DIR)\..\..\include
5. 下链接器>常规>其他包含目录

插入$(OPENCV_DIR)\lib
6a。 (用于 DEBUG 属性!)在下,链接器>输入>其他依赖项


opencv_core246d.lib
opencv_imgproc246d.lib
opencv_highgui246d.lib
opencv_ml246d.lib
opencv_video246d.lib
opencv_features2d246d.lib
opencv_calib3d246d.lib
opencv_objdetect246d.lib
opencv_contrib246d.lib
opencv_legacy246d.lib
opencv_flann246d.lib

6b。 (对于 RELEASE 属性!)在下,链接器>输入>其他依赖项


opencv_core246.lib
opencv_imgproc246.lib
opencv_highgui246.lib
opencv_ml246.lib
opencv_video246.lib
opencv_features2d246.lib
opencv_calib3d246.lib
opencv_objdetect246.lib
opencv_contrib246.lib
opencv_legacy246.lib
opencv_flann246.lib

这应该足够了。如果在运行代码后缺少.dll窗口,请将所需的.dll从C:\opencv_built\build\x86\vc10\binC:\opencv_built\x86\vc10\bin复制到项目文件夹中。

关于c++ - 在VS 2008上启动OpenCV 2.4.6的致命错误,找不到文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19949032/

10-11 22:42
查看更多