Вопрос

I am using this tutorial to get started with OpenCV 2.4.6 on VS 2008: http://docs.opencv.org/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.html

I followed all instructions (my OpenCV is not in the default Program Files (x86) folder, it's in

C:\opencv_built

Unlike in the tutorial, I put very simple code, just to make sure all included files are reachable and if it builds successfully etc:

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

But I get a fatal error when I try to build:

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  

This is obviously referring to this line:

#include <opencv2/imgproc/imgproc.hpp>  // Gaussian Blur

I don't know where to find the dll files, or what to do next? I know this must be really easy but I've searched for any of the dll files, eg.

opencv_core243d.lib

but I get no search results.

Это было полезно?

Решение 3

Okay the fix was this:

Under Linker -> General -> Additional Library Dependencies

I put:

C:\opencv_built\lib\Debug

Другие советы

1. Check your path to \vc10 folder. It should be either:

C:\opencv_built\build\x86\vc10

or

C:\opencv_built\x86\vc10

2. Go to

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

Variable Name: OPENCV_DIR

Variable Value: Insert your path from step 1 here.


3. Open Visual Studio, make new project, go to Property Pages


4. Under C/C++ > Additional Include Directories

Insert $(OPENCV_DIR)\..\..\include


5. Under Linker > General > Additional Include Directories

Insert $(OPENCV_DIR)\lib


6a. (For DEBUG property!) Under Linker > Input > Additional Dependencies

Insert

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. (For RELEASE property!) Under Linker > Input > Additional Dependencies

Insert

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

This should be enough. If you get missing .dll window after running code, copy desired .dll from your C:\opencv_built\build\x86\vc10\bin or C:\opencv_built\x86\vc10\bin to your project folder.

It's not a dll file, it's a header file. The file is called imgproc.hpp

If you compiler can't find it it's either because it isn't there, or it's because you haven't told your compiler where to find it.

The important part for VS is the “Additional Include Directories”, look at that part again on the web page you followed.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top