11
OpenCV installation walkthrough Guide target This guide aims to describe all steps to install OpenCV on a Windows base system. It is not a replacement in any way of the official one that is by far the best place to start from but it target to address issues I had and that are probably related to new versions of the software involved or even to lack of knowledge on my side. Moreover, solutions reported here are taken from different forums/sites and you need to thank the original solver, just searching for them one by one could take big amount of time: they are here to save time and thanks to the original solver. Environment The machine is equipped with Windows 8.1 Pro 64bits. Same steps can be applied in 32 bits systems without small changes almost all related to installation packages. 10GB free for all the installations: they take space. What to build The target is to install OpenCV 2.4.10 with some feature enabled: TBB support (to have Haar Cascades generation faster) VTK support Qt support (to have same graphical environment for Windows, Linux and Raspberry development) Documentation enabled. These options are not mandatory and, depending on what you would like to do, can be leave disabled. Pre-requisites We need some software to being able to enable the feature listed above: OpenCV (version 2.4.10 is installed, http://opencv.org/downloads.html) The executable package is download, it will install OpenCV together with sources. We will use these sources to compile the MinGW version. TBB (Threading Building Blocks, Intel©, https://www.threadingbuildingblocks.org/download ) We are going to compile the package for our specific environment so sources have to be downloaded. VTK (The Visualization Toolkit, http://www.vtk.org/VTK/resources/software.html ) We are going to compile the package for our specific environment so sources have to be downloaded.

OpenCV installation walkthrough Web viewOpenCV installation walkthrough. Guide target. This guide aims to describe all steps to install OpenCV on a Windows base system. It is not a

  • Upload
    vubao

  • View
    239

  • Download
    3

Embed Size (px)

Citation preview

OpenCV installation walkthroughGuide target

This guide aims to describe all steps to install OpenCV on a Windows base system. It is not a replacement in any way of the official one that is by far the best place to start from but it target to address issues I had and that are probably related to new versions of the software involved or even to lack of knowledge on my side.

Moreover, solutions reported here are taken from different forums/sites and you need to thank the original solver, just searching for them one by one could take big amount of time: they are here to save time and thanks to the original solver.

Environment

The machine is equipped with Windows 8.1 Pro 64bits. Same steps can be applied in 32 bits systems without small changes almost all related to installation packages.

10GB free for all the installations: they take space.

What to build

The target is to install OpenCV 2.4.10 with some feature enabled:

TBB support (to have Haar Cascades generation faster)

VTK support

Qt support (to have same graphical environment for Windows, Linux and Raspberry development)

Documentation enabled.

These options are not mandatory and, depending on what you would like to do, can be leave disabled.

Pre-requisites

We need some software to being able to enable the feature listed above:

OpenCV (version 2.4.10 is installed, http://opencv.org/downloads.html) The executable package is download, it will install OpenCV together with sources. We will use these sources to compile the MinGW version.

TBB (Threading Building Blocks, Intel, https://www.threadingbuildingblocks.org/download) We are going to compile the package for our specific environment so sources have to be downloaded.

VTK (The Visualization Toolkit, http://www.vtk.org/VTK/resources/software.html) We are going to compile the package for our specific environment so sources have to be downloaded.

CMake (version 3.1.0, http://www.cmake.org/download)Binary installation package is available.

MikTex (TeX/LaTeX implementation, http://miktex.org/download)Binary installation package is available.

Qt5 (Qt5.4.0 package for with MinGW4.9.1, http://www.qt.io/download-open-source/#)Binary installation package is available.

Java (JDK7u80 64bit, https://jdk7.java.net/download.html) Binary installation package is available.

Python (2.7, Anaconda installation package, http://continuum.io/downloads) Binary installation package is available.

Sphinx (http://sphinxsearch.com/downloads/release) Binary installation package is available.

MinGW (version 4.9.1) This package will be installed with Qt5.4.0: we will use this one to compile other software we need.

Here are listed specific versions but the same process shall work with packages/sources more recent.

Even if not strictly mandatory I suggest to install all packages under a path without any space. The installation directory C:\Bin is used through this guide for all software.

Some environmental variable will be created and the PATH one will be modified so from the system applet or from regedit (Windows registry editor program) we will need to operate on these variables.

We will install the different software following the order below.

CMake installation

After downloading the package, current version is cmake-3.1.0-win32-x86.exe, execute and install it with defaults or change as per general suggestion above (i.e. installation path is C:\Bin\CMake). If the automatic modification of the path is selected I get an error reporting that the PATH is too long and the operation fails so I do it manually at the end of the installation, adding C:\Bin\CMake\bin in the PATH variable.

During the installation of VTK and OpenCV, that use CMake, it is assumed you use the default MinGW compiler that is automatically recognized after installing the Qt package.

MikTex installation

After package download, current is basic-miktex-2.9.5105.exe, accept defaults (changing the path if you want to) and proceed. I installed it under C:\Bin\MiKTeX2.9 and I add C:\Bin\MiKTeX2.9\miktex\bin to the path.

JDK installation

Download package jdk-7u80-ea-bin-b03-windows-x64-19_nov_2014.exe and run it. I installed it under C:\Bin\Java\jdk1.7.0_80. Follow the installation steps: nothing has to be done in addition.

Python

Download Anaconda-2.1.0-Windowsx-86_64.exe and install it. This versions comes with Numpy package already available so we will save time and problems. We will install it under C:\Bin\Anaconda. Follow the installation steps: nothing has to be done in addition.

Sphinx

Download sphinx-2.2.6-release-win64-full.zip and unzip it in C:\Bin\sphinx-2.2.6.

Change all occurrences of @CONFDIR@ with C:\Bin\sphinx-2.2.6 in the file sphinx.conf.in.

Open a command prompt as administrator and run the following command from the bin directory in the installation folder:

C:\Bin\sphinx-2.2.6\bin>searchd.exe --install --config c:\Bin\sphinx-2.2.6\sphinx.conf.in --servicename SphinxSearch

You should see something like:

Sphinx 2.2.6-id64-release (r4843)

Copyright (c) 2001-2014, Andrew Aksyonoff

Copyright (c) 2008-2014, Sphinx Technologies Inc (http://sphinxsearch.com)

Installing service...

Service 'SphinxSearch' installed successfully.

In any case, in the file doc/sphinx.txt it is described what to do for a correct installation.

Qt installation

Download package qt-opensource-windows-x86-mingw491_opengl-5.4.0.exe and run it. I installed it under C:\Bin\Qt\Qt5.4.0. When prompted in the installer add Tools -> Ming 4.9.1 option and leave the rest as default. Follow the installation steps.

At the end of the installation, add the MinGW binary directory to the PATH variable: C:\Bin\Qt\Qt5.4.0\Tools\mingw491_32\bin.

TBB compilation

Download tbb43_20141204oss_src.tgz and unzip it under C:\Bin. You will have following directory tree: C:\Bin\tbb43_20141204oss. When you unzip the tgz file another single file without extension named tbb43_20141204oss_src will be created. If you open it will the zip program (I used 7zip) it will be seen as an archive and you can unzip it properly. Inside the root directory, a file named Makefile is contained (in case you downloaded the binaries it will be not present).

We will now proceed to compile it. Open a command shell and issue the following command:

C:\Bin\tbb43_20141204oss>mingw32-make compiler=gcc

DLLs, i.e. tbb.dll, will be created in the build directory: C:\Bin\tbb43_20141204oss\build. We are interested in the C:\Bin\tbb43_20141204oss\build\windows_ia32_gcc_mingw4.9.1_release ones so we will now add this string to the PATH variable.

VTK compilation

Download VTK-6.1.0.zip and unzip it under C:\Bin. You will have following directory tree: C:\Bin\VTK-6.1.0. Before start compiling we need to patch a couple of files according to:

https://github.com/mxe/mxe/blob/master/src/vtk6-2-mingw-w64.patchThe patch is reported here.

diff -ur VTK6.0.0.rc3/IO/Video/vtkWin32VideoSource.cxx VTK6.0.0.rc3.new/IO/Video/vtkWin32VideoSource.cxx

--- VTK6.0.0.rc3/IO/Video/vtkWin32VideoSource.cxx2013-06-13 05:47:10.000000000 +1000

+++ VTK6.0.0.rc3.new/IO/Video/vtkWin32VideoSource.cxx2013-06-22 16:06:01.000000000 +1000

@@ -274,7 +274,7 @@

}

// set the user data to 'this'

- vtkSetWindowLong(this->Internal->ParentWnd,vtkGWL_USERDATA,(vtkLONG)this);

+ vtkSetWindowLong(this->Internal->ParentWnd,vtkGWL_USERDATA,(intptr_t)this);

// Create the capture window

this->Internal->CapWnd = capCreateCaptureWindow("Capture",

@@ -339,7 +339,7 @@

}

// set user data for callbacks

- if (!capSetUserData(this->Internal->CapWnd,(long)this))

+ if (!capSetUserData(this->Internal->CapWnd,(intptr_t)this))

{

vtkErrorMacro(