Something More for Research

Explorer of Research #HEMBAD

OpenCV 2.4.10 Complete Installation in Windows 8.1

Posted by Hemprasad Y. Badgujar on January 6, 2015


OpenCV 2.4.10 Complete Installation in Windows 8.1 with Own Libraries

The description here was tested on Windows 8.1 Pro. Nevertheless, it should also work on any other relatively modern version of Windows OS. If you encounter errors after following the steps described below, feel free to contact me.

Note :  To use the OpenCV library you have two options: Installation by Using the Pre-built Libraries or Installation by Making Your Own Libraries from the Source Files. While the first one is easier to complete, it only works if you are coding with the latest Microsoft Visual Studio IDE and doesn’t take advantage of the most advanced technologies we integrate into our library.

I am going to skip Installation by Using the Pre-built Libraries is it is easier to install even for New User. So Let’s Work on Installation by Making Your Own Libraries from the Source Files (If you are building your own libraries you can take the source files from OpenCV Git repository.) Building the OpenCV library from scratch requires a couple of tools installed beforehand

Prerequisites  Tools

Step By Step Prerequisites Setup

  • IDE : Microsoft Visual Studio. However, you can use any other IDE that has a valid CC++ compiler.

    Installing By Downloading from the Product Website Start installing Visual Studio by going to Visual Studio Downloads on the MSDN website and then choosing the edition you want to download.here we will going to use Visual Studio 2012 / ISO keys with  Visual Studio 2012 Update 4 / ISO and Step By Step Installing Visual Studio Professional 2012
  • Make Tool : Cmake is a cross-platform, open-source build system.

    Download and install the latest stable binary version: here we will going to use CMake 2.8 Choose the windows installer (cmake-x.y.z-win32.exe) and install it. Letting the cmake installer add itself to your path will make it easier but is not required.

  • Download OpenCV source Files by GIT/Sourceforge by : TortoiseGit or download source files from page on Sourceforge.

    The Open Source Computer Vision Library has >2500 algorithms, extensive documentation and sample code for real-time computer vision. It works on Windows, Linux, Mac OS X, Android and iOS.

  •  Python and Python libraries : Installation notes

    • It is recommended to uninstall any other Python distribution before installing Python(x,y)
    • You may update your Python(x,y) installation via individual package installers which are updated more frequently — see the plugins page
    • Please use the Issues page to request new features or report unknown bugs
    • Python(x,y) can be easily extended with other Python libraries because Python(x,y) is compatible with all Python modules installers: distutils installers (.exe), Python eggs (.egg), and all other NSIS (.exe) or MSI (.msi) setups which were built for Python 2.7 official distribution – see the plugins page for customizing options
    • Another Python(x,y) exclusive feature: all packages are optional (i.e. install only what you need)
    • Basemap users (data plotting on map projections): please see the AdditionalPlugins

Sphinx is a python documentation generator

  • After installation, you better add the Python executable directories to the environment variable PATH in order to run Python and package commands such as sphinx-build easily from the Command Prompt.

    • Right-click the “My Computer” icon and choose “Properties”

    • Click the “Environment Variables” button under the “Advanced” tab

    • If “Path” (or “PATH”) is already an entry in the “System variables” list, edit it. If it is not present, add a new variable called “PATH”.

    • Add these paths, separating entries by ”;”:

      • C:\Python27 – this folder contains the main Python executable
      • C:\Python27\Scripts – this folder will contain executables added by Python packages installed with easy_install (see below)

      This is for Python 2.7. If you use another version of Python or installed to a non-default location, change the digits “27” accordingly.

      After installation, you better add the Python executable directories to the environment variable PATH in order to run Python and package commands such as sphinx-build easily from the Command Prompt.

      • Right-click the “My Computer” icon and choose “Properties”

      • Click the “Environment Variables” button under the “Advanced” tab

      • If “Path” (or “PATH”) is already an entry in the “System variables” list, edit it. If it is not present, add a new variable called “PATH”.

      • Add these paths, separating entries by ”;”:

        • C:\Python27 – this folder contains the main Python executable
        • C:\Python27\Scripts – this folder will contain executables added by Python packages installed with pip (see below)

        This is for Python 2.7. If you use another version of Python or installed to a non-default location, change the digits “27” accordingly.

      • Now run the Command Prompt. After command prompt window appear, type python and Enter. If the Python installation was successful, the installed Python version is printed, and you are greeted by the prompt>>> . TypeCtrl+Z and Enter to quit.

      Install the pip command

      Python has a very useful pip command which can download and install 3rd-party libraries with a single command. This is provided by the Python Packaging Authority(PyPA): https://groups.google.com/forum/#!forum/pypa-dev

      To install pip, download https://bootstrap.pypa.io/get-pip.py and save it somewhere. After download, invoke the command prompt, go to the directory with get-pip.py and run this command:

      C:\> python get-pip.py
      

      Now pip command is installed. From there we can go to the Sphinx install.

      Note

      pip has been contained in the Python official installation after version
      of Python-3.4.0 or Python-2.7.9.

      Installing Sphinx with pip

      If you finished the installation of pip, type this line in the command prompt:

      C:\> pip install sphinx
      

      After installation, type sphinx-build -h on the command prompt. If everything worked fine, you will get a Sphinx version number and a list of options for this command.

      That it. Installation is over. Head to First Steps with Sphinx to make a Sphinx project.

    • Now run the Command Prompt. After command prompt window appear, type python and Enter. If the Python installation was successful, the installed Python version is printed, and you are greeted by the prompt>>> . TypeCtrl+Z and Enter to quit.

    Install the easy_install command

    Python has a very useful easy_install command which can download and install 3rd-party libraries with a single command. This is provided by the “setuptools” project: https://pypi.python.org/pypi/setuptools.

    To install setuptools, download https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py and save it somewhere. After download, invoke the command prompt, go to the directory with ez_setup.py and run this command:

    C:\> python ez_setup.py
    

    Now setuptools and its easy_install command is installed. From there we can go to the Sphinx install.

    Installing Sphinx with easy_install

    If you finished the installation of setuptools, type this line in the command prompt:

    C:\> easy_install sphinx
    

    After installation, type sphinx-build on the command prompt. If everything worked fine, you will get a Sphinx version number and a list of options for this command.

  • Numpy is a scientific computing package for Python. Required for the Python interface.

Try the (unofficial) binaries in this site: http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
You can get numpy 1.6.2 x64 with or without Intel MKL libs to Python 2.7

I suggest WinPython, a Python 2.7 distribution for Windows with both 32- and 64-bit versions.

It is also worth considering the Anaconda Python distribution. http://continuum.io/downloads

  • Numpy :Required for the Python interface abve Installation of python alosho included with Numpy and Scipy libraries

  • Intel © Threading Building Blocks (TBB) is used inside OpenCV for parallel code snippets. Download Here

    • Download TBB
      • Go to TBB download page to download the open source binary releases. I choose Commercial Aligned Release, because this has the most stable releases. I downloaded tbb43_20141204os, TBB 4.3 Update 3, specifically tbb43_20141204os for Windows. The release has the header files as well as the import library and DLL files prebuilt for Microsoft Visual C++ 8.0 and 9.0 on both x86(IA32) and x64(intel64). If you are aggressive and need the source code of TBB, you can try stable releases or development releases.
    • Install TBB
      • Extract the files in the zip file to a local directory, for example, C:\TBB. You should find tbb22_013oss under it. This is the installation directory, and doc, example, include etc should be directly under the installation folder.
      • Set a Windows environment variable TBB22_INSTALL_DIR to the above directory, e.g., C:\TBB\tbb22_013oss.
    • Develop with TBB
      • Add $(TBB22_INSTALL_DIR)\include to your C++ project’s additional include directories.
      • Add $(TBB22_INSTALL_DIR)\<arch>\<compiler>\lib (e.g., $(TBB22_INSTALL_DIR)\ia32\vc9\lib) to your project’s additional library directories.
      • Add to your project’s additional dependencies tbb.lib (Release) or tbb_debug.lib (Debug).
      • Write your C++ code to use TBB. See code below as an example.
    • Deploy with TBB
      • The TBB runtime is in TBB DLLs (tbb.dll/tbbmalloc.dll/tbbmalloc_proxy.dll for Release, tbb_debug.dll/tbbmalloc_debug.dll/tbbmalloc_proxy_debug.dll for Debug). They can be found in $(TBB22_INSTALL_DIR)\\\bin.
      • Your executable should have these DLLs in the same folder for execution.

     

  • Intel © Integrated Performance Primitives (IPP) may be used to improve the performance of color conversion.(Paid)

    Intel Parallel Studio XE 2015 – Cluster Edition includes everything in the Professional edition (compilers, performance libraries, parallel models, performance profiler, threading design/prototyping, and memory & thread debugger). It adds a MPI cluster communications library, along with MPI error checking and tuning to design, build, debug and tune fast parallel code that includes MPI.

  • Eigen is a C++ template library for linear algebra.

     “install” Eigen?

    In order to use Eigen, you just need to download and extract Eigen‘s source code (see the wiki for download instructions). In fact, the header files in the Eigen subdirectory are the only files required to compile programs using Eigen. The header files are the same for all platforms. It is not necessary to use CMake or install anything.

     simple first program

    Here is a rather simple program to get you started.

    #include <iostream>
    #include <Eigen/Dense>
     int main()
    {
    MatrixXd m(2,2);
    m(0,0) = 3;
    m(1,0) = 2.5;
    m(0,1) = -1;
    m(1,1) = m(1,0) + m(0,1);
    std::cout << m << std::endl;
    }
  • Installing CUDA Development Tools

    The setup of CUDA development tools on a system running the appropriate version of Windows consists of a few simple steps:

    • Verify the system has a CUDA-capable GPU.
    • Download the NVIDIA CUDA Toolkit.
    • Install the NVIDIA CUDA Toolkit.
    • Test that the installed software runs correctly and communicates with the hardware.
    • CUDA Toolkit will allow you to use the power lying inside your GPU. we will going to use CUDA 6.0 Toolkit

      To verify that your GPU is CUDA-capable, open the Control Panel (StartControl > Panel) and double click on System. In the System Properties window that opens, click the Hardware tab, then Device Manager. Expand the Display adapters entry. There you will find the vendor name and model of your graphics card. If it is an NVIDIA card that is listed inhttp://developer.nvidia.com/cuda-gpus, your GPU is CUDA-capable.

      The Release Notes for the CUDA Toolkit also contain a list of supported products.

       Download the NVIDIA CUDA Toolkit

      The NVIDIA CUDA Toolkit is available at http://developer.nvidia.com/cuda-downloads.

      Choose the platform you are using and download the NVIDIA CUDA Toolkit

      The CUDA Toolkit contains the CUDA driver and tools needed to create, build and run a CUDA application as well as libraries, header files, CUDA samples source code, and other resources.

      Download Verification

      The download can be verified by comparing the MD5 checksum posted at http://developer.nvidia.com/cuda-downloads/checksums with that of the downloaded file. If either of the checksums differ, the downloaded file is corrupt and needs to be downloaded again.

      To calculate the MD5 checksum of the downloaded file, follow the instructions at http://support.microsoft.com/kb/889768.

      Install the CUDA Software

      Before installing the toolkit, you should read the Release Notes, as they provide details on installation and software functionality.

      Note: The driver and toolkit must be installed for CUDA to function. If you have not installed a stand-alone driver, install the driver from the NVIDIA CUDA Toolkit.

      Graphical Installation

      Install the CUDA Software by executing the CUDA installer and following the on-screen prompts.

      Silent Installation

      Alternatively, the installer can be executed in silent mode by executing the package with the -s flag. Additional flags can be passed which will install specific subpackages instead of all packages. Allowed subpackage names are: CUDAToolkit_6.5, CUDASamples_6.5, CUDAVisualStudioIntegration_6.5, and Display.Driver. For example, to install only the driver and the toolkit components:

      .exe -s CUDAToolkit_6.5 Display.Driver

      This will drastically improve performance for some algorithms (e.g the HOG descriptor). Getting more and more of our algorithms to work on the GPUs is a constant effort of the OpenCV .

  • JRE :Java run time environment

    Installing Ant The binary distribution of Ant consists of the following directory layout:

      ant
       +--- README, LICENSE, fetch.xml, other text files. //basic information
       +--- bin  // contains launcher scripts
       |
       +--- lib  // contains Ant jars plus necessary dependencies
       |
       +--- docs // contains documentation
       |      |
       |      +--- images  // various logos for html documentation
       |      |
       |      +--- manual  // Ant documentation (a must read ;-)
       |
       +--- etc // contains xsl goodies to:
                //   - create an enhanced report from xml output of various tasks.
                //   - migrate your build files and get rid of 'deprecated' warning
                //   - ... and more ;-)
    

    Only the bin and lib directories are required to run Ant. To install Ant, choose a directory and copy the distribution files there. This directory will be known as ANT_HOME.

Before you can run Ant there is some additional set up you will need to do unless you are installing the RPM version from jpackage.org:

  • Add the bin directory to your path.
  • Set the ANT_HOME environment variable to the directory where you installed Ant. On some operating systems, Ant’s startup scripts can guess ANT_HOME (Unix dialects and Windows NT/2000), but it is better to not rely on this behavior.
  • Optionally, set the JAVA_HOME environment variable (see the Advanced section below). This should be set to the directory where your JDK is installed.

Operating System-specific instructions for doing this from the command line are in the Windows, Linux/Unix (bash), and Linux/Unix (csh) sections. Note that using this method, the settings will only be valid for the command line session you run them in. Note: Do not install Ant’s ant.jar file into the lib/ext directory of the JDK/JRE. Ant is an application, whilst the extension directory is intended for JDK extensions. In particular there are security restrictions on the classes which may be loaded by an extension.

Windows Note:
The ant.bat script makes use of three environment variables – ANT_HOME, CLASSPATH and JAVA_HOME. Ensure that ANT_HOME and JAVA_HOME variables are set, and that they do not have quotes (either ‘ or “) and they do not end with \ or with /. CLASSPATH should be unset or empty.

Check Installation

You can check the basic installation with opening a new shell and typing ant. You should get a message like this

Buildfile: build.xml does not exist!
Build failed

So Ant works. This message is there because you need to write an individual buildfile for your project. With a ant -version you should get an output like

Apache Ant(TM) version 1.9.2 compiled on July 8 2013

If this does not work ensure your environment variables are set right. They must resolve to:

  • required: %ANT_HOME%\bin\ant.bat
  • optional: %JAVA_HOME%\bin\java.exe
  • required: %PATH%=…maybe-other-entries…;%ANT_HOME%\bin;…maybe-other-entries

ANT_HOME is used by the launcher script for finding the libraries. JAVA_HOME is used by the launcher for finding the JDK/JRE to use. (JDK is recommended as some tasks require the java tools.) If not set, the launcher tries to find one via the %PATH% environment variable. PATH is set for user convenience. With that set you can just start ant instead of always typingthe/complete/path/to/your/ant/installation/bin/ant.

  • OpenEXR source files are required for the library to work with this high dynamic range (HDR) image file format.

  • OpenNI Framework contains a set of open source APIs that provide support for natural interaction with devices.

    Guideline How to Install OpenNI 2.0 + Nite 2.0 + Kinect SDK 1.8 + windows 7 32/64 bit
    
    UPDATED [14th January 2013]
    
    Kinect Installation Guide Document[ View / Download]
    https://docs.google.com/file/d/0B3e4_6C5_YOjcmZpak12Q2MyZHM/edit 
    
    Kinect Installation Video [download]
    https://drive.google.com/file/d/0B3e4_6C5_YOjQjRXMUNnNW5xN3M/edit?usp=sharing
    
    Step 1
    
    Download File Required
    Kinect SDK 1.8  
    Web ~ http://www.microsoft.com/en-us/kinectforwindows/develop/developer-downloads.aspx
    
    Kinect Developer Toolkits 1.8 ~ https://drive.google.com/file/d/0B3e4_6C5_YOjaW85QzVKR2lYVkU/edit?usp=sharing
    KinectRuntime 1.8 ~ https://drive.google.com/file/d/0B3e4_6C5_YOjS1dGdHcwMjJGWDQ/edit?usp=sharing
    Kinect SDK 1.8 ~ https://drive.google.com/file/d/0B3e4_6C5_YOjeUowcDhUNmRMV0U/edit?usp=sharing
    
    OpenNI 2.2  32bits / 64bits
    http://www.openni.org/openni-sdk/
    or
    http://structure.io/openni
    
    OpenNi 32 bit ~ https://drive.google.com/file/d/0B3e4_6C5_YOjMS1EQWh6VFhWbnc/edit?usp=sharing
    OpenNi 64 bit ~ https://drive.google.com/file/d/0B3e4_6C5_YOjYmVPQzhwazhBOUE/edit?usp=sharing
    Nite 2.2 
    http://www.openni.org/files/nite/
    
    Nite 32 bit ~ https://drive.google.com/file/d/0B3e4_6C5_YOjQWtCcVl3VnRsWG8/edit?usp=sharing
    Nite 64 bit ~https://drive.google.com/file/d/0B3e4_6C5_YOjOGIySEluYkNibEE/edit?usp=sharing
    
    Step 2
    a. Install Kinect for Windows SDK
    b. Install OpenNI 2.2 SDK  32bits / 64bits  ( install both 64 bits and 32bits if u are using win64)
    c. Install  Nite 2.2  ( install both 64 bits and 32bits if u are using win64)
    
    Step 3
    Run NiViewer.exe for Testing.  It will be located at
    
    64bits 
    ~ (OpenNI ) C:\Program Files\OpenNI2\Samples\Bin
    ~ (Prime Sensor) C:\Program Files\PrimeSense\NiTE2\Samples\Bin
    
    32bits 
    ~(OpenNI )  C:\Program Files (x86) \OpenNI2\Samples\Bin
    ~ (Prime Sensor) C:\Program Files (x86) \PrimeSense\NiTE2\Samples\Bin
    
    Programmer Guide
    http://www.openni.org/openni-programmers-guide/
  • Miktex is the best TEX implementation on the Windows OS. but we will use lyx

    Install the programs found below in the order shown.

    1. Install MiKTeX This is the core program used byLyx to output nice documents. After installing it, make sure thatMiKTeX is able to install missing packages on-the-fly. To do this, go toStart→Programs→MiKTeX→MiKTeX Options →General→Package installation→Ask me first.
      Note: You should be able to use other LaTeX packages instead of MikTeX. One example is TeXLive, a CD-based version.
    2. Install Ghostscript. Thisis used to create Postscript documents, as well as for viewing .ps and .eps files insideLyX.
    3. Install ImageMagick (choose the file “ImageMagick-6.x.x-Q16-windows-dll.exe”). ImageMagickis used to convert images into formats thatLyX can understand.
    4. Optionally, install GSview, which lets you view Postscript files. Thisis recommended.
    5. Optionally, install a PDF viewer, if you do not already have one. This is also recommended. Adobe Reader is the most common. Alternates include the more compact Foxit reader and GSview, which shows PDF files in addition to Postscript.
    6. Download these math fonts math and install them in windows fonts folder. To install the fonts useStart→Settings→Control Panel→Fonts and thenFile→Install New Font. These fontsare used to display symbols in theLyX math editor.
    7. Finally, install LyX 1.4.1 for Windows. Installing it last ensures that it can find the programs listed above. If you install or update one of those programs later, go to Reconfigure in the Tools menu to make LyX look for it.
  • Kinect for Windows SDK, which is a free download for Kinet Support

  • Environment Editor : Rapid Environment Editor

  • OpenGL SDK and Libraries

  • Cg Toolkit Download

  • QT for GUI (for X64) and Visual Studio Add-in 1.2.4 for Qt5

    Extract it into a directory like C:\Qt Open a shell, cd to the directory containing the extracted Qt files and enter the following command:

    configure.exe -release -no-webkit -no-phonon -no-phonon-backend -no-script -no-scripttools
                  -no-qt3support -no-multimedia -no-ltcg

    This will take around 10 minutes. Then enter the next command that will take a lot longer (can easily take even more than a full hour): make Create a system environment variable QTDIR : C:\Qt\qt-everywhere-opensource-src-4.8.2 Add %QTDIR%\bin at the front of the system PATH.

    setx -m QTDIR D:/OpenCV/dep/qt/qt-everywhere-opensource-src
    1. Now start the CMake (cmake-gui). You may again enter it in the start menu search or get it from the All Programs ‣ CMake 2.8 ‣ CMake (cmake-gui). First, select the directory for the source files of the OpenCV library (1). Then, specify a directory where you will build the binary files for OpenCV (2).

      Select the directoriesPress the Configure button to specify the compiler (and IDE) you want to use. Note that in case you can choose between different compilers for making either 64 bit or 32 bit libraries. Select the one you use in your application development. How CMake should look at build time.CMake will start out and based on your system variables will try to automatically locate as many packages as possible. You can modify the packages to use for the build in the WITH ‣ WITH_X menu points (where X is the package abbreviation). Here are a list of current packages you can turn on or off: The packages OpenCV may useSelect all the packages you want to use and press again the Configure button. For an easier overview of the build options make sure the Grouped option under the binary directory selection is turned on. For some of the packages CMake may not find all of the required files or directories. In case of these CMake will throw an error in its output window (located at the bottom of the GUI) and set its field values, to not found constants. For example: Constant for not found packagesError (warning) thrown in output window of the CMake GUIFor these you need to manually set the queried directories or files path. After this press again the Configure button to see if the value entered by you was accepted or not. Do this until all entries are good and you cannot see errors in the field/value or the output part of the GUI. Now I want to emphasize an option that you will definitely love: ENABLE ‣ ENABLE_SOLUTION_FOLDERS. OpenCV will create many-many projects and turning this option will make sure that they are categorized inside directories in the Solution Explorer. It is a must have feature, if you ask me. Set the Solution Folders and the parts you want to buildFurthermore, you need to select what part of OpenCV you want to build.

      • BUILD_DOCS -> It creates two projects for building the documentation of OpenCV (there will be a separate project for building the HTML and the PDF files). Note that these aren’t built together with the solution. You need to make an explicit build project command on these to do so.
      • BUILD_EXAMPLES -> OpenCV comes with many example applications from which you may learn most of the libraries capabilities. This will also come handy to easily try out if OpenCV is fully functional on your computer.
      • BUILD_PACKAGE -> Prior to version 2.3 with this you could build a project that will build an OpenCV installer. With this you can easily install your OpenCV flavor on other systems. For the latest source files of OpenCV it generates a new project that simply creates zip archive with OpenCV sources.
      • BUILD_SHARED_LIBS -> With this you can control to build DLL files (when turned on) or static library files (*.lib) otherwise.
      • BUILD_TESTS -> Each module of OpenCV has a test project assigned to it. Building these test projects is also a good way to try out, that the modules work just as expected on your system too.
      • BUILD_PERF_TESTS -> There are also performance tests for many OpenCV functions. If you’re concerned about performance, build them and run.
      • BUILD_opencv_python -> Self-explanatory. Create the binaries to useOpenCV from the Python language.While building VTK6.1 with Qt5.2.1 (MSVC2012_64_opengl prebuilt binary) using MSVC2012_x64 on Windows 8.1,
      • I got the following error message:
        CMake Error at C:/Qt/Qt5.2.1/5.2.1/msvc2012_64_opengl/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:16 (message): Failed to find “glu32″ in “” with CMAKE_CXX_LIBRARY_ARCHITECTURE “”.Call Stack (most recent call first): C:/Qt/Qt5.2.1/5.2.1/msvc2012_64_opengl/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:52(_qt5gui_find_extra_libs) C:/Qt/Qt5.2.1/5.2.1/msvc2012_64_opengl/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:152 (include) C:/Qt/Qt5.2.1/5.2.1/msvc2012_64_opengl/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake:94 find_package) GUISupport/Qt/CMakeLists.txt:58 (find_package)
        I checked VTK_GROUP_QT, Module_vtkGUISupportQt, Module_vtkGUISupportQtOpenGL, and set QT version to 5. CMake found the following three DIR’s:
        Qt5Core_DIR = C:/Qt/Qt5.2.1/5.2.1/msvc2012_64_opengl/lib/cmake/Qt5Core
        Qt5Gui_DIR = C:/Qt/Qt5.2.1/5.2.1/msvc2012_64_opengl/lib/cmake/Qt5Gui
        Qt5Widgets_DIR = C:/Qt/Qt5.2.1/5.2.1/msvc2012_64_opengl/lib/cmake/Qt5Widgets
        My problems was solved. On CMake, I added this entry:
        CMAKE_PREFIX_PATH: C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64
        for my Windows 8.1 x64 version.

        File:Cmake-add-cache-entry-arrow.png

      Press again the Configure button and ensure no errors are reported. If this is the case you can tell CMake to create the project files by pushing the Generate button. Go to the build directory and open the created OpenCV solution. Depending on just how much of the above options you have selected the solution may contain quite a lot of projects so be tolerant on the IDE at the startup. Now you need to build both the Release and the Debug binaries. Use the drop-down menu on your IDE to change to another of these after building for one of them. you will get Checking for Windows (Phone) Platform SDK 8.0/8.1 Checking for Visual Studio 2012/2013 Looking for Mfapi.h Looking for Mfapi.h – found found IPP: 8.1.1 [8.1.1] at: C:/Program Files (x86)/Intel/Composer XE/ipp IPP libs: ippvmmt.lib;ippccmt.lib;ippcvmt.lib;ippimt.lib;ippsmt.lib;ippcoremt.lib IPP libs: ippvmmt.lib;ippccmt.lib;ippcvmt.lib;ippimt.lib;ippsmt.lib;ippcoremt.lib CUDA detected: 6.0 CUDA NVCC target flags: -gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_30,code=compute_30 Found Sphinx 1.2.3: C:/Python27/Scripts/sphinx-build.exe Found apache ant 1.9.4: C:/apache-ant/bin/ant.bat VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file Assume that non-module dependency is available: cudart (for module opencv_core) Assume that non-module dependency is available: nppc (for module opencv_core) Assume that non-module dependency is available: nppi (for module opencv_core) Assume that non-module dependency is available: npps (for module opencv_core) General configuration for OpenCV 2.4.10 ===================================== Version control: unknown Platform: Host: Windows 6.2 AMD64 CMake: 2.8.12.2 CMake generator: Visual Studio 11 Win64 CMake build tool: C:/PROGRA~2/MICROS~1.0/Common7/IDE/devenv.com MSVC: 1700 C/C++: Built as dynamic libs?: YES C++ Compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/x86_amd64/cl.exe (ver 17.0.61030.0) C++ flags (Release): /DWIN32 /D_WINDOWS /W4 /GR /EHa /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /wd4251 /MD /O2 /Ob2 /D NDEBUG /Zi C++ flags (Debug): /DWIN32 /D_WINDOWS /W4 /GR /EHa /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /wd4251 /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 C Compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/x86_amd64/cl.exe C flags (Release): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /MD /O2 /Ob2 /D NDEBUG /Zi C flags (Debug): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 Linker flags (Release): /machine:x64 /INCREMENTAL:NO /debug Linker flags (Debug): /machine:x64 /debug /INCREMENTAL Precompiled headers: YES OpenCV modules: To be built: core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib java python stitching superres ts videostab Disabled: world Disabled by dependency: – Unavailable: androidcamera dynamicuda viz Windows RT support: NO GUI: QT 5.x: YES (ver 5.4.0) QT OpenGL support: YES (Qt5::OpenGL 5.4.0) OpenGL support: YES (glu32 opengl32) VTK support: NO Media I/O: ZLib: build (ver 1.2.7) JPEG: build (ver 62) PNG: build (ver 1.5.12) TIFF: build (ver 42 – 4.0.2) JPEG 2000: build (ver 1.900.1) OpenEXR: NO Video I/O: Video for Windows: YES DC1394 1.x: NO DC1394 2.x: NO FFMPEG: YES (prebuilt binaries) codec: YES (ver 55.18.102) format: YES (ver 55.12.100) util: YES (ver 52.38.100) swscale: YES (ver 2.3.100) gentoo-style: YES OpenNI: YES (ver 1.3.3, build 6) OpenNI PrimeSensor Modules: YES (C:/Program Files/PrimeSense/Sensor/Bin64/XnCore64.dll) PvAPI: NO GigEVisionSDK: NO DirectShow: YES Media Foundation: YES XIMEA: NO Intel PerC: NO Other third-party libraries: Use IPP: 8.1.1 [8.1.1] at: C:/Program Files (x86)/Intel/Composer XE/ipp Use Eigen: YES (ver ..) Use TBB: YES (ver 4.3 interface 8000) Use OpenMP: NO Use GCD NO Use Concurrency NO Use C=: NO Use Cuda: YES (ver 6.0) Use OpenCL: YES NVIDIA CUDA Use CUFFT: YES Use CUBLAS: YES USE NVCUVID: YES NVIDIA GPU arch: 20 21 30 35 NVIDIA PTX archs: 30 Use fast math: YES OpenCL: Version: dynamic Include path: E:/opencv/sources/3rdparty/include/opencl/1.2 Use AMD FFT: NO Use AMD BLAS: NO Python: Interpreter: C:/Python27/python.exe (ver 2.7.9) Libraries: C:/Python27/libs/python27.lib (ver 2.7.9+) numpy: C:/Python27/lib/site-packages/numpy/core/include (ver 1.8.2) packages path: C:/Python27/Lib/site-packages Java: ant: C:/apache-ant/bin/ant.bat (ver 1.9.4) JNI: C:/Program Files/Java/jdk1.7.0_60/include C:/Program Files/Java/jdk1.7.0_60/include/win32 C:/Program Files/Java/jdk1.7.0_60/include Java tests: YES Documentation: Build Documentation: YES Sphinx: C:/Python27/Scripts/sphinx-build.exe (ver 1.2.3) PdfLaTeX compiler: C:/Program Files/MiKTeX 2.9/miktex/bin/x64/pdflatex.exe Tests and samples: Tests: YES Performance tests: YES C/C++ Examples: NO Install path: E:/opencv/build/install cvconfig.h is in: E:/opencv/build —————————————————————– Configuring done Generating done Look here for changing the Build Type   In the end you can observe the built binary files inside the bin directory: The Result of the build. For the documentation you need to explicitly issue the build commands on the doc project for the PDF files and on the doc_html for the HTML ones. Each of these will call Sphinx to do all the hard work. You can find the generated documentation inside the Build/Doc/_html for the HTML pages and within the Build/Doc the PDF manuals. The Documentation Projects To collect the header and the binary files, that you will use during your own projects, into a separate directory (simillary to how the pre-built binaries ship) you need to explicitely build the Install project. The Install Project This will create an Install directory inside the Build one collecting all the built binaries into a single place. Use this only after you built both the Release and Debugversions. To test your build just go into the Build/bin/Debug or Build/bin/Release directory and start a couple of applications like the contours.exe. If they run, you are done. Otherwise, something definitely went awfully wrong. In this case you should contact us at our Q&A forum. If everything is okay the contours.exe output should resemble the following image (if built with Qt support): A good output result

      Note

      If you use the GPU module (CUDA libraries) make sure you also upgrade to the latest drivers of your GPU. Error messages containing invalid entries in (or cannot find) the nvcuda.dll are caused mostly by old video card drivers. For testing the GPU (if built) run the performance_gpu.exe sample application.

    Set the OpenCV enviroment variable and add it to the systems path

    First we set an enviroment variable to make easier our work. This will hold the build directory of our OpenCV library that we use in our projects. Start up a command window and enter:

    setx -m OPENCV_DIR D:\OpenCV\Build\x86\vc11     (suggested for Visual Studio 2012 - 32 bit Windows)
    setx -m OPENCV_DIR D:\OpenCV\Build\x64\vc11     (suggested for Visual Studio 2012 - 64 bit Windows)

    Here the directory is where you have your OpenCV binaries (extracted or built). You can have different platform (e.g. x64 instead of x86) or compiler type, so substitute appropriate value. Inside this you should have two folders called lib and bin. The -m should be added if you wish to make the settings computer wise, instead of user wise. If you built static libraries then you are done. Otherwise, you need to add the bin folders path to the systems path. This is cause you will use the OpenCV library in form of“Dynamic-link libraries” (also known as DLL). Inside these are stored all the algorithms and information the OpenCV library contains. The operating system will load them only on demand, during runtime. However, to do this he needs to know where they are. The systems PATH contains a list of folders where DLLs can be found. Add the OpenCV library path to this and the OS will know where to look if he ever needs the OpenCV binaries. Otherwise, you will need to copy the used DLLs right beside the applications executable file (exe) for the OS to find it, which is highly unpleasent if you work on many projects. To do this start up again the Path Editor and add the following new entry (right click in the application to bring up the menu):

    %OPENCV_DIR%\bin

    Right click to insert new path manually.Add the entry.Save it to the registry and you are done. If you ever change the location of your build directories or want to try out your applicaton with a different build all you will need to do is to update the OPENCV_DIR variable via the setx command inside a command window.

    build applications with OpenCV inside the Microsoft Visual Studio

    Everything I describe here will apply to the C\C++ interface of OpenCV. I start out from the assumption that you have read and completed with success the Installation in Windows tutorial. Therefore, before you go any further make sure you have an OpenCV directory that contains the OpenCV header files plus binaries and you have set the environment variables as described here. You should have a folder looking like this. The OpenCV libraries, distributed by us, on the Microsoft Windows operating system are in a Dynamic Linked Libraries (DLL). These have the advantage that all the content of the library are loaded only at runtime, on demand, and that countless programs may use the same library file. This means that if you have ten applications using the OpenCV library, no need to have around a version for each one of them. Of course you need to have the dll of the OpenCV on all systems where you want to run your application. Another approach is to use static libraries that have lib extensions. You may build these by using our source files as described in the Installation in Windows tutorial. When you use this the library will be built-in inside your exe file. So there is no chance that the user deletes them, for some reason. As a drawback your application will be larger one and as, it will take more time to load it during its startup. To build an application with OpenCV you need to do two things:

    • Tell to the compiler how the OpenCV library looks. You do this by showing it the header files.

    • Tell to the linker from where to get the functions or data structures of OpenCV, when they are needed.

      If you use the lib system you must set the path where the library files are and specify in which one of them to look. During the build the linker will look into these libraries and add the definitions and implementation of all used functions and data structures to the executable file. If you use the DLL system you must again specify all this, however now for a different reason. This is a Microsoft OS specific stuff. It seems that the linker needs to know that where in the DLL to search for the data structure or function at the runtime. This information is stored inside lib files. Nevertheless, they aren’t static libraries. They are so called import libraries. This is why when you make some DLLs in Windows you will also end up with some lib extension libraries. The good part is that at runtime only the DLL is required.

    To pass on all this information to the Visual Studio IDE you can either do it globally (so all your future projects will get these information) or locally (so only for you current project). The advantage of the global one is that you only need to do it once; however, it may be undesirable to clump all your projects all the time with all these information. In case of the global one how you do it depends on the Microsoft Visual Studio you use. There is a 2008 and previous versions and a 2010 way of doing it. Inside the global section of this tutorial I’ll show what the main differences are. The base item of a project in Visual Studio is a solution. A solution may contain multiple projects. Projects are the building blocks of an application. Every project will realize something and you will have a main project in which you can put together this project puzzle. In case of the many simple applications (like many of the tutorials will be) you do not need to break down the application into modules. In these cases your main project will be the only existing one. Now go create a new solution inside Visual studio by going through the File ‣ New ‣ Project menu selection. Choose Win32 Console Application as type. Enter its name and select the path where to create it. Then in the upcoming dialog make sure you create an empty project. Which options to select

    The local method

    Every project is built separately from the others. Due to this every project has its own rule package. Inside this rule packages are stored all the information the IDE needs to know to build your project. For any application there are at least two build modes: a Release and a Debug one. The Debug has many features that exist so you can find and resolve easier bugs inside your application. In contrast the Release is an optimized version, where the goal is to make the application run as fast as possible or to be as small as possible. You may figure that these modes also require different rules to use during build. Therefore, there exist different rule packages for each of your build modes. These rule packages are called inside the IDE as project properties and you can view and modify them by using the Property Manger. You can bring up this withView ‣ Property Pages. Expand it and you can see the existing rule packages (called Proporty Sheets). An example of Property SheetThe really useful stuff of these is that you may create a rule package once and you can later just add it to your new projects. Create it once and reuse it later. We want to create a new Property Sheet that will contain all the rules that the compiler and linker needs to know. Of course we will need a separate one for the Debug and the Release Builds. Start up with the Debug one as shown in the image below: Add a new Property SheetUse for example the OpenCV_Debug name. Then by selecting the sheet Right Click ‣ Properties. In the following I will show to set the OpenCV rules locally, as I find unnecessary to pollute projects with custom rules that I do not use it. Go the C++ groups General entry and under the “Additional Include Directories” add the path to your OpenCV include. If you don’t have “C/C++” group, you should add any .c/.cpp file to the project.

    $(OPENCV_DIR)\..\..\include
    

    Add the include dir like this.When adding third party libraries settings it is generally a good idea to use the power behind the environment variables. The full location of the OpenCV library may change on each system. Moreover, you may even end up yourself with moving the install directory for some reason. If you would give explicit paths inside your property sheet your project will end up not working when you pass it further to someone else who has a different OpenCV install path. Moreover, fixing this would require to manually modifying every explicit path. A more elegant solution is to use the environment variables. Anything that you put inside a parenthesis started with a dollar sign will be replaced at runtime with the current environment variables value. Here comes in play the environment variable setting we already made in our previous tutorial. Next go to the Linker ‣ General and under the “Additional Library Directories” add the libs directory:

    $(OPENCV_DIR)\lib
    

    Add the library folder like this.Then you need to specify the libraries in which the linker should look into. To do this go to the Linker ‣ Input and under the “Additional Dependencies” entry add the name of all modules which you want to use: Add the debug library names here.Like this.The names of the libraries are as follow:

    opencv_(The Name of the module)(The version Number of the library you use)d.lib
    

    A full list, for the latest version would contain:

    opencv_calib3d2410d.lib opencv_contrib2410d.lib opencv_core2410d.lib opencv_features2d2410d.lib opencv_flann2410d.lib opencv_gpu2410d.lib opencv_haartraining_engined.lib opencv_highgui2410d.lib opencv_imgproc2410d.lib opencv_legacy2410d.lib opencv_ml2410d.lib opencv_nonfree2410d.lib opencv_objdetect2410d.lib opencv_ocl2410d.lib opencv_photo2410d.lib opencv_stitching2410dd.lib opencv_superres2410d.lib opencv_ts2410d.lib opencv_video2410d.lib opencv_videostab2410d.lib The letter d at the end just indicates that these are the libraries required for the debug. Now click ok to save and do the same with a new property inside the Release rule section. Make sure to omit the d letters from the library names and to save the property sheets with the save icon above them. cv2.lib opencv_calib3d2410.lib opencv_contrib2410.lib opencv_core2410.lib opencv_features2d2410.lib opencv_flann2410.lib opencv_gpu2410.lib opencv_haartraining_engine.lib opencv_highgui2410.lib opencv_imgproc2410.lib opencv_java2410.lib opencv_legacy2410.lib opencv_ml2410.lib opencv_nonfree2410.lib opencv_objdetect2410.lib opencv_ocl2410.lib opencv_photo2410.lib opencv_stitching2410.lib opencv_superres2410.lib opencv_ts2410.lib opencv_video2410.lib opencv_videostab2410.lib

    And the release ones.You can find your property sheets inside your projects directory. At this point it is a wise decision to back them up into some special directory, to always have them at hand in the future, whenever you create an OpenCV project. Note that for Visual Studio 2010 the file extension is props, while for 2008 this is vsprops. And the release ones.Next time when you make a new OpenCV project just use the “Add Existing Property Sheet…” menu entry inside the Property Manager to easily add the OpenCV build rules. Use this option.

    The global method

    In case you find to troublesome to add the property pages to each and every one of your projects you can also add this rules to a “global property page”. However, this applies only to the additional include and library directories. The name of the libraries to use you still need to specify manually by using for instance: a Property page. In Visual Studio 2008 you can find this under the: Tools ‣ Options ‣ Projects and Solutions ‣ VC++ Directories. VC++ Directories in VS 2008.In Visual Studio 2010 this has been moved to a global property sheet which is automatically added to every project you create: VC++ Directories in VS 2010.The process is the same as described in case of the local approach. Just add the include directories by using the environment variable OPENCV_DIR.

    Test it!

    Now to try this out download our little test source code or get it from the sample code folder of the OpenCV sources. Add this to your project and build it. Here’s its content:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <iostream>
    
    using namespace cv;
    using namespace std;
    
    int main( int argc, char** argv )
    {
        if( argc != 2)
        {
         cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
         return -1;
        }
    
        Mat image;
        image = imread(argv[1], IMREAD_COLOR); // Read the file
    
        if(! image.data ) // Check for invalid input
        {
            cout << "Could not open or find the image" << std::endl ;
            return -1;
        }
    
        namedWindow( "Display window", WINDOW_AUTOSIZE ); // Create a window for display.
        imshow( "Display window", image ); // Show our image inside it.
    
        waitKey(0); // Wait for a keystroke in the window
        return 0;
    }
    

    You can start a Visual Studio build from two places. Either inside from the IDE (keyboard combination: Control-F5) or by navigating to your build directory and start the application with a double click. The catch is that these two aren’t the same. When you start it from the IDE its current working directory is the projects directory, while otherwise it is the folder where the application file currently is (so usually your build directory). Moreover, in case of starting from the IDE the console window will not close once finished. It will wait for a keystroke of yours. This is important to remember when you code inside the code open and save commands. You’re resources will be saved ( and queried for at opening!!!) relatively to your working directory. This is unless you give a full, explicit path as parameter for the I/O functions. In the code above we open this OpenCV logo. Before starting up the application make sure you place the image file in your current working directory. Modify the image file name inside the code to try it out on other images too. Run it and voilá: You should have this.

    Command line arguments with Visual Studio

    Throughout some of our future tutorials you’ll see that the programs main input method will be by giving a runtime argument. To do this you can just start up a commmand windows (cmd + Enter in the start menu), navigate to your executable file and start it with an argument. So for example in case of my upper project this would look like:

    1
    2
    3
    D:
    CD OpenCV\MySolutionName\Release
    MySolutionName.exe exampleImage.jpg
    

    Here I first changed my drive (if your project isn’t on the OS local drive), navigated to my project and start it with an example image argument. While under Linux system it is common to fiddle around with the console window on the Microsoft Windows many people come to use it almost never. Besides, adding the same argument again and again while you are testing your application is, somewhat, a cumbersome task. Luckily, in the Visual Studio there is a menu to automate all this: Visual Studio Command Line ArgumentsSpecify here the name of the inputs and while you start your application from the Visual Studio enviroment you have automatic argument passing.

Advertisements

One Response to “OpenCV 2.4.10 Complete Installation in Windows 8.1”

  1. Regarding finding Qt 5 in CMake for OpenCV, here is a note about the change in variable used to find Qt: http://bugs.mitk.org/show_bug.cgi?id=17816#c8. It states, in part:

    “In the Qt4 case, passing QT_QMAKE_EXECUTABLE was the standard solution to tell projects about a specific Qt4 installation. With Qt5 this seems to have changed. Qt5 installations are now located in CMake via an entry in CMAKE_PREFIX_PATH so using QT_QMAKE_EXECUTABLE doesn’t seeem to be necessary for Qt5 any more. …”

    Thanks for this useful guide.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Extracts from a Personal Diary

dedicated to the life of a silent girl who eventually learnt to open up

Num3ri v 2.0

I miei numeri - seconda versione

ThuyDX

Just another WordPress.com site

Algunos Intereses de Abraham Zamudio Chauca

Matematica, Linux , Programacion Serial , Programacion Paralela (CPU - GPU) , Cluster de Computadores , Software Cientifico

josephdung

thoughts...

Tech_Raj

A great WordPress.com site

Travel tips

Travel tips

Experience the real life.....!!!

Shurwaat achi honi chahiye ...

Ronzii's Blog

Just your average geek's blog

Karan Jitendra Thakkar

Everything I think. Everything I do. Right here.

VentureBeat

News About Tech, Money and Innovation

Chetan Solanki

Helpful to u, if u need it.....

ScreenCrush

Explorer of Research #HEMBAD

managedCUDA

Explorer of Research #HEMBAD

siddheshsathe

A great WordPress.com site

Ari's

This is My Space so Dont Mess With IT !!

%d bloggers like this: