How do I start developing with OpenCV3.1 and opencv_contrib in Visual Studio?

asked 2016-12-19 10:58:49 -0600

dma156 gravatar image

I want to be able to develop my openCV code in VS, my version is Professional 2015, Version 14.0.24720.00 Update 1. I had intially just downloaded the OpenCV 3.1 executable and then linked my projects to the files from that, but then realised it did not have the extra face.hpp libraries.

So I followed this answer here on this stackoverflow question, which helped me compile x64 openCV3.1 with the extra opencv_contrib modules, but now my question is how do I create a project and have the dependencies for OCV3.1 with the extra modules configured?

Current OpenCV solution in Visual Studio:

image description

edit retag flag offensive close merge delete

Comments

1

If you have build opencv using cmake and you are a beginner it is better to build opencv with examples. In CMake GUI BUILD_EXAMPLES must be checked.

For your own project you can copy Cmake example in your folder an run cmake gui and select this folder. CMake will make you sln for your project.

LBerger gravatar imageLBerger ( 2016-12-19 11:10:36 -0600 )edit

By the cmake example stuff, do you mean copy the contents of that to the build folder? Then the sln will be built by CMake for the Cmake example files?

dma156 gravatar imagedma156 ( 2016-12-19 11:36:53 -0600 )edit

Example :

  1. create c:/MySourceProject and copy this file
  2. copy my own cmakelist all cpp and .h will be included in project
  3. run CMake GUI and select "where is the source code" source c:/MySourceProject
  4. select "where to build binaries" source c:/MySourceProject/build
  5. press configure and select Visual studi 14 2015 win64
  6. if cmake cannot find Opencv give path whereyou build opencv
  7. press generate and open project and build your program

Normally you can run your program (check image path file)

LBerger gravatar imageLBerger ( 2016-12-19 11:52:20 -0600 )edit

I'm not sure whether you can help with this new error that I have encountered, (btw thanks for all your help so far), but I cannot run your exampleProject or any of the examples from OpenCV. I use the Local Windows Debugger and I get a message saying "Unable to start program C:\ExampleProject\build\x64\Debug\ALL_BUILD. Access is Denied."

dma156 gravatar imagedma156 ( 2016-12-19 15:43:48 -0600 )edit

When you open solution you have three projects ALL_BUILD ZERO_CHECK and HOMOMORPHIC select HOMOMORPHIC as starter project in visual studio and run

LBerger gravatar imageLBerger ( 2016-12-19 18:52:27 -0600 )edit

It now tries to run but now it says I'm missing the dlls Opencv_highgui310d.dll Opencv_imgcodecs310d.dll Opencv_imgproc310d.dll Opencv_core310d.dll I don't have a bin folder anymore, just lib, I think this is to do with needing the vc14 folder path

dma156 gravatar imagedma156 ( 2016-12-20 07:04:27 -0600 )edit

Dll are in {path where you build opencv}/bin/{DEBUG|RELEASE}

you can add this these path to enviromment path or copy dll where is your exe. Last method is disk memory consumming because for all your project you will have to do it but it solves your problem

LBerger gravatar imageLBerger ( 2016-12-20 07:09:21 -0600 )edit

Project runs now, but the Homomorphic project itself generates an unhandled exception and that the image was null. Anyway, if I create a project within the Homomorphic Solution now, and I have this general piece of C++ code called "Display.cpp" for simply displaying an image using OpenCV, how do I get the CV dependencies linked? Do I need to configure the Project VC++ directories and the Input under Linker?

dma156 gravatar imagedma156 ( 2016-12-20 08:26:03 -0600 )edit

About image give a path to an image saved in your PC

Don't create a project in Homomorphic solution. Copy CMakeList.txt where you want. Change in CMakeList.txt Homomorphic name in my project everywhere (https://github.com/LaurentBerger/Homo... L8 and L11 and L18, and start process again and you have a new solution. CMake can detect many things like opencv qt4 qt5 wxwidgets...

You can add in previous solution like here in each folder I have got a CMakelists.txt

LBerger gravatar imageLBerger ( 2016-12-20 09:47:33 -0600 )edit