need some basic openCV help (C++)

Soldato
Joined
15 Feb 2011
Posts
10,234
Location
Slough
After trying and failing to install it the 'complicated' way (making the libraries myself from the source code) I eventually gave up and installed it with the precompiled libraries. (this isn't the problem but it might have some bering on it so i figured i'd let you know).

I have followed the instructions to get openCV up and running in visual studios 2010 express and i am now trying to get the sample code at the bottom of the page running.

When i try to build it with the sample code as is, it will give me the error: cannot open include file 'opencv2/imgproc/imgproc.hpp'

When i change the paths in the "#include" lines to the full path imgproc seems to work but I get the same error with core instead. ie: cannot open include file 'opencv2/core/core.hpp'

I know the paths are correct because I've physically checked them about a million times now. I've even tried changing the slashes from forwards to backwards since win7 seems to think they are backslashes when i copy the full path as text and the sample code thinks i should use forward slashes

Any suggestions would be much appreciated because I've tried various solutions from people on the internet with exactly the same problem and nothing seems to work.
 
Caporegime
Joined
18 Oct 2002
Posts
32,623
Standard linker error really. I don't know visual studio (I use cmake and gcc) but somewhere you Need to set the right paths to the openCv headers and library's or the compiler.

The compiler is failing to find the header until you specify the full path, therefore it won't find the cpp file either.
 
Associate
Joined
9 Jun 2004
Posts
423
Quibble: it's a compiler error, not a linker error.

Anyway, don't change the #include directives to use full paths -- as you've noticed, you would have to change every single one, including those inside the library.

Instead you need to add the opencv2 "include" directory to your project-level include paths, so that those relative paths can be joined with that to product a valid full path by the compiler when it's searching.

VStudio makes this a pain because it's per-project/per-configuration (unless you use property sheets), in CMake (for example) it's totally trivial to add the a path to the include search directories.
 
Soldato
OP
Joined
15 Feb 2011
Posts
10,234
Location
Slough
Thank you for the help guys, it has definitely pointed me in the right direction. After digging around for a bit it looks like even the written guide to get things working with VS is out of date. I noticed that it was using libraries ending with 231 rather than 236 that I have, although even fixing that hasn't solved my problem.

I think the main problem is that they have messed about with the file structure compared to the version in the tutorial (or they haven't told me to mess about with the file structure at some point). For example, after plugging "setx -m OPENCV_DIR C:\openCV\build\x86\vc10" into the command prompt it says that I should have an include directory in that folder when i do not. i do however have an include folder with all the relevant files and folders in "C:\openCV\build"

Unfortunately that is about as far as I have got, so if any of you have any ideas on how to fix this then i would be all ears.
 
Back
Top Bottom