Visual Servoing Platform  version 3.1.0
Tutorial: Installation from source for Windows with Visual C++ 2013 (vc12)

In this tutorial you will learn how to install ViSP from source on Windows 8.1 or 10.0 with Visual C++ 2013. These steps have been tested on Windows 10.0 (64 bit), with CMake 3.9.6 and Visual Studio Express 2013.

Note
Concerning ViSP installation, we provide also other Tutorials.

Install prerequisities

  • Visual Studio C++. Note that ViSP can also be build with Visual Studio Express that could be downloaded from http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products. In this tutorial we use Visual Studio Express 2013.
    Note
    If you want to use Visual Studio Express, you have to install Express 2013 for Windows Desktop. The Desktop version is important to work with CMake.
  • CMake that could be download at : http://www.cmake.org. Download the latest release for Windows win64-x64 platform (at the time this tuto was written it was the file cmake-3.9.6-win64-x64.msi). To install just double click on the msi file.

Create a workspace

First create a workspace that will contain all ViSP and optional 3rd parties. This workspace is here set to C:\workspace folder, but it could be set to any other location. To create the workspace:

  • Open a cmd terminal (in your "Start" menu click on "Run" and type in cmd.exe) and run:
    C:\> mkdir C:\workspace

Install 3rd parties

ViSP is interfaced with several 3rd party libraries. The complete list is provided here. If you are with Windows 8.1 we recommend to install Windows SDK 3rd party. We recommend also to install OpenCV 3rd party. Other 3rd parties like Ogre3D 3rd party are optional and should be considered only by expert developers.

Windows SDK 3rd party

If you are under Windows 8.1 we recommend to install the "Windows Software Development Kit (SDK) for windows 8.1" to get the Graphical Device Interface (GDI) capabilities. The GDI is used in ViSP to display images in a window thanks to vpDisplayGDI class.

OpenCV 3rd party

1. Get OpenCV

First you have to get OpenCV:

  • From http://opencv.org/releases.html download OpenCV 3.0.0 for Windows. In our case we got opencv-3.0.0.exe Win pack installer.
  • Extract the content of the archive in C:\workspace.
    img-win10-extract-opencv.png
  • The installer extracted all the material in C:\workspace\opencv.
    Note
    OpenCV 3.0.0 windows installer contains pre-build libraries compatible with Visual C++ 2013 (vc12) in C:\workspace\opencv\build\x64\vc12 and also libraries compatible with Visual C++ 2012 (vc11) in C:\workspace\opencv\build\x64\vc11. With a more recent OpenCV release you need to build yourself OpenCV from source with Visual C++ 2013 (vc12) as it is done in Tutorial: Installation from source for Windows with Visual C++ 2017 (vc15).
  • We strongly recommend to rename this folder to a name that contain OpenCV version like C:\workspace\opencv-3.0.0.

2. Complete OpenCV installation

Now you have to complete OpenCV installation setting some environment vars:

  • In order that ViSP detects OpenCV you have to set OpenCV_DIR environment variable. Start up a cmd terminal and enter:
    C:\> setx OpenCV_DIR "C:\workspace\opencv-3.0.0\build"
    where C:\workspace\opencv-3.0.0\build is where you have installed OpenCV. Inside this folder you should have a file named OpenCVConfig.cmake.
  • You have also to add the location of OpenCV libraries in the PATH environment variable following the indications mentioned in Setting up PATH variable.

librealsense 3rd party

I you have an Intel RealSense Depth camera (F200, SR300, R200, LR200, ZR300, and D400 series cameras), you may install librealsense 1.12.1. Otherwise you can skip this section.

Note
There is also librealsense 2.x.y, but ViSP is not compatible yet with this version, that is why we recommend to install the last stable release 1.12.1.

1. Get librealsense 1.12.1

  • Get librealsense 1.12.1 source code from github
      C:\> cd C:\workspace
      C:\> git clone https://github.com/IntelRealSense/librealsense.git librealsense-1.12.1
      C:\> cd librealsense-1.12.1
      C:\> git checkout tags/v1.12.1
    
  • Here we suppose that you have librealsense source code in C:\workspace\librealsense-1.12.1 folder.

2. Configure librealsense 1.12.1

  • Launch CMake (cmake-gui), complete the source code and build locations as in the next image to set the location of the build to C:/workspace/librealsense-1.12.1/build-vc12:
    img-cmake-win10-msvc12-realsense-config.png
  • Click then on "Configure" button and accept the creation of the build directory by a click on "Yes" button.
  • Select then your compiler "Visual Studio 12 2013 Win64" and click on "Finish" button.
  • Modify CMAKE_INSTALL_PREFIX var to C:/workspace/librealsense-1.12.1/build-vc12 folder location.
    img-cmake-win10-msvc12-realsense-install.png
  • Click again on "Configure" button. All the red lines should disappear.
  • To finish the configuration, click on "Generate" button.

3. Install librealsense 1.12.1

  • To build librealsense just double click on C:/workspace/librealsense-1.12.1/Realsense.sln solution file. This action will open Realsense project in Visual Studio C++ 12 2013.
  • Select Release configuration and build INSTALL target
    img-win10-msvc12-realsense-build.png
  • After these steps, librealsense library could be found in C:/workspace/librealsense-1.12.1/build-vc12/bin/realsense.dll

4. Complete librealsense 1.12.1 installation

  • Set REALSENSE_DIR environment variable:
    C:\> setx REALSENSE_DIR "C:\workspace\librealsense-1.12.1\build-vc12"
  • You have also to add the location of librealsense library in the PATH environment variable following the indications mentioned in Setting up PATH variable.

Ogre3D 3rd party

Warning
Ogre3D installation from source code described in this section is reserved to expert users.

If you are interested in augmented reality (see vpAROgre), or if you want to enable advanced visibility computation during model-based tracking (see vpMbTracker::setOgreVisibilityTest() and Tutorial: Markerless model-based tracking) we recommend to install Ogre3D. You can check if a prebuild SDK matches your Visual C++ version, and follow the SDK installation instructions. You can also install the lastest release from source. Based on our experience, this is what we recommend.

Ogre source code is hosted on BitBucket. On Ogre wiki you will find useful information to build and install Ogre from source. Hereafter we give the main steps.

1. Get Ogre prerequisities

  • To build Ogre on Windows you will need to install the DirectX SDK. Since Windows 8, DirectX is no longer a standalone package, rather it is bundled in the Windows 8.x SDK. The latest version is the Windows 8.1 SDK.
  • To get the Ogre source code but also the source code of all the dependencies hosted on BitBucket and available with Mercurial, you have to install TortoiseHg.

2. Get Ogre dependencies

  • A repository containing Ogre dependencies source code is available here at BitBucket.
  • Open an explorer window, and enter in TortoiseHg Clone menu. Select as source https://bitbucket.org/cabalistic/ogredeps and as destination C:\Ogre\ogredeps as in the next image:
    img-win10-ogredeps-tortoisehg.png
  • Click on "Clone" button to get dependencies source code in C:\workspace\ogredeps

3. Build Ogre dependencies

  • To build the dependencies, open CMake GUI and set source code location pointing to C:\workspace\ogredeps and build location pointing to C:\workspace\ogredeps\build-vc12. Select Visual Studio 12 2013 Win64 as generator, click on "Configure" button twice and then on "Generate" button. You should have something similar to the next image:
    img-cmake-win10-msvc12-ogredeps.png
  • Open C:\workspace\ogredeps\build-vc12\OGREDEPS.sln solution file with Visual C++.
  • In Visual, select Debug configuration and build INSTALL project:
    img-win10-msvc12-build-ogredeps.png
    Note
    If the build fails due to the environment variable DXSDK_DIR that is not set, see Unable to build ogredeps: DXSDK_DIR missing for a work arround.
  • In Visual, select also Release configuration and build again INSTALL project.
    img-win10-msvc12-build-ogredeps-install-release.png
  • Now in C:\workspace\ogredeps\build-vc12\ogredeps\bin you will find the cg.dll and OIS.dll dependencies build in Debug and Release:
  • To finish dependencies installation, set OGRE_DEPENDENCIES_DIR environment variable pointing to C:\workspace\ogredeps\build-vc12\ogredeps
    C:\> setx OGRE_DEPENDENCIES_DIR C:\workspace\ogredeps\build-vc12\ogredeps

4. Get Ogre source

  • From Ogre download page, identify the last release. In our case Ogre 1.10.9 that is on BitBucket repository under branch v1-10-9.
  • Open an explorer window, and enter in TortoiseHg Clone menu. Select as source https://bitbucket.org/sinbad/ogre, as destination C:\workspace\ogre and select revision v1-10-9 corresponding to the branch of the latest release as presented in the next image:
    img-win10-ogre-tortoisehg.png
  • Click on "Clone" button to get Ogre source code in C:\workspace\ogre

5. Build Ogre source

  • Close and re-open CMake Gui. Set source code location pointing to C:\workspace\ogre and build location pointing to C:\workspace\ogre\build-vc12. Select "Visual Studio 12 2013 Win64" as generator, click on "Configure" button and then on "Generate" button. You should have something similar to the next image:
    img-cmake-win10-msvc12-ogre.png
    Note
    As shown in the previous image, Ogre installation folder is set to C:\workspace\ogre\build-vc12\sdk.
  • Open C:\workspace\ogre\build-vc12\OGRE.sln solution file with Visual C++.
  • In Visual, select Debug configuration and build INSTALL project.
  • In Visual, select also Release configuration and build again INSTALL project.
    img-win10-msvc12-build-ogre-install-release.png
  • Now in C:\workspace\ogre\build-vc12\sdk\bin you will find all the libraries in Debug and Release configuration, including cg and OIS dependencies that were build previously.
    img-win10-ogre-explorer.png

6. Complete Ogre installation

  • To finish Ogre installation set OGRE_DIR environment variables to C:\workspace\ogre\build-vc12\sdk location.
    C:\> setx OGRE_DIR C:\workspace\ogre\build-vc12\sdk

Install ViSP from source code

Getting ViSP source code

There are different ways to get ViSP source code.

  • You can download the latest release as a zip or a tarball. Once visp-x.y.z.tar.gz or visp-x.y.z.zip is downloaded, uncompress the file in C:\workspace\visp\visp-x.y.z using for axample WinRAR.
  • You can also download a daily snapshot. Once visp-snapshot-yyyy-mm-dd.tar.gz is downloaded, uncompress the file in C:\workspace\visp\visp-x.y.z using for axample WinRAR.
  • Or you get the cutting-edge ViSP from GitHub repository using the git command line (see How to install Git):
    C:\> mkdir C:\workspace\visp
    C:\> cd C:\workspace\visp
    C:\> git clone https://github.com/lagadic/visp.git

We suppose now that ViSP source is in C:\workspace\visp\visp.

Configuring ViSP from source

The goal of the configuration step is now to use CMake to produce a Visual Studio C++ solution file that will be located in C:/workspace/visp/visp-build-vc12.

  • Launch CMake (cmake-gui) and complete the source code and binaries location as in the next image.
    img-cmake-win10-msvc12-visp-launch.png
  • Click then on "Configure" button.
    img-cmake-win10-msvc12-visp-create-folder.png
  • Click on "Yes" to create the C:/workspace/visp/visp-build-vc12 folder.
  • Select then your compiler "Visual Studio 12 2013 Win64" and click on "Finish" button.
    img-cmake-win10-msvc12-msvc-version.png
  • This will start CMake configuration. As shown in the next image, eigen, Flycapture, GDI (Graphical Device Interface), OpenCV, OpenMP, Pylon, Realsense, XML2 and zbar 3rd parties are automatically detected.
    img-cmake-win10-msvc12-visp-config.png
    Note
    Installation folder is set to C:/workspace/visp/visp-build-vc12/install. If you want to change the installation folder to C:/Program Files (x86)/ViSP, make sure that you have administrator privileges to write in that folder before modifying CMAKE_INSTALL_PREFIX.
  • Click then on "Configure" button. All the red lines should disappear.
    img-cmake-win10-msvc12-visp-config2.png
    Note
    The default configuration lead to the creation of a shared library (with .dll extension). This is the default configuration that is recommended. If you want to create rather a static library (with .lib extension) you have to uncheck the BUILD_SHARED_LIBS option to disable DLL creation.
  • To finish the configuration, click on "Generate" button.
    img-cmake-win10-msvc12-visp-generate.png
  • Once the generation is done, in C:/workspace/visp/visp-build-vc12 folder you have the Visual Studio VISP.sln generated solution file.

Building ViSP from source

  • To build ViSP just double click on C:/workspace/visp/visp-build-vc12/VISP.sln solution file. This action will open ViSP project in Visual Studio C++. As shown in the next image, by default, Visual Studio position the solution configuration to Debug.
    img-win10-msvc12-visp-open.png
  • Enter menu "BUILD/Build Solution" to build ViSP or hit "Ctrl+Shift+B".
  • At the end of the build process you should have the following indicating that all the build succeeded.
    img-win10-msvc12-visp-build-end.png
  • Now to install ViSP, build "INSTALL" project. To this end, apply a left click on "INSTALL" to select the project, then a right click to enter in the "Build" menu.
    img-win10-msvc12-visp-install.png
  • At the end of the installation, you should have the following.
    img-win10-msvc12-visp-install-end.png
  • As shown in the previous image, all the headers but also the generated libraries are copied in C:/workspace/visp/visp-build-vc12/install folder; headers and libraries in include and x64/vc14 subfolders respectively.
  • This ends ViSP installation with Debug configuration.
  • We recommend now to do the same with Release settings. As shown in the next image, select the Release configuration.
    img-win10-msvc12-visp-release.png
  • Now, as previously, build and install ViSP again.
  • At the end, in C:/workspace/visp/visp-build-vc12/install/x64/vc12/bin folder you have two versions of ViSP DLL libraries corresponding to ViSP modules; the one suffixed by "d" with debug information, the other one optimized with release compiler options.
    img-win10-msvc12-visp-explorer-install.png

Setting up PATH variable

If you built static libraries then you are done. Otherwise, if you follow this tutorial step by step you need to add the bin folders path to the systems path. This is because you will use ViSP and OpenCV libraries in form of "Dynamic-link libraries" (also known as DLL). Inside these are stored all the algorithms and information the libraries 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 variable contains a list of folders where DLLs can be found. Add ViSP and OpenCV libraries path to this and the OS will know where to look if he ever needs the libraries. Otherwise, you will need to copy the used DLLs right beside the applications executable file (exe) for the OS to find it.

To modify the PATH var and add the path to ViSP library, open a cmd terminal and run:

C:\> echo %PATH%
C:\> setx PATH "%PATH%;C:\workspace\visp\visp-build-vc12\install\x64\vc12\bin"

Then to add the path to OpenCV 3rd party libraries location, close and re-open a cmd-terminal and run:

C:\> echo %PATH%
C:\> setx PATH "%PATH%;C:\workspace\opencv-3.0.0\build\x64\vc12\bin"

Then to add the path to librealsense 3rd party library location, close and re-open a cmd-terminal and run:

C:\> echo %PATH%
C:\> setx PATH "%PATH%;C:\workspace\librealsense-1.12.1\build-vc12\bin"

If installed, you have also to add the location of Ogre 3rd party libraries to the path. Close and re-open a cmd terminal to run:

C:\> echo %PATH%
C:\> setx PATH "%PATH%;C:\workspace\ogre\build-vc12\sdk\bin"
C:\> setx PATH "%PATH%;C:\workspace\ogre\build-vc12\sdk\bin\Release"
C:\> setx PATH "%PATH%;C:\workspace\ogre\build-vc12\sdk\bin\Debug"

Then close and re-open a cmd terminal to check if the PATH var was well positioned.

C:\> echo %PATH%

Install ViSP dataset

Some ViSP examples and tests require data (images, video, models) that are not part of ViSP source code but available in a separate archive named visp-images-x.y.z.zip. This archive could be downloaded from https://visp.inria.fr/download page. We provide here after the way to install these data if you want to run ViSP examples.

Download visp-images-3.1.0.zip from https://visp.inria.fr/download and uncompress it in your workspace C:/workspace.

img-win10-visp-images.png

ViSP examples and tests are able to detect automatically the location of the requested data if you position an environment variable called VISP_INPUT_IMAGE_PATH. In our case, this variable should be set to C:\workspace\visp-images-3.1.0.

C:\> setx VISP_INPUT_IMAGE_PATH C:\workspace\visp-images-3.1.0

From now, you can try to run ViSP examples and tests. For example, if you want to run C:/worspace/visp/visp-build-vc12/example/device/display/Debug/displayGDI.exe, open a command window, enter in the right folder, and run:

img-win8.1-cmd-displayGDI.jpg

Known issues

Unable to build ogredeps: DXSDK_DIR missing

During ogredeps build as described in Ogre3D 3rd party installation you may get in Visual C++ the following error when building SDL2 project:

error: DIRECTX requires $DXSDK_DIR environment variable to be set
img-win8.1-msvc-ogredeps-issue.jpg

To fix the issue:

  • Quit Visual C++ and start again CMake over ogredeps project
  • Disable SDL2 dependency build turning OGREDEPS_BUILD_SDL2 option off
    img-win8.1-cmake-ogredeps-issue.jpg
  • Configure and generate again the project
  • Open C:\Ogre\ogredeps\build\OGREDEPS.sln solution file with Visual C++ and try a new build as described in Ogre3D 3rd party

Model-based trackers are not working with Ogre visibility ckeck

If you run mbtEdgeTracking.exe, mbtKltTracking.exe or mbtEdgeKltTracking.exe enabling Ogre visibility check (using "-o" option), you may encounter the following issue:

C:\ViSP\visp-build\example\Tracking\Debug> mbtEdgeTracking.exe -c -o
...
OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource VTFInstancing.cg in resource group General
...
Initializing OIS ***

and then a wonderful runtime issue as in the next image:

img-win8.1-msvc-mbtracker-ogre-issue.jpg

It means maybe that Ogre version is not compatible with DirectX 11. This can be checked adding "-w" option to the command line:

C:\ViSP\visp-build\example\Tracking\Debug> mbtEdgeTracking.exe -c -o -w

Now the binary should open the Ogre configuration window where you have to select "OpenGL Rendering Subsystem" instead of "Direct3D11 Rendering Subsystem". Press then OK to continue and start the tracking of the cube.

img-win8.1-msvc-mbtracker-ogre-opengl.jpg

Next tutorial

You are now ready to see the next Tutorial: How to create and build a CMake project that uses ViSP on Unix or Windows that will show you how to use ViSP as a 3rd party to build your own project.