Installing OpenFace: an open source facial behavior analysis toolkit (Ubuntu 16.04)

EDIT: 06/15/2017 Additional compile time troubleshooting tips added.

Installation System: Ubuntu 16.04

1. Installing dependencies:

sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install llvm
sudo gedit /etc/apt/sources.list
change
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
to
deb http://us.archive.ubuntu.com/ubuntu/ xenial main universe
sudo apt-get update
sudo apt-get install clang-3.7 libc++-dev libc++abi-dev
sudo apt-get install cmake
sudo apt-get install libopenblas-dev liblapack-dev
sudo apt-get install git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev checkinstall
wget https://github.com/Itseez/opencv/archive/3.1.0.zip
sudo unzip 3.1.0.zip
cd opencv-3.1.0
mkdir build
cd build/
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_SHARED_LIBS=OFF ..
make -j4
sudo make install
sudo apt-get install libboost-all-dev

2. Installing OpenFace

git clone https://github.com/TadasBaltrusaitis/OpenFace.git
cd OpenFace/
mkdir build

cd build/
cmake -D CMAKE_BUILD_TYPE=RELEASE ..
make

Ref: https://github.com/TadasBaltrusaitis/OpenFace/wiki/Unix-Installation

3. Using from MATLAB  (Error Resolution: ibstdc++.so.6: version `CXXABI_1.3.8′ not found)

To solve this issue, I found setting the LD_LIBARARY_PATH from the script works for me. Just add the following at the beginning of the script (change the libstdc++.so.6 path according to your system):

setenv('LD_LIBRARY_PATH', '/usr/lib/x86_64-linux-gnu/libstdc++.so.6');

Sample script for running FaceLandmarkImg

from subprocess import call


# FaceLandmarkImg
#
# Single image analysis
#
# -f  the image file being input, can have multiple -f flags
# -of  location of output file for landmark points, gaze and action units
# -op  location of output file for 3D landmark points and head pose
# -gaze indicate that gaze estimation should be performed
# -oi  location of output image with landmarks
# -root  the root directory so -f, -of, -op, and -oi can be specified relative to it
# -inroot  the input root directory so -f can be specified relative to it
# -outroot  the root directory so -of, -op, and -oi can be specified relative to it
#
# Batch image analysis
#
# -fdir  - runs landmark detection on all images (.jpg and .png) in a directory, if the directory contains
# .txt files (image_name.txt) with bounding box (min_x min_y max_x max_y), it will use those for initialisation
# -ofdir  directory where detected landmarks, gaze, and action units should be written
# -oidir  directory where images with detected landmarks should be stored
# -opdir  directory where pose files are output (3D landmarks in images together with head pose and gaze)

exe = "../build/bin/FaceLandmarkImg"

# f_param = './OpenFace/image_sequence/001.jpg'
# of_param = './OpenFace/python/img_output/001.txt'
# op_param = './OpenFace/python/img_output/001_3d.txt'
# oi_param = './OpenFace/python/img_output/001.jpg'
# call([exe, "-f", f_param, "-of", of_param, "-op", op_param, "-oi", oi_param])

fdir_param = './OpenFace/image_sequence/'
ofdir_param = './OpenFace/python/imgseq_output'
oidir_param = ofdir_param
opdir_param = ofdir_param

call([exe, "-fdir", fdir_param, "-ofdir", ofdir_param, "-oidir", oidir_param, "-opdir", opdir_param, "-wild"])

 
UDPATE: 06/15/17

The following problem are faced when trying to install OpenFace using their install.sh installation script.

COMPILETIME ERROR 1: OpenCV3.1.0 Installation issue: cudalegacy not compile

This problem you’ll face if are trying to compile with CUDA-8.0:

try this: in graphcuts.cpp (where your error is thrown) change this:

#include "precomp.hpp"

#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
to this:

#include "precomp.hpp"

#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)
because graphcuts is not supported directly with CUDA8 anymore.

COMPILE TIME ERROR 2: /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcairo.so: undefined reference to `pixman_glyph_cache_remove'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcairo.so: undefined reference to `pixman_composite_glyphs_no_mask'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcairo.so: undefined reference to `pixman_glyph_get_mask_format'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcairo.so: undefined reference to `pixman_glyph_cache_insert'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcairo.so: undefined reference to `pixman_glyph_cache_freeze'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcairo.so: undefined reference to `pixman_glyph_cache_thaw'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcairo.so: undefined reference to `pixman_glyph_cache_lookup'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcairo.so: undefined reference to `pixman_composite_glyphs'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcairo.so: undefined reference to `pixman_glyph_cache_create

Solution: 1) Install libpixman-1-dev
sudo apt-get install libpixman-1-dev
2) Modify link.txt files to add "-lpixman-1" switch. Path to link.txt -
build/exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/link.txt
build/exe/FaceLandmarkVid/CMakeFiles/FaceLandmarkVid.dir/link.txt
build/exe/FaceLandmarkVidMulti/CMakeFiles/FaceLandmarkVidMulti.dir/link.txt
build/exe/FeatureExtraction/CMakeFiles/FeatureExtraction.dir/link.txt

Advertisements

14 thoughts on “Installing OpenFace: an open source facial behavior analysis toolkit (Ubuntu 16.04)

    • Yes, FaceLandmarkImg, FaceLandmarkVid, FaceLandmarkVidMulti and FeatureExtraction works for me. For FaceLandmarkVidMulti, try to use the command line example below and see if it works:

      ./bin/FaceLandmarkVidMulti -f ../videos/multi_face.avi

  1. hey i am getting error after running this , could you please help me out ! Thank you so much..

    cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_SHARED_LIBS=OFF ..

    the error goes like this :
    —-after some code—-

    CMake Error at 3rdparty/ippicv/downloader.cmake:77 (message):
    ICV: Failed to download ICV package: ippicv_linux_20151201.tgz.
    Status=56;”Failure when receiving data from the peer”
    Call Stack (most recent call first):
    3rdparty/ippicv/downloader.cmake:110 (_icv_downloader)
    cmake/OpenCVFindIPP.cmake:237 (include)
    cmake/OpenCVFindLibsPerf.cmake:12 (include)
    CMakeLists.txt:537 (include)

    — Configuring incomplete, errors occurred!
    See also “/home/vinay/Downloads/opencv-3.1.0/build/CMakeFiles/CMakeOutput.log”.
    See also “/home/vinay/Downloads/opencv-3.1.0/build/CMakeFiles/CMakeError.log”.

  2. hey Naved , thank u so much
    I succesfully installed and tested with videos,images,multiple images,feature extraction provided in this link ( which u mentioned )
    https://github.com/TadasBaltrusaitis/OpenFace/wiki/Unix-Installation

    I need a small help
    when i used to import openface from python it’s showing traceback error

    >>>
    >>> import sys
    >>>
    >>> import dlib
    >>>
    >>> import cv2
    >>>
    >>> import openface
    Traceback (most recent call last):
    File “”, line 1, in
    ImportError: No module named openface
    >>>
    >>>
    May I know the reason ?
    Thank u so much for your help.

  3. Amit, one easy way to check is to go to the terminal, type python, and enter TAB two times to autocomplete. You’ll see python, python2.7, python3 etc..if you have multiple versions installed, they enter each of the python interface and try to import openface to check which one has been used during openface installation.

  4. hi Naved, I installed openface using the script given by you. But when I run the ”make” command in terminal but it throes me error.
    make[2]: *** [bin/FaceLandmarkImg] Error 1
    CMakeFiles/Makefile2:252: recipe for target ‘exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/all’ failed
    make[1]: *** [exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/all] Error 2
    Makefile:127: recipe for target ‘all’ failed

      • This time i use cmake given as here:
        https://github.com/TadasBaltrusaitis/OpenFace/issues/175
        sudo cmake -D CMAKE_CXX_COMPILER=clang++-3.7 -D CMAKE_CXX_FLAGS=”-std=c++11 -stdlib=libc++ -I/usr/include/libcxxabi” -D CMAKE_EXE_LINKER_FLAGS= -v”-std=c++11 -stdlib=libc++ -lc++abi” -D CMAKE_BUILD_TYPE=RELEASE ..

        and got error

        /usr/bin/ld: cannot find -lvtkRenderingOpenGL
        /usr/bin/ld: cannot find -lvtkImagingHybrid
        /usr/bin/ld: cannot find -lvtkIOImage
        /usr/bin/ld: cannot find -lvtkCommonDataModel
        /usr/bin/ld: cannot find -lvtkCommonMath
        /usr/bin/ld: cannot find -lvtkCommonCore
        /usr/bin/ld: cannot find -lvtksys
        /usr/bin/ld: cannot find -lvtkCommonMisc
        /usr/bin/ld: cannot find -lvtkCommonSystem
        /usr/bin/ld: cannot find -lvtkCommonTransforms
        /usr/bin/ld: cannot find -lvtkCommonExecutionModel
        /usr/bin/ld: cannot find -lvtkDICOMParser
        /usr/bin/ld: cannot find -lvtkIOCore
        /usr/bin/ld: cannot find -lvtkmetaio
        /usr/bin/ld: cannot find -lvtkImagingCore
        /usr/bin/ld: cannot find -lvtkRenderingCore
        /usr/bin/ld: cannot find -lvtkCommonColor
        /usr/bin/ld: cannot find -lvtkFiltersExtraction
        /usr/bin/ld: cannot find -lvtkFiltersCore
        /usr/bin/ld: cannot find -lvtkFiltersGeneral
        /usr/bin/ld: cannot find -lvtkCommonComputationalGeometry
        /usr/bin/ld: cannot find -lvtkFiltersStatistics
        /usr/bin/ld: cannot find -lvtkImagingFourier
        /usr/bin/ld: cannot find -lvtkalglib
        /usr/bin/ld: cannot find -lvtkFiltersGeometry
        /usr/bin/ld: cannot find -lvtkFiltersSources
        /usr/bin/ld: cannot find -lvtkInteractionStyle
        /usr/bin/ld: cannot find -lvtkRenderingLOD
        /usr/bin/ld: cannot find -lvtkFiltersModeling
        /usr/bin/ld: cannot find -lvtkIOPLY
        /usr/bin/ld: cannot find -lvtkIOGeometry
        /usr/bin/ld: cannot find -lvtkFiltersTexture
        /usr/bin/ld: cannot find -lvtkRenderingFreeType
        /usr/bin/ld: cannot find -lvtkftgl
        /usr/bin/ld: cannot find -lvtkIOExport
        /usr/bin/ld: cannot find -lvtkRenderingAnnotation
        /usr/bin/ld: cannot find -lvtkImagingColor
        /usr/bin/ld: cannot find -lvtkRenderingContext2D
        /usr/bin/ld: cannot find -lvtkRenderingGL2PS
        /usr/bin/ld: cannot find -lvtkRenderingContextOpenGL
        /usr/bin/ld: cannot find -lvtkRenderingLabel
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
        exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/build.make:152: recipe for target ‘bin/FaceLandmarkImg’ failed
        make[2]: *** [bin/FaceLandmarkImg] Error 1
        CMakeFiles/Makefile2:252: recipe for target ‘exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/all’ failed
        make[1]: *** [exe/FaceLandmarkImg/CMakeFiles/FaceLandmarkImg.dir/all] Error 2
        Makefile:127: recipe for target ‘all’ failed
        make: *** [all] Error 2

  5. hello i am trying to run :
    ./bin/FaceLandmarkVidMulti -f ../videos/multi_face.avi
    but i have this error:
    bash: ./bin/FaceLandmarkVidMulti: No existe el archivo o el directorio

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