-
Notifications
You must be signed in to change notification settings - Fork 13
Building: SAF on OpenVINO (aka CVSDK)
This guide goes through steps for setting up SAF with CVSDK support. Ubuntu 16.04.4 LTS (64-bit) is required and the following is tested on Skull Canyon (6th Generation Core Skylake) with kernel 4.13.0-36. The instructions assume you are on Intel network.
wget -e use_proxy=yes http://releases.ubuntu.com/16.04/ubuntu-16.04.4-desktop-amd64.iso
Install common toolchain tools.
sudo apt-get install --yes cmake git
sudo apt-get install --yes gcc-multilib
From here on, we will assume the following working directory.
cd $HOME/vcs
Remove OpenCV from your system if you happen to have installed.
sudo apt-get remove libopencv-*
sudo apt-get autoremove opencv-data
Install CVSDK.
cd $HOME/vcs
wget -e use_proxy=yes http://registrationcenter-download.intel.com/akdlm/irc_nas/13131/l_openvino_toolkit_p_2018.1.265.tgz
tar zxvf l_openvino_toolkit_p_2018.1.265.tgz
cd l_openvino_toolkit_p_2018.1.265
./install_cv_sdk_dependencies.sh
./install.sh # NOTE: You should select to install with SUDO.
Add the following to your environment.
# Add the following to the end of $HOME/.bashrc
source /opt/intel/computer_vision_sdk/bin/setupvars.sh
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/intel/opencl
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Install NEO OpenCL driver.
cd /opt/intel/computer_vision_sdk/install_dependencies
sudo ./install_NEO_OCL_driver.sh
Build CVSDK extensions.
cd /opt/intel/computer_vision_sdk/deployment_tools/inference_engine/samples
sudo mkdir build
cd build
sudo -E cmake ..
sudo make cpu_extension -j8
Install dependency.
sudo apt-get install --yes autoconf automake libtool curl make g++ unzip
Install Protocol Buffer v3.
cd $HOME/vcs
git clone https://github.com/google/protobuf.git
cd protobuf
git reset --hard 513b35dc4e732a5649d50b2c56405109def40624
git submodule update --init --recursive
./autogen.sh
./configure --disable-shared --with-pic
make -j8
sudo make install
Add the following to your environment.
# Add the following to the end of $HOME/.bashrc
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Install dependency.
sudo apt-get install --yes --no-install-recommends cmake libglib2.0-dev libgoogle-glog-dev
sudo apt-get install --yes --no-install-recommends libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev
sudo apt-get install --yes --no-install-recommends gstreamer1.0:amd64
sudo apt-get remove --purge gstreamer1.0-vaapi
sudo apt-get install --yes libeigen3-dev
sudo apt-get install --yes libjemalloc-dev libzmq3-dev
sudo apt-get install --yes --no-install-recommends libboost-all-dev
sudo apt-get install --yes libcpprest-dev
sudo apt-get install --yes libjsoncpp-dev
sudo apt-get install --yes python-numpy python-scipy
sudo apt-get install --yes libopenblas-dev liblapack-dev
Checkout the latest SAF.
cd $HOME/vcs
git clone https://github.com/viscloud/saf.git
Build SAF.
cd saf
mkdir cvsdk
cd cvsdk
cmake -DCMAKE_BUILD_TYPE=Release -DUSE_CVSDK=ON -DBACKEND=cpu -DUSE_SSD=ON -DUSE_WEBSOCKET=ON -DUSE_KAFKA=ON -DUSE_MQTT=ON -DUSE_PYTHON=ON ..
make -j8 && make apps -j8
sudo make install_python
Prepare configuration files.
cd $HOME/vcs/saf/config
cp cameras.toml.example cameras.toml
cp models.toml.example models.toml
cp config.toml.example config.toml
cvsdk/apps/simple --camera GST_TEST
Note that once CVSDK is installed, there are models available at the following path:
/opt/intel/computer_vision_sdk/deployment_tools/intel_models
We first configure SAF to include the person-detection-retail-0012 model, which is with the topology of MobileNet-SSD and fine-tuned for one-class detection of person, by adding the following to SAF's model configuration file.
# Add the following to $HOME/vcs/saf/models.toml
[[model]]
name = "person-detection-retail-0012"
type = "cvsdk"
desc_path = "/opt/intel/computer_vision_sdk/deployment_tools/intel_models/person-detection-retail-0012/FP32/person-detection-retail-0012.xml"
params_path = "/opt/intel/computer_vision_sdk/deployment_tools/intel_models/person-detection-retail-0012/FP32/person-detection-retail-0012.bin"
input_width = 96
input_height = 112
label_file = "/opt/intel/computer_vision_sdk/deployment_tools/intel_models/person-detection-retail-0012/label.names"
The label file included above is a requirement for SAF to interpret results into labels, which can be created as follows.
sudo echo "person" >> /opt/intel/computer_vision_sdk/deployment_tools/intel_models/person-detection-retail-0012/label.names
Finally, use the following to run the detector app.
cd $HOME/vcs/saf
cvsdk/apps/detector -c GST_TEST --detector_type cvsdk-ssd -m person-detection-retail-0012 --detector_targets person --detector_confidence_threshold 0.1
Add device number of 0, namely the first GPU device, to the aforementioned detector app command line and run the detector app.
cd $HOME/vcs/saf
cvsdk/apps/detector -c GST_TEST --device 0 --detector_type cvsdk-ssd -m person-detection-retail-0012 --detector_targets person --detector_confidence_threshold 0.1
First thing first, you should make sure you have a Neural Compute Stick connected to your host system. Then use the following to set up proper USB rules.
cd $HOME/vcs/saf
cd scripts && ./install_myriad_usb_rules.sh
Now, add half precision model to SAF's model configuration file.
# Add the following to $HOME/vcs/saf/models.toml
[[model]]
name = "person-detection-retail-0012-fp16"
type = "cvsdk"
desc_path = "/opt/intel/computer_vision_sdk/deployment_tools/intel_models/person-detection-retail-0012/FP16/person-detection-retail-0012.xml"
params_path = "/opt/intel/computer_vision_sdk/deployment_tools/intel_models/person-detection-retail-0012/FP16/person-detection-retail-0012.bin"
input_width = 96
input_height = 112
label_file = "/opt/intel/computer_vision_sdk/deployment_tools/intel_models/person-detection-retail-0012/label.names"
Add device number of -10, namely the first GPU device, to the aforementioned detector app command line and run the detector app.
cd $HOME/vcs/saf
cvsdk/apps/detector -c GST_TEST --device -10 --detector_type cvsdk-ssd -m person-detection-retail-0012-fp16 --detector_targets person --detector_confidence_threshold 0.1