Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
Tutorial: Installation from source for OSX with Homebrew

In this tutorial you will learn how to install ViSP from source on OSX with Homebrew. These steps have been tested with Mac OS X 10.9.5 Mavericks, with 10.10.3 Yosemite, with 10.12.5 Sierra and with 10.14.2 Mojave.

Note
Concerning ViSP installation, we provide also other Tutorials.

Install prerequisites

  • First, go to http://brew.sh to install Homebrew.
  • Next use homebrew to install additional software.
    $ brew update
    $ brew install cmake git subversion wget
  • You will need to add /usr/local/bin to the PATH environment var in your ~/.bashrc or ~/.bash_profile to have Homebrew be at the front of the PATH.
    $ echo "export PATH=/usr/local/bin:$PATH" >> ~/.bashrc
    $ source ~/.bashrc
  • Install XQuartz to get X11. Go to https://www.xquartz.org/, download and install the dmg file. At the time this tutorial was written, we installed XQuartz-2.7.11.dmg file.

Create a workspace

First create a workspace that will contain all ViSP source, build, data set and optional 3rd parties. This workspace is here set to $HOME/visp-ws folder, but it could be set to any other location.

In a terminal, run:

$ echo "export VISP_WS=$HOME/visp-ws" >> ~/.bashrc
$ source ~/.bashrc
$ mkdir -p $VISP_WS

Quick ViSP installation

In this section, we give minimal instructions to build ViSP from source just to try ViSP without entering in Advanced ViSP installation.

  • Install a small number of recommended 3rd parties
    $ brew install opencv glog eigen libxml2
  • Get ViSP source code
    $ cd $VISP_WS
    $ git clone https://github.com/lagadic/visp.git
  • Create a build folder and build ViSP
    $ mkdir -p $VISP_WS/visp-build
    $ cd $VISP_WS/visp-build
    $ cmake ../visp
    $ make -j4
  • Set VISP_DIR environment variable
    $ echo "export VISP_DIR=$VISP_WS/visp-build" >> ~/.bashrc
    $ source ~/.bashrc

To have a trial, just jump to Install ViSP dataset before running some binaries that you just build or jump to Next tutorial. You can later come back to the Advanced ViSP installation.

Note
If you encounter an error, check Known issues section.

Advanced ViSP installation

Install 3rd parties

ViSP is interfaced with several 3rd party libraries. The complete list is provided here.

Note
ViSP can be used without any third-party since all of them are optional. But obviously in this case, as we do not want to reinvent the wheel, some features implemented in third-party libraries will not be exploitable through ViSP. It is therefore possible to skip in a first time this section and start directly to Quick ViSP installation. Later, if you realize that a third-party library is missing, you can still install it, go back to the build folder, configure ViSP with CMake to detect the newly installed third-party library and build ViSP again as explained in How to take into account a newly installed 3rd party.

Recommended 3rd parties

We recommend to install the following 3rd parties:

  • OpenCV to get advanced image processing and computer vision features coming with ViSP
  • libX11 to be able to open a window to display images
  • lapack and eigen to benefit from optimized mathematical capabilities
  • libdc1394 to grab images from firewire cameras
  • libxml2 to be able to configure the model-based trackers from xml files
  • libzbar to be able to detect QR codes

Installation of recommended 3rd parties could be performed running:

$ brew install opencv glog lapack eigen libdc1394 libxml2 zbar

Other optional 3rd parties

  • If you have an Intel Realsense RGB-D camera (R200, F200, SR300, LR200, RZ300) you may install librealsense 1.12.1 and PCL library using:
    $ brew install librealsense pcl pkg-config
  • If you have a rather a Basler camera you may donwload and install Pylon SDK following these instructions.
  • If lapack 3rd party is not detected during CMake configuration it may be useful to install the Gnu Scientific Library (GSL) to benefit from optimized mathematical capabilities. To this end run the following instruction:
    $ brew install gsl

Get 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 downloaded, uncompress the file using either
    $ tar xvzf visp-x.y.z.tar.gz -C $VISP_WS
    or
    $ unzip visp-x.y.z.zip -d $VISP_WS
  • You can also download a daily snapshot. Once downloaded, uncompress the file using
    $ tar xvzf visp-snapshot-yyyy-mm-dd.tar.gz -C $VISP_WS
  • Or you get the cutting-edge ViSP from GitHub repository using the following command
    $ cd $VISP_WS
    $ git clone https://github.com/lagadic/visp.git

We suppose now that ViSP source is in the directory $VISP_WS/visp. The following should be adapted if you downloaded ViSP from a zip or tarball. In that case, the source is rather in something like $VISP_WS/visp-x.y.z.

Configure ViSP from source

These are the steps to configure ViSP from source with CMake:

  • In the workspace, create first a directory named visp-build that will contain all the build material; generated Makefiles, object files, output libraries and binaries.
    $ mkdir $VISP_WS/visp-build
  • Enter the visp-build folder and configure the build:
    $ cd $VISP_WS/visp-build
    $ cmake ../visp
    A more versatile way to configure the build is to use ccmake, the CMake GUI:
    $ ccmake ../visp
    The following image shows that this command allows to configure (just by pressing [c] key) the build in a more advanced way where some options could be easily turned ON/OFF. It allows also to see which are the 3rd parties that will be used. To generate the makefiles, just press [g] key in the ccmake gui.
    img-ccmake-osx-all.jpg
    Snapshot of the ccmake ../visp command used to configure ViSP.
Note
If you encounter an error during CMake configuration, check Known issues section.

Build ViSP libraries

To build ViSP proceed with:

$ cd $VISP_WS/visp-build
$ make -j4

Build ViSP documentation

To build ViSP documentation, you have first to install Doxygen package:

$ brew install doxygen

Then you can proceed with:

$ cd $VISP_WS/visp-build
$ cmake ../visp
$ make -j4 visp_doc

The generated documentation is then available in $VISP_WS/visp-build/doc/html/index.html

Note
It is also possible to generate a more complete documentation that includes also all the internal classes. This could be achieved setting CMake var ENABLE_FULL_DOC to ON like:
$ cmake ../visp -DENABLE_FULL_DOC=ON
$ make -j4 visp_doc

Set VISP_DIR environment var

In order to ease ViSP detection by CMake when ViSP is used as a 3rd party in an external project, like the one described in the Tutorial: How to create and build a CMake project that uses ViSP on Unix or Windows, you may set VISP_DIR environment variable with the path to the VISPConfig.cmake file:

$ echo "export VISP_DIR=$VISP_WS/visp-build" >> ~/.bashrc
$ source ~/.bashrc

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 http://visp.inria.fr/download page. We provide here after the way to install these data if you want to run ViSP examples or tests. Note that ViSP tutorials are not using ViSP data set.

  • After ViSP data set download unzip the archive
    $ unzip ~/Downloads/visp-images-3.2.0.zip -d $VISP_WS
  • We suppose now that the data are located in $VISP_WS/visp-images-3.2.0.
    $ ls $VISP_WS/visp-images-3.2.0
    AprilTag LICENSE.txt calibration cube ellipse-1 iv mbt mire video
    Klimt README.md circle ellipse endianness line mbt-depth mire-2
  • Set VISP_INPUT_IMAGE_PATH environment variable to help ViSP examples and tests to find the location of the data set. It is more convenient if this environment variables is automatically added to your bash session every time a new shell is launched:
    $ echo "export VISP_WS=$HOME/visp-ws" >> ~/.bashrc
    $ echo "export VISP_INPUT_IMAGE_PATH=$VISP_WS/visp-images-3.2.0" >> ~/.bashrc
    $ source ~/.bashrc
  • From now, you can try to run ViSP examples and tests. For example you can run displayX example that should open a windows with Klimt painting image and some overlay drawings:
    $ cd $VISP_WS/visp-build
    $ ./example/device/display/displayX
    A click to close the windows...
    A click to display a cross...
    Cross position: 201, 441
    A click to exit the program...
    Bye
Note
Here if you encounter the following issue, dyld: Library not loaded: /usr/local/opt/glog/lib/libglog.0.3.5.dylib enter the corresponding section to see how to fix it.

Known issues

dyld: Library not loaded: /usr/local/opt/glog/lib/libglog.0.3.5.dylib

With OpenCV 4.0.0 installed using brew install opencv you may experience the following error trying to execute a binary linked with ViSP:

$ cd $VISP_WS/visp-build
$ ./example/device/display/displayX
dyld: Library not loaded: /usr/local/opt/glog/lib/libglog.0.3.5.dylib
Referenced from: /usr/local/opt/opencv/lib/libopencv_sfm.3.4.dylib
Reason: image not found
Abort trap: 6

A work around is to install glog library with:

$ brew install glog

Tips and tricks

How to take into account a newly installed 3rd party

Since all 3rd parties are optional you may have started to install only some of them. Imagine that you just installed a new third-party, or that you upgraded the version of this 3rd party. The next step is to go back to the build folder, configure ViSP with CMake to detect the newly installed third-party library and build again ViSP. This could be achieved with:

$ cd $VISP_WS/visp-build
$ cmake ../visp

Here you can check the content of the ViSP-third-party.txt file and see if the newly installed 3rd party is well detected (see Which are the 3rd party libraries that are used in ViSP ?).

Finally, you need to rebuild ViSP with:

$ make -j4

How to install ViSP

Installing ViSP is optional and not recommended, since ViSP could be used as a 3rd party without installation. If you still want to proceed with the installation run:

$ cd $VISP_WS/visp-build
$ sudo make install
Note
The default install location is set to /usr/local. This location could be changed modifying CMAKE_INSTALL_PREFIX var:
$ cd $VISP_WS/visp-build
$ cmake ../visp -DCMAKE_INSTALL_PREFIX=/usr
$ make -j4
$ sudo make install
If you proceed to ViSP installation in a system folder like /usr or /usr/local there is no need to Set VISP_DIR environment var that helps CMake to find ViSP libraries in an external project that uses ViSP as a 3rd party. If you rather install ViSP in a non "standard" folder, let say /my/install/folder, you have to set VISP_DIR to /my/install/folder/lib/cmake/visp that contains the VISPConfig.cmake file:
$ cd $VISP_WS/visp-build
$ cmake ../visp -DCMAKE_INSTALL_PREFIX=/my/install/folder
$ make -j4
$ sudo make install
$ echo "export VISP_DIR=/my/install/folder/lib/cmake/visp" >> ~/.bashrc
$ source ~/.bashrc

How to uninstall ViSP

After ViSP installation, you can remove installed material using:

$ cd $VISP_WS/visp-build
$ sudo make uninstall

How to build only ViSP libraries

If you want to build only ViSP modules libraries, nor the examples, tutorials and tests:

$ cd $VISP_WS/visp-build
$ make -j4 visp_modules

How to build a ViSP specific module

If you want to build a given module and all the dependencies:

$ cd $VISP_WS/visp-build
$ make -j4 visp_<module_name>

For example to build the model-based tracker module named mbt, run:

$ cd $VISP_WS/visp-build
$ make -j4 visp_mbt

Which are the targets that could be run with make ?

To know which are the target available with make:

$ make help | grep visp
... visp_doc
... visp_modules
... visp_tutorials
... visp_demos
... visp_tests
... visp_examples
... visp_clipper
... visp_apriltag
... visp_core
... visp_gui
... visp_imgproc
... visp_io
... gen_visp_java_source
... visp_klt
... visp_me
... visp_sensor
... visp_ar
... visp_blob
... visp_robot
... visp_visual_features
... visp_vs
... visp_vision
... visp_detection
... visp_java
... visp_java_jar
... visp_java_jar_source_copy
... visp_mbt
... visp_tt
... visp_tt_mi

Which are the 3rd party libraries that are used in ViSP ?

To see which are the optional 3rd parties that are found during the configuration stage and that will be used by ViSP during the build you can have a look to the text file named ViSP-third-party.txt and located in $VISP_WS/visp-build. We provide hereafter an example of a possible content of this file that contains also build info.

$ cat $VISP_WS/visp-build/ViSP-third-party.txt
==========================================================
General configuration information for ViSP 3.2.0
Version control: 3.1.0-689-g60f19bd63-dirty
Platform:
Timestamp: 2018-11-29T16:18:33Z
Host: Darwin 17.7.0 x86_64
CMake: 3.12.4
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: Release
C/C++:
Built as dynamic libs?: yes
C++ Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ (ver 10.0.0.10001145)
C++ flags (Release): -Wall -Wextra -std=c++11 -fvisibility=hidden -msse2 -msse3 -mssse3 -fPIC -O3 -DNDEBUG
C++ flags (Debug): -Wall -Wextra -std=c++11 -fvisibility=hidden -msse2 -msse3 -mssse3 -fPIC -g
C Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
C flags (Release): -Wall -Wextra -std=c++11 -fvisibility=hidden -msse2 -msse3 -mssse3 -fPIC -O3 -DNDEBUG
C flags (Debug): -Wall -Wextra -std=c++11 -fvisibility=hidden -msse2 -msse3 -mssse3 -fPIC -g
Linker flags (Release):
Linker flags (Debug):
ViSP modules:
To be built: core gui imgproc io java_bindings_generator klt me sensor ar blob robot visual_features vs vision detection java mbt tt tt_mi
Disabled: -
Disabled by dependency: -
Unavailable: -
Python (for build): /usr/local/bin/python2.7
Java:
ant: /usr/local/bin/ant (ver 1.10.5)
JNI: /System/Library/Frameworks/JavaVM.framework/Headers /System/Library/Frameworks/JavaVM.framework/Headers /System/Library/Frameworks/JavaVM.framework/Headers
Build options:
Build deprecated: yes
Build with moment combine: no
Mathematics:
Use Lapack/blas: yes (ver n/a)
Use Lapack (built-in): no
Use Eigen3: yes (ver 3.3.5)
Use OpenCV: yes (ver 3.4.3)
Use GSL: yes (ver 2.5)
Simulator:
Ogre simulator:
\- Use Ogre3D: no
\- Use OIS: no
Coin simulator:
\- Use Coin3D: no
\- Use SoWin: no
\- Use SoXt: no
\- Use SoQt: no
\- Use Qt4: no
\- Use Qt3: no
Media I/O:
Use JPEG: yes (ver 90)
Use PNG: yes (ver 1.6.35)
\- Use ZLIB: yes (ver 1.2.11)
Use OpenCV: yes (ver 3.4.3)
Real robots:
Use Afma4: no
Use Afma6: no
Use Franka: no
Use Viper650: no
Use Viper850: no
Use aria (Pioneer): no
Use PTU46: no
Use Biclops PT: no
Use Virtuose: no
GUI:
Use X11: yes
Use GTK: no
Use OpenCV: yes (ver 3.4.3)
Use GDI: no
Use Direct3D: no
Cameras:
Use DC1394-2.x: yes (ver 2.2.2)
Use CMU 1394: no
Use V4L2: no
Use directshow: no
Use OpenCV: yes (ver 3.4.3)
Use Flycapture: no
Use Pylon: yes (ver 5.0.5.8973)
RGB-D sensors:
Use Realsense: yes (ver 1.12.1)
Use Realsense2: yes (ver 2.16.5)
Use Kinect: no
\- Use libfreenect: no
\- Use libusb-1: yes (ver 1.0.22)
\- Use pthread: yes
Use PCL: yes (ver 1.8.1)
\- Use VTK: yes (ver 8.1.1)
F/T sensors:
Use atidaq (built-in): no
Use comedi: no
Detection:
Use zbar: yes (ver 0.10)
Use dmtx: no
Use AprilTag (built-in): yes (ver 0.9.8)
Misc:
Use Clipper (built-in): yes (ver 6.4.2)
Use XML2: yes (ver 2.9.4)
Optimization:
Use OpenMP: no
Use pthread: yes
Use pthread (built-in): no
Use cxx11: yes
cxx standard: 11
Documentation:
Use doxygen: yes
Tests and samples:
Tests: yes
Demos: yes
Examples: yes
Tutorials: yes
Install path: /usr/local
==========================================================

Known issues

CMake Error in /usr/local/share/pcl-1.9/PCLConfig.cmake

During CMake configuration if you install pcl using brew install pcl as explained in Other optional 3rd parties installation section, you may encounter the following issue with PCL 1.9.1 on OSX Mojave:

CMake Error at /usr/local/share/pcl-1.9/PCLConfig.cmake:361 (pcl_report_not_found):
cmake_policy POP without matching PUSH
Call Stack (most recent call first):
/usr/local/share/pcl-1.9/PCLConfig.cmake:545 (find_external_library)
cmake/VISPUtils.cmake:533 (find_package)
CMakeLists.txt:589 (VP_OPTION)
CMake Error in /usr/local/share/pcl-1.9/PCLConfig.cmake:
cmake_policy PUSH without matching POP
Call Stack (most recent call first):
cmake/VISPUtils.cmake:533 (find_package)
CMakeLists.txt:589 (VP_OPTION)

This issue comes from PCL 3rd party. The fix consists in installing pkg-config and starting a fresh CMake configuration:

$ brew install pkg-config
$ cd $VISP_WS/visp-build
$ rm -rf *
$ cmake ../visp

An other solution, but less elegant, would be modifying /usr/local/share/pcl-1.9/PCLConfig.cmake by commenting the following lines:

#cmake_policy(PUSH)
#cmake_policy(POP)

/usr/local/lib/pkgconfig is not writable

  • During OpenCV installation, if you get the following errors:
    $ brew install opencv
    Could not symlink lib/pkgconfig/isl.pc
    /usr/local/lib/pkgconfig is not writable.
    You can try again using:
    brew link isl
    ...
    it means maybe that you install other softwares without brew in /usr/local. A work arround is to change the owner of the corresponding folder like:
    $ sudo chown <your-user-name> /usr/local/lib/pkgconfig
  • If you enter into troubles with the packages you install with brew, a good stating is to run:
    $ brew doctor

Application built with libpng-1.5.18 but running with 1.6.17

  • If you encounter the following issue
    $ ./modules/vision/testKeypoint-5
    libpng warning: Application built with libpng-1.5.18 but running with 1.6.17
    error: can't create a png read structure!
    error reading png file
    It means that apparently there is a conflict between libpng version installed by brew install opencv3 (1.6.17), and the one used by X11/XQuartz (1.5.18). A work arround is to turn off libpng usage in ViSP. To configure and build again ViSP without png support:
    $ ccmake -DUSE_PNG=OFF ../ViSP
    $ make -j4
    An other work arround option is to turn off X11 usage in ViSP. Display capabilities will be then the one from OpenCV. To this end, configure and build again ViSP without X11 support:
    $ ccmake -DUSE_X11=OFF ../ViSP
    $ make -j4

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.