User Tools

Site Tools


opencv_tutorials_installation

This is an old revision of the document!


Tutorial Installing OpenCV 3.1 in Visual Studio 2015

1) Necessary Software

For the following tutorials was used OpenCV 3.1 in Visual Studio 2015. You will need to download the main OpenCV directory , and the opencv_contrib directory (it contains some advanced features that can be useful for us ). The Visual Studio 2015 and the CMAKE.

Download the OpenCV main file here (Select version 3.1.0 for your OS)

Download all the opencv_contrib directory here

Download the Visual Studio 2015 here(Visual Studio Community)

Download the CMAKE for your OS here.


Installation Instructions

  1. Install the CMAKE into your computer using the default installe that you downloaded.
  2. Install Visual Studio 2015 (try to create a new project , select Cinto the left , and select win32 console application ) IF YOU DON'T HAVE THE C++ OPTION , click into "click here and go online to find templates" , it should download some more files and then you are ready to go ). If you have the WIN32 Console application option in the Visual C++ tab you are OK to move into the next step ( no need to create the project ). - Execute the OpenCV 3.1 file and save in a directory that is easy to access ( Like C:/opencv ) - Save the opencv_contrib directory in a place that you have easy access ( Like c:/opencv_contrib ) - Open CMAKE , into the source directory choose c:/opencv/source and into the building directory choose c:/opencv/building - click generate ( it will ask for what version of Visual Studio that you have installed ). - Look for OPENCV_EXTRA_MODULES_PATH into the list that will appear into the CMAKE - click on the blank space and browse to the c:/opencv_contrib/modules - click generate again - click configure - Navigate into c:/opencv/build and double click the OpenCV solution archive (will open the Visual Studio) - On the right side , click with the right button into the INSTALL under the CmakeTarget folder and click BUILD.It can take a while be patient. - Close and open the Visual Studio again , click new project and under Visual C++ select Win32 COnsole application , save your project anywhere you want and create it. It will open a window ,on this window click Next and then select the "Empty Project" box. - On the Right side , right click into the source folder > add > new item. - Let the name as source and select C++ File.cpp as the type. - on the upper task bar (right bellow the Debug > GENERAL > Additional include directories add these two directories: C:\opencv\build\include and

C:\opencv\build\install\include

  1. Under Linker > General > Additional libraries directory add these two directories: C:\opencv\build\x64\vc14\lib (if you have windows 64 bits and are using Visual Studio 2015) and C:\opencv\build\install\include\opencv2
  2. Under Linker > INPUT> Additional Dependencies include the following libraries

<Code C++> opencv_calib3d310d.lib opencv_core310d.lib opencv_features2d310d.lib opencv_flann310d.lib opencv_highgui310d.lib opencv_imgcodecs310d.lib opencv_imgproc310d.lib opencv_ml310d.lib opencv_objdetect310d.lib opencv_photo310d.lib opencv_shape310d.lib opencv_stitching310d.lib opencv_superres310d.lib opencv_ts310d.lib opencv_video310d.lib opencv_videoio310d.lib opencv_videostab310d.lib opencv_xfeatures2d.lib </Code>


To test if you did everything right , on your source file try to type:

<Code C++> #include “opencv2/xfeatures2d/nonfree.hpp” #include <opencv/highgui.h> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> </Code>

If the Visual Studio does not underline this lines it is because you did everything right and the libraries are successfully linked to your Visual Studio and you are ready to go.


If you want other sources for installations you can check the official instructions or just google for Installation Instructions OpenCV for your operational system.

OpenCV Official Instructions

opencv_tutorials_installation.1465370135.txt.gz · Last modified: 2016/06/08 00:15 by joaomatos