Skip to content

Building

Christopher Canel edited this page Sep 5, 2018 · 1 revision

1. Dependencies

Ubuntu

First install OpenCV 3.x.

If you have issues installing OpenCV from source, then try using this CMake command:

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_CUDA=OFF -DBUILD_SHARED_LIBS=OFF -DWITH_IPP=OFF -DBUILD_PROTOBUF=OFF -DBUILD_opencv_dnn=OFF BUILD_EXAMPLES=OFF BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF BUILD_opencv_apps=OFF ..

Standard packages:

sudo apt update
sudo apt install -y cmake libglib2.0-dev libgoogle-glog-dev \
    libboost-all-dev libgstreamer1.0-dev \
    libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev \
    libgstreamer-plugins-bad1.0-dev gstreamer1.0-libav libjemalloc-dev \
    libzmq3-dev libeigen3-dev libjsoncpp-dev libcurl4-gnutls-dev \
    libprotobuf-dev protobuf-compiler git

If you are building with -DUSE_MQTT=yes, then SAF has one additional dependency:

sudo apt install -y libssl-dev

If you are building with -DUSE_WEBSOCKET=yes, then SAF has two additional dependencies:

sudo apt install -y libwebsocketpp-dev libcpprest-dev

2. Compile and run

Please see the main README for a quick start guide on how to compile and run SAF.

3. Additional compilation options

  • Control the backend

    • Use CPU: -DBACKEND=cpu
    • Use CUDA device: -DBACKEND=cuda
    • Use OpenCL device: -DBACKEND=opencl
  • Add deep learning frameworks

    • Use Caffe: -DUSE_CAFFE=yes -DCAFFE_HOME=<path to Caffe>/distribute
    • Use TensorFlow (see this page for details): -DUSE_TENSORFLOW=yes -DTENSORFLOW_HOME=<path to TensorFlow
  • Enable additional camera types

    • Build with the PtGray SDK for their GigE cameras: -DUSE_PTGRAY=yes
    • Build with the Vimba SDK for Allied Vision cameras: -DUSE_VIMBA=yes -DVIMBA_HOME=<path to Vimba_2_1>
  • Configure gRPC support. (Note that SAF already includes ZeroMQ support by default, which can be used for publishing and subscribing to streams. This option adds gRPC as an alternative way to connect SAF instances running on different machines.)

4. Control the encoders and decoders

By default, SAF tries to pick a good GStreamer encoder and decoder for the platform (i.e., prefers hardware over software). To force SAF to use other decoders and encoders, edit the config/config.toml file.

Running the gst-inspect-1.0 command (on Ubuntu, found in the gstreamer1.0-tools) lists the available encoders and decoders. The list varies depending on which GStreamer plugins are installed.

Hardware acceleration

GStreamer supports hardware-accelerated encode and/or decode on some hardware through VA-API. On Ubuntu, there are two steps:

  1. Install the gstreamer1.0-vaapi package.
  2. Become part of the video group (usually sudo adduser <username> video). You may have to log out and log back in for the group change to take effect.

If these steps work, then gst-inspect-1.0 | grep vaapi should return some results, and the vainfo command should also succeed.