Step by step: Recipe to setup a Visual Studio 2013 project with both (integrated) latest Aruco "library" version and OpenCV 3.0.0

8:29 AM

Sometimes, we need to do deep modifications in Aruco library for our projects. So it may be convenient to incorporate a big chunck of its files in our customized projects. Here you have the Visual Studio 2013 setup I use, step by step.

Open Visual Studio 2013
Click on New Proyect. It will show a window with predefined templates. Surprisingly, there is no Visual C++ x64 templates in the menu. So, you can choose Win32 Console Application, and write the preferred location of the project.
I usually chose Empty project in the Application Settings window, later you can take one of the example files of Aruco as the main file to begin with.
Select the Project upper menu and click on Properties (ALT + F7)
Click on Configuration Manager button and chose twice a New Active Solution Platform: x64 for Debug and Release configurations.
Check in the Property pages that Target Machine is set to MachineX64 in Configuration Properties / Linker / Advanced

Now, we do have a simple x64 generic project, that must be setup to use OpenCV 3.0.0
Library names have changed in 3.0.0 version, so now it's much easier to include the .lib and .dll files
We'll suppose OpenCV is compiled already (it can be build from scratch, but it has a lot of dependencies to solve in Windows platforms), as it is provided in the Windows release in OpenCV website.
We have to tell Visual Studio where the header files are: Configuration Properties / C/C++ / Additional Include Directories (both Debug and Release configurations). In my case: C:\libraries\openCV\3.0.0\build\include;
Also, we have to communicate Visual Studio which and where the library files are: Configuration Properties / Linker / General / Additional Library Directories 
C:\libraries\openCV\3.0.0\build\x64\vc12\lib;
So, the .lib files must be included in Configuration Properties / Linker / General / Additional Dependencies. They are different for debug and release configurations, because symbols and optimized code:
Debug setup: opencv_ts300d.lib; opencv_world300d.lib;
Release setup: opencv_ts300.lib; opencv_world300.lib;
Fortunately, it is cleaner and simpler than previous OpenCV versions.
You can copy  file to Debug and Release folders (if you do not have included its folder in the PATH).

A simple OpenCV application should compile with this setup.
Aruco library needs some more tweaks in Visual Studio 2013.
I add most of files as source files in the project (everything but highlyreliablemarkers and chromaticmask).


On one hand, markerdetector requires OpenMP support in the last versions of Aruco. So,
Properties / C/C++ / Language / Open MP Support  has to be switched to Yes (/openmp)

On the other hand, Visual Studio 2013 has not the same broad support for C++, so lots of annoying warnings are spread out while compiling:
warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
To avoid this messy output that hinder the important messages, that particular warining may be muted. 
#pragma warning( disable : 4290 ) // at the beggining of the main file

Some deprecation code errors:
marker.cpp(230): error C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
It is easy to eliminate by wirting _CRT_SECURE_NO_WARNINGS as a constant in Configuration Properties / C/C++ / Preprocessor Definitions

Finally, if you do not want to be bothered by PDB warning messages:
Tools -> Options -> Debugging -> Output Window -> Module Load Messages -> Off 
It will disable the display of modules loaded.

You Might Also Like

0 comentarios

Popular Posts

Like us on Facebook

Flickr Images