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

In this tutorial you will learn how to install ViSP from source on Windows 10 with Visual C++. These steps have been tested on Windows 10 (64 bit), with CMake 3.10.0 and Visual Studio Community 2015.

Note
Concerning ViSP installation, we provide also other Tutorials.

Install prerequisities

  • Visual C++. Visual Studio Community 2015 that includes Visual C++ could be downloaded from https://www.visualstudio.com. After the installation, start Visual Studio and create an empty C++ project to install the common tools for Visual C++ 2015.
  • 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.10.0-rc3-win64-x64.msi). To install just double click on the msi file.
  • Windows Software Developement Kit (SDK) for Windows 10. This SDK could be downloaded from https://dev.windows.com/en-US/downloads/windows-10-sdk. This SDK is requested by CMake and allows also to get the Graphical Device Interface (GDI) capabilities. The GDI is used in ViSP to display images in a window thanks to vpDisplayGDI class.

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. We recommend to install OpenCV 3rd party and libxml2 3rd party in the workspace. If you have an Intel Realsense depth camera you may also install librealsense 3rd party. If your camera is a PointGrey you may install FlyCapture 3rd party, while if your camera is a Basler, you may rather install Pylon 3rd party. If you want to be able to detect a QR code you may install zbar 3rd party. To use optimized matrix operations you may install eigen 3rd party. Other 3rd parties are optional and should be considered only by expert developers.

OpenCV 3rd party

1. Get OpenCV

First you have to get OpenCV:

  • From http://opencv.org/releases.html download the latest OpenCV for Windows. In our case we got opencv-3.3.1-vc14.exe Win pack installer. The same procedure could be used to consider rather OpenCV 3.3.0 by downloading opencv-3.3.0-vc14.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.
  • We strongly recommend to rename this folder to a name that contain OpenCV version like C:\workspace\opencv-3.3.1.

OpenCV 3.3.1 windows installer contains pre-build libraries compatible with Visual C++ 2015 (vc14) in C:\workspace\opencv-3.3.1\build\x64\vc14. That is why there is no need to build OpenCV from source for vc14 as it is done in Tutorial: Installation from source for Windows with Visual C++ 2017 (vc15).

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.3.1\build"
    where C:\workspace\opencv-3.3.1\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.

libxml2 3rd party

1. Get libxml2

  • Download the latest libxml2 release from ftp://xmlsoft.org/libxml2. At the time this tuto was written it was libxml2-2.9.7.tag.gz file.
  • Extract the content of the tarball in C:\workspace. Winrar could be used to this end.
  • Here we suppose that you have libxml2 source code in C:\workspace\libxml2-2.9.7 folder.

2. Install libxml2

  • In the Windows "Start" menu, scroll to "Visual Studio 2015", and select "Visual Studio Command Prompt for native x64".
  • To build libxml2 from source enter the following instructions in the Visual Studio Command Prompt:
    C:\> cd C:\workspace\libxml2-2.9.7\win32
    C:\> cscript configure.js iconv=no ftp=no http=no compiler=msvc prefix=C:\workspace\libxml2-2.9.7\build-vc14
    C:\> nmake /f Makefile.msvc install
  • After these steps, libxml2 library could be found in C:/workspace/libxml2-2.9.7/build/vc14/bin/libxml2.dll

3. Complete libxml2 installation

  • To complete the installation, set XML2_DIR environment variable:
    C:\> setx XML2_DIR "C:\workspace\libxml2-2.9.7\build-vc14"
  • You have also to add the location of libxml2 library 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-vc14:
    img-cmake-win10-msvc14-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 14 2015 Win64" and click on "Finish" button.
  • Modify CMAKE_INSTALL_PREFIX var to C:/workspace/librealsense-1.12.1/build-vc14 folder location.
    img-cmake-win10-msvc14-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++ 14 2015.
  • Select Release configuration and build INSTALL target
    img-win10-msvc14-realsense-build.png
  • After these steps, librealsense library could be found in C:/workspace/librealsense-1.12.1/build-vc14/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-vc14"
  • You have also to add the location of librealsense library in the PATH environment variable following the indications mentioned in Setting up PATH variable.

FlyCapture 3rd party

I you have a PointGrey USB 2.0, USB 3.0, GigE or FireWire camera (DragonFly2, Flea3...), you may install FlyCapture. Otherwise you can skip this section.

Complete installation instructions are given here. We recap hereafter the main instructions to install FlyCapture SDK under Windows:

  • Download the latest FlyCapture2 Full SDK for your camera from Point Grey’s download site. On the download page, select your product family and "Windows 10 64 bit" as operating system. At the time this tutorial we written we selected "FlyCapture 2.11.3.164 SDK - Windows (64 bit)" to download FlyCapture_2.11.3.164_x64.exe file.
  • Double-click the downloaded software executable and follow the installation instructions.
  • Select the correct driver for the camera when prompted by the installation instructions.
  • Reboot the system.

Pylon 3rd party

I you have a Basler FireWire, Camera Link, GigE or USB3.0 camera, you may install Pylon SDK. Otherwise you can skip this section.

To install Pylon:

  • visit Basler Software Download page to download and install the SDK corresponding to your platform. At the time this tutorial we written we selected "Pylon 5.0.11 Camera Software Suite Windows" to download Basler_pylon_5.0.11.10913.exe file.
  • Double-click on downloaded file and follow the installation instructions.
  • Be carreful to select "Developer" profile during the installation in order to install Pylon SDK headers (.h) besides the dll.
    img-win10-pylon-developer.png
  • Click then on "Next" button.
  • Select how your Basler camera is connected to the computer (USB, GigE, FireWire, Camera Link), then click on "Next" button.
  • Keep the default destination folder as C:\Program Files\Basler\pylon 5\ and click on "Next" button
  • In the "Ready to install" panel, click on the "Install" button
  • Reboot the system.

zbar 3rd party

If you want to work with QR codes (see Tutorial: Bar code detection), we recommend to install zbar 3rd party. Otherwise you can skip this section.

Note
Since ViSP 3.1.0 we provide also AprilTag detection capabilities that are available without 3rd party installation (see Tutorial: AprilTag marker detection).

To install zbar you need to build the library from source. There is a fork of the library available from GitHub (https://github.com/dani4/ZBarWin64) and adapted for compiling under Visual following the steps:

1. Get zbar

  • Get ZBarWin64 source code from Github repository. Open a command window and hit:
    C:\> cd C:\workspace
    C:\> git clone https://github.com/dani4/ZBarWin64

2. Build zbar

  • Then open C:\workspace\ZBarWin64\zbar64.sln solution file with Visual Studio C++
  • Select x64 configuration and build zbar library in Release
    img-win10-msvc15-zbar-build.png

3. Complete zbar installation

  • To complete the installation, set ZBAR_DIR environment variable:
    C:\> setx ZBAR_DIR "C:\workspace\ZBarWin64"
  • You have also to add the location of zbar and iconv libraries in the PATH environment variable following the indications mentioned in Setting up PATH variable.

eigen 3rd party

Even if eigen is designed as a template we recommand to install the library with Visual Studio.

1. Get eigen

  • Download the latest eigen release from http://eigen.tuxfamily.org. At the time this tutorial was written we downloaded eigen-eigen-5a0156e40feb.tar.gz tarball corresponding to eigen 3.3.4.
  • Extract the content of the archive in C:\workspace.
  • We recommend to rename C:\workspace\eigen-eigen-5a0156e40feb in C:\workspace\eigen-3.3.4

2. Configure eigen

To build eigen from source with Visual C++ 2015 (vc14)

  • Launch CMake (cmake-gui), complete the source code and build locations as in the next image.
    img-cmake-win10-msvc14-eigen-launch.png
  • Click then on "Configure" button.
  • Click on "Yes" to create the C:/workspace/eigen-3.3.4/build-vc14 folder.
  • Select then your compiler "Visual Studio 14 2015 Win64" and click on "Finish" button.
    img-cmake-win10-msvc14-msvc-version.png
  • This will start CMake configuration.
  • Set CMAKE_INSTALL_PREFIX var to C:/workspace/eigen-3.3.4/build-vc14/install folder location.
    img-cmake-win10-msvc14-eigen-install.png
  • Click again on "Configure" button. All the red lines should disappear.
  • To finish the configuration, click on "Generate" button.
  • Once the generation is done, in C:/workspace/eigen-3.3.4/build-vc14 folder you have the Visual Studio Eigen3.sln generated solution file.

3. Install eigen

  • To install eigen just double click on C:/workspace/eigen-3.3.4/build-vc14/Eigen3.sln solution file. This action will open eigen project in Visual Studio C++ 14 2015.
  • Build INSTALL target knowing that "Debug" or "Release" configuration doesn't mather
    img-win10-msvc14-eigen-build-install.png
  • After these steps, eigen is installed in C:/workspace/eigen-3.3.4/build-vc14/install

4. Complete eigen installation

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

  • In order that ViSP detects eigen you have to set EIGEN_DIR environment variable. Start up a cmd terminal and enter:
    C:\> setx Eigen3_DIR "C:\workspace\eigen-3.3.4\build-vc15\install"
    where C:\workspace\eigen-3.3.4\build-vc14\install is where you have installed eigen. Inside this folder you should have a file named Eigen3Config.cmake.
  • There is no need to set PATH environment var since eigen is a template that has no library.

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-vc14.

  • Launch CMake (cmake-gui) and complete the source code and binaries location as in the next image.
    img-cmake-win10-msvc14-visp-launch.png
  • Click then on "Configure" button.
    img-cmake-win10-msvc14-visp-create-folder.png
  • Click on "Yes" to create the C:/workspace/visp/visp-build-vc14 folder.
  • Select then your compiler "Visual Studio 14 2015 Win64" and click on "Finish" button.
    img-cmake-win10-msvc14-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-msvc14-visp-config.png
    Note
    Installation folder is set to C:/workspace/visp/visp-build-vc14/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-msvc14-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-msvc14-visp-generate.png
  • Once the generation is done, in C:/workspace/visp/visp-build-vc14 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-vc14/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-msvc14-visp-open.png
  • Enter menu "BUILD/Build Solution" to build ViSP or hit "Ctrl+Shift+B".
    img-win10-msvc14-visp-build.png
  • At the end of the build process you should have the following indicating that all the build succeeded.
    img-win10-msvc14-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-msvc14-visp-install.png
  • At the end of the installation, you should have the following.
    img-win10-msvc14-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-vc14/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-msvc14-visp-release.png
  • Now, as previously, build and install ViSP again.
  • At the end, in C:/workspace/visp/visp-build-vc14/install/x64/vc14/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-msvc14-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-vc14\install\x64\vc14\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.3.1\build\x64\vc14\bin"

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

C:\> echo %PATH%
C:\> setx PATH "%PATH%;C:\workspace\libxml2-2.9.7\build-vc14\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-vc14\bin"

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

C:\> echo %PATH%
C:\> setx PATH "%PATH%;C:\workspace\ZBarWin64\x64\Release"
C:\> setx PATH "%PATH%;C:\workspace\ZBarWin64\zbar\libiconv\dll_x64"

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-vc14/example/device/display/Debug/displayGDI.exe, open a command window, enter in the right folder, and run:

img-win10-msvc14-cmd-displayGDI.png

Tip & tricks

How to set a specific Visual Studio version

If one of the following command lines are not working:

C:\> nmake
C:\> cl

it may possible that you have more then one Visual Studio version installed on your system.

To select Visual Studio 2015 (vc14) you may open a cmd terminal, enter in the corresponding Visual Studio folder and run vcvarsall.bat:

C:\> cd C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
C:\> vcvarsall.bat

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.