User Tools

Site Tools


opencv_tutorials_installation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
opencv_tutorials_installation [2016/06/08 00:15] joaomatosopencv_tutorials_installation [2016/09/05 14:38] (current) jadintredup
Line 1: Line 1:
-===== Tutorial Installing OpenCV 3.1 in Visual Studio 2015 =====+===== Installing OpenCV 3.1.0 with Visual Studio 2015 =====
  
-**1) Necessary Software**+=== Part 1: Download the necessary Files ===
  
- 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**.+  * Visual Studio 2015 can be downloaded for free at [[https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx | Visual Studio 2015]].
  
 +  * OpenCV 3.1.0 is the latest release of OpenCV and most currently supported for Visual Studio 2015. It can be cloned from its git repository at [[https://github.com/opencv/opencv | OpenCV]]. We will clone the repository into a new directory C:\OpenCV
  
 +  * Cmake is required to build the libraries from the source code provided by the git repository. Cmake can be downloaded from [[https://cmake.org/download/ | CMake]]. Be sure to download the correct version for your system.
  
-[[http://opencv.org/downloads.html|Download the OpenCV main file here (Select version 3.1.0 for your OS)]] 
  
-[[https://github.com/Itseez/opencv_contrib|Download all the opencv_contrib directory here]]+----
  
-[[https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx|Download the Visual Studio 2015 here(Visual Studio Community)]]+==== Part 2Building the Binaries Using CMake ====
  
-[[https://cmake.org/download/|Download the CMAKE for your OS here.]]+  - Open your OpenCV directory and create a new directory called "mybuild" so that the path is C:\OpenCV\mybuild 
 +  - Start CMake and 
  
 +2.1) Install the OpenCV 2.4.13 that you downloaded into your PC. Choose an easy to find directory , like C:>OpenCV . When the installation is done , you will see two folders inside the OpenCV folder ( Build and Source ). 
  
 +2.2) Create a new folder called OpenCV-Build into an easy to find  directory , like C:OpenCV-Build.
  
 +2.3) Open the CMAKE and on the box "Where the source code is " Select the folder OpenCV > Source (Generated by the OpenCV installation) . On the box "Where to build the binaries" Select the folder OpenCV-Build that you created. 
  
-----+2.4) Click one time in Generate (it will ask for you to select your compiler , choose the Visual Studio version that you are using) , and after generating is complete click in Configure. You will get some errors but it is OK because we are only installing the OpenCV without any other 3rd party libraries. 
  
-===== Installation Instructions =====+2.5) Go to the OpenCV-Build folder and open the ALLBUILD visual studio solution. 
  
-  - Install the CMAKE into your computer using the default installe that you downloaded. +2.6) On the top Taskbar , select Debug and x64(if you have windows 64 bits or x86 (if you have windows 32 bits ) . After that right click the install on the right side of the window and select BUILD.  It will take some time and you will get some errors (because some 3rd party libraries are missing but thats OK )
-  - Install Visual Studio 2015 (try to create a new project , select C++ into 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|Team|Tools ) , select Debug and x64 (if you have windows 64 bits) +
-  - Right click into the name of your project on the right side and click properties. +
-  - Under C/C++ > GENERAL > Additional include directories add these two directories: C:\opencv\build\include and  +
-C:\opencv\build\install\include  +
-  - 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 +
-  - Under Linker > INPUT> Additional Dependencies include the following libraries+
  
-<Code C++>+2.7) Repeat 2.7 using the Release instead of Debug. 
 + 
 +2.8) Close the visual studio and open again . Select new project > Visual C++ and select win32 Console Application. Choose the folder where do you want to save it ( can be anywhere ) and select a name. Click OK , it will pop up a window , select next , check the "empty project" box ( don't change the other options) and click OK. 
 + 
 +2.9) Select Debug and x64(if you have windows 64 bits ) or x86 (if you have windows 32 bits). 
 + 
 +2.10) Right click on the source files folder on the solution explorer (right side of the window). Click in add > new item. Select Visual C++ in the left ,  click on c++ File (.cpp) and then OK. 
 + 
 +2.11) On the Solution explorer (right side ) , right click into your project name > properties. 
 + 
 +2.12) On the top , Configuration select Debug , and platform select all. 
 + 
 +2.13) On the left , select C/C++ > general. Into the additional include directory , add the directory : OpenCV-Build > install > include. 
 + 
 +2.14) On the left , select Linker> general. Into the additional library directory add the directory: OpenCV-Build > install > x64 (or x86 depending on your Windows bits) > vc14 > lib. 
 + 
 +2.15) On the left , select Linker > input. Into additional dependencies paste the following libraries: 
 +<Code>
 opencv_calib3d310d.lib opencv_calib3d310d.lib
 +opencv_flann310d.lib
 opencv_core310d.lib opencv_core310d.lib
 opencv_features2d310d.lib opencv_features2d310d.lib
-opencv_flann310d.lib 
 opencv_highgui310d.lib opencv_highgui310d.lib
-opencv_imgcodecs310d.lib 
-opencv_imgproc310d.lib 
 opencv_ml310d.lib opencv_ml310d.lib
 opencv_objdetect310d.lib opencv_objdetect310d.lib
 +opencv_imgproc310d.lib
 +opencv_video310d.lib
 +opencv_imgcodecs310d.lib
 opencv_photo310d.lib opencv_photo310d.lib
 opencv_shape310d.lib opencv_shape310d.lib
-opencv_stitching310d.lib 
 opencv_superres310d.lib opencv_superres310d.lib
 opencv_ts310d.lib opencv_ts310d.lib
-opencv_video310d.lib 
 opencv_videoio310d.lib opencv_videoio310d.lib
 opencv_videostab310d.lib opencv_videostab310d.lib
-opencv_xfeatures2d.lib 
 </Code> </Code>
  
 +2.16) Repeat 2.12) 2.13) 2.14) using Release configuration. In the step 2.15) you must paste the libraries names without the "d" on the final , for example opencv_calib3d310.lib instead of opencv_calib3d310d.lib.
  
----- +2.17) Close the Visual Studio.
- +
-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.+2.18) Go to your files explorer , right click into your PC icon > properties. Select advanced system settings > environment variables. Into the system variables box , find the Path variable , click to edit it. Click in new and then select your directory : OpenCV-Build > install > x64 (orx86) > vc14 > bin.
  
 +2.19) Restart your PC.
  
-[[http://docs.opencv.org/3.1.0/d3/d52/tutorial_windows_install.html#gsc.tab=0|OpenCV Official Instructions]]+2.20) Open Visual Studio again , and open the project that you created following the previous stepsIf you did everything OK you are good to go.
  
 +2.21) Copy and paste any example on the Tutorials section and see if it is running OK.
  
opencv_tutorials_installation.1465370135.txt.gz · Last modified: 2016/06/08 00:15 by joaomatos