Guide: How to Build OpenCV 3.0.0


Published on

A tutorial teaching how to build and use OpenCV v.3.0.0 using Visual Studio 2013.

Published in: Technology
  • Thanks. This saved me some time. In addtion you could also hint optional step of building opencv contribution modules, by adding the OPENCV > OPENCV_EXTRA_MODULES_PATH. Also optionally build python wrappers by setting PYTHON2 > PYTHON2_INCLUDE_DIR to C:/Python27/include and PYTHON2_LIBRARY to C:/Python27/libs/python27.lib.
    Are you sure you want to  Yes  No
    Your message goes here
  • ok this is weird after almost 299 errors i cleanesd and compiled and got the same number of errors, but then i compiled again without cleaning and then i got no errors and OpenCV was finally built... that was weird... so the solution was to compile twice? o.O
    Are you sure you want to  Yes  No
    Your message goes here
  • a bunch of errors like that one error 90 but with different numbers depending of the module where the error was found @André
    Are you sure you want to  Yes  No
    Your message goes here
  • Error 90 error : The system was unable to find the specified registry key or value. C:\opencv\custombuild\modules\core\CUSTOMBUILD opencv_core
    Are you sure you want to  Yes  No
    Your message goes here
  • @Diego Hernandez Reyes Could you please point out the error in more details?
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Guide: How to Build OpenCV 3.0.0

  1. 1. BUILDING OPENCV 3.0.0 YOURSELF André Moreira June, 2014
  2. 2. WHO I AM ... # My name is André de Souza Moreira; # Msc. Candidate at PUC-RIO; # Researcher at Instituto Tecgraf in Computer Graphics; # Before: Researcher at NCA in Medical Image Processing.
  3. 3. WHAT IS OPENCV? # It’s an open source library written in C++ for computer vision. # It was originally designed by Intel. # There are several bidings to others languagens like Python and Java. # Runs on Windows, Android, Linux, OS X and others. # Offers CUDA and OpenCL Interface. # Its last release version is 2.4.9 but you can acquire 3.0.0 version (under development) on github (June, 2014).
  4. 4. GOALS # Making a simple building of OpenCV 3.0.0 with Visual Studio 2013; # Running an OpenCV example; # Linking the library against a new project in Visual Studio 2013.
  6. 6. Step : Get the Source Code # Available at # Option 1: Download directly from the website 1
  7. 7. Step : Get the Source COde # Option 2: Clone the git repository: # The advantage of this method consists of tracking changes from the original repository. So, you can rebuild the library whenever there is a new feature... 1 $ git clone
  8. 8. Step : Install dependencies # There are a lot dependencies you can use in opencv building, such as: Qt, Python, Opengl, pdflatex to generate the documentation, CUDA, OpenCL and others... # For example, you can install the python 2.7.x and numpy in order to build python wrapper. 2
  9. 9. # Install the Cmake Tool • Available on # Open cmake-gui, configure where the library’s source code is (1) and where the project’s files will be generated (2). Finally, click in Configure button (3). Step : Preparing the Project 3 (1) (2) (3)
  10. 10. # Select the project that will be generated. • In our case is Visual Studio 2013. (No, I did not choose the wrong option, the generator for Visual Studio 2013 is really called Visual Studio 12!) ;P Step : Preparing the Project 3
  11. 11. # Cmake will show you some build options: • BUILD: set what gonna be built. • WITH: The library takes advantage of others technologies like CUDA. • INSTALL: Which files will be put in the installation folder. • CMAKE/CMAKE_INSTAL_PREFIX: Set the default installation folder. # After choosing, click Configure button again. If everything is OK, all the red background will disappear. # Finally, click in the Generate button. Step : Preparing the Project 3
  12. 12. My Options:
  14. 14. # Go to the build folder and open the Visual Studio Solution (Opencv.sln) # Select the build mode (1) and then build the project ALL_BUILD (2). (This step will build all the projects shown in the Solution Explorer Guide) # If no errors occurs, build the INSTALL project (3). (Installs the artifacts) Step : Building the Project 4 (1) (2) (3)
  15. 15. # Copy all the .dll in {INSTALL_DIRECTORY} x64vc12bin to: • C:WindowsSystem32 if the library was built in x64 • C:WindowsSysWOW64 if the library was built in x86 # At this point, you can run any sample and it should works without error. # Copy all files in {INSTALL_DIRECTORY} x64vc12lib to {VISUALSTUDIO_DIRECTORY}VClib (x86) or {VISUALSTUDIO_DIRECTORY}VClibamd64 (x64) # Copy the two folders in {INSTALL_DIRECTORY} include to {VISUALSTUDIO_DIRECTORY}VCinclude Step : Installing the library 5
  16. 16. RUN THE SAMPLES # You can run the examples from {INSTALL_DIRECTORY} x64vc12samples* and check if everything is OK. • Running cppcpp-example-delaunay2.exe:
  17. 17. Link Against the Library # Create a new project (CTRL+SHIFT+N). # Go to DEBUG > {projectName} Properties (Alt + F7) # List the modules’ name you need in Linker > Input > Additional Dependencies: • Example:
  18. 18. Link Against the Library # Create a cpp file (CTRL+SHIFT+A) and run it (CTRL+F5): #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/opencv.hpp> #include <stdlib.h> #include <stdio.h> using namespace cv; /** @function main */ int main(int argc, char** argv) { Mat src, src_gray, dst; int kernel_size = 3; int scale = 1; int delta = 0; int ddepth = CV_16S; char* window_name = "Laplace Demo"; /// Load your image src = imread("myImage.jpg"); if (! { return -1; } /// Remove noise by blurring with a Gaussian filter GaussianBlur(src, src, Size(3, 3), 0, 0, BORDER_DEFAULT); /// Convert the image to grayscale cvtColor(src, src_gray, COLOR_RGB2GRAY); /// Create window namedWindow(window_name, WINDOW_AUTOSIZE); /// Apply Laplace function Mat abs_dst; Laplacian(src_gray, dst, ddepth, kernel_size, scale, delta, BORDER_DEFAULT); convertScaleAbs(dst, abs_dst); /// Show what you got imshow(window_name, abs_dst); waitKey(0); return 0; }
  19. 19. The Result Ref:
  20. 20. Need Help? # The Official Documentation: • # The Stackoverflow Community: • # OpenCV’s Install Guide: • # This Great Book: ;) OpenCV Computer Vision Application Programming Cookbook (2nd Edition), Robert Laganiere. ISBN-13: 9781782161486 Publisher: Packt Publishing Publication date: 8/1/2014 Pages: 390
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.