# OpenVINO for backup
## Install OpenVINO toolkit
1. Download OpenVINO Toolkit and install it.
2. Execute following commands
```sh=0
tar -xvzf l_openvino_toolkit_p_<version>.tgz
cd l_openvino_toolkit_p_<version>
sudo ./install_GUI.sh
```
### Install External Software Dependencies
1. After finished the installation, execute following commands
```sh=0
cd /opt/intel/openvino/install_dependencies
sudo -E ./install_openvino_dependencies.sh
```
### Set the Environment Variables
1. Set the environment varibales temporary
```sh=0
source /opt/intel/openvino/bin/setupvars.sh
```
2. (Optinal) Add environment varibales in ~/.openvino_bashrc. Execute this command once time.
```sh=0
echo 'source /opt/intel/openvino/bin/setupvars.sh' > ~/.openvino_bashrc
```
### Configure the Model Optimizer
1. **(Option 1)** Configure all supported frameworks at the same time
```sh=0
cd /opt/intel/openvino/deployment_tools/model_optimizer/install_prerequisites
sudo ./install_prerequisites.sh
```
2. **(Option 2)** Configure each framework separately
Configure individual frameworks separately **ONLY** if you did not select **Option 1** above
```sh=0
cd /opt/intel/openvino/deployment_tools/model_optimizer/install_prerequisites
```
* For Caffe:
```
sudo ./install_prerequisites_caffe.sh
```
* For TensorFlow:
```
sudo ./install_prerequisites_tf.sh
```
* For MXNet:
```
sudo ./install_prerequisites_mxnet.sh
```
* For ONNX:
```
sudo ./install_prerequisites_onnx.sh
```
* For Kaldi:
```
sudo ./install_prerequisites_kaldi.sh
```
3. You are ready to compile the samples by running the [verification scripts](https://docs.openvinotoolkit.org/latest/_docs_install_guides_installing_openvino_linux.html#run-the-demos).
* Running this demo will download FP16 squeenet model.
* Reference this scrpit file to download other models.
* ./demo_squeezenet_download_convert_run.sh
* ./demo_security_barrier_camera.sh
## Install OpenCL Driver for GPU
* Install OpenCL Driver for GPU
* Note: Please use root privileges to run the installer when installing the core components.
```sh=0
mkdir -p ~/code && cd ~/code
wget https://github.com/intel/compute-runtime/releases/download/19.04.12237/intel-gmmlib_18.4.1_amd64.deb
wget https://github.com/intel/compute-runtime/releases/download/19.04.12237/intel-igc-core_18.50.1270_amd64.deb
wget https://github.com/intel/compute-runtime/releases/download/19.04.12237/intel-igc-opencl_18.50.1270_amd64.deb
wget https://github.com/intel/compute-runtime/releases/download/19.04.12237/intel-opencl_19.04.12237_amd64.deb
wget https://github.com/intel/compute-runtime/releases/download/19.04.12237/intel-ocloc_19.04.12237_amd64.deb
sudo dpkg -i *.deb
```
## Install OpenCV 3.4 or later (For Ubuntu 18.04)
### OpenCV dependency
```
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev
```
## Install Intel® RealSense⢠SDK 2.0 (tag v2.24.0)
```sh=0
sudo apt-key adv --keyserver keys.gnupg.net --recv-key C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C8B3A55A6F3EFCDE
sudo add-apt-repository "deb http://realsense-hw-public.s3.amazonaws.com/Debian/apt-repo bionic main" -u
sudo apt-get install -y librealsense2-dkms \
librealsense2-utils \
librealsense2-dev \
librealsense2-dbg
```
* Reconnect the Intel RealSense depth camera and run: realsense-viewer to verify the installation.
* Verify that the kernel is updated :
```sh=0
modinfo uvcvideo | grep "version:"
```
The above command should include realsense string.
## Other Dependencies
```sh=0
#librealsense dependency
sudo apt-get install -y libssl-dev libusb-1.0-0-dev pkg-config libgtk-3-dev
sudo apt-get install -y libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev
# numpy and networkx
pip3 install numpy
pip3 install networkx==2.3
# libboost
sudo apt-get install -y --no-install-recommends libboost-all-dev
cd /usr/lib/x86_64-linux-gnu
ll | grep libboost_python
```
* Check the version about **libboost_python-py3X.so .**
* Appear libboost_python-py36.so.
```sh=0
sudo ln -sf libboost_python-py36.so libboost_python3.so
```
* Appear libboost_python-py35.so.
```sh=0
sudo ln -sf libboost_python-py35.so libboost_python3.so
```
Build sample code under openvino toolkit
## Building and Installation
==**root** is required instead of sudo==
```sh=0
sudo su
source /opt/intel/openvino/bin/setupvars.sh
cd /opt/intel/openvino/deployment_tools/inference_engine/samples/
mkdir build
cd build
cmake ..
make
exit
```
* Check the builded lib file: **libcpu_extension.so** and **libgflags_nothreads.a**
```sh=0
sudo ls -l /opt/intel/openvino/deployment_tools/inference_engine/samples/build/intel64/Release/lib/libcpu_extension.so | grep libcpu_extension.so
sudo ls -l /opt/intel/openvino/deployment_tools/inference_engine/samples/build/intel64/Release/lib/libgflags_nothreads.a | grep libgflags_nothreads.a
```
* Add two enviranment variables in ~/.openvino_bashrc.
```
echo "export CPU_EXTENSION_LIB=/opt/intel/openvino/deployment_tools/inference_engine/samples/build/intel64/Release/lib/libcpu_extension.so" >> ~/.openvino_bashrc
echo "export GFLAGS_LIB=/opt/intel/openvino/deployment_tools/inference_engine/samples/build/intel64/Release/lib/libgflags_nothreads.a" >> ~/.openvino_bashrc
echo "export OpenCV_DIR=/opt/intel/openvino/opencv" >> ~/.openvino_bashrc
```
* Install ROS2_OpenVINO packages
```sh=0
mkdir -p ~/ros2_openvino_ws/src
cd ~/ros2_openvino_ws/src
git clone https://github.com/intel/ros2_openvino_toolkit
git clone https://github.com/intel/ros2_object_msgs
git clone https://github.com/ros-perception/vision_opencv -b dashing
git clone https://github.com/ros2/message_filters.git
git clone https://github.com/ros-perception/image_common.git -b dashing
git clone https://github.com/intel/ros2_intel_realsense.git -b devel
cd ..
rosdep install --from-paths src --ignore-src --rosdistro dashing -y
```
* Modify dynamic_vino_lib's CMakeLists.txt
```diff=0
diff --git a/dynamic_vino_lib/CMakeLists.txt b/dynamic_vino_lib/CMakeLists.txt
index 977c464..ab0303b 100644
--- a/dynamic_vino_lib/CMakeLists.txt
+++ b/dynamic_vino_lib/CMakeLists.txt
@@ -131,7 +131,8 @@ if(WIN32)
endif()
endif()
else()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type ")
+ #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type ")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ")
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-command-line-argument")
elseif(UNIX)
```
* Build package
```bash
# source ~/ros2_ws/install/local_setup.bash
source /opt/intel/openvino/bin/setupvars.sh
source ~/.openvino_bashrc
cd ~/ros2_openvino_ws
colcon build --symlink-install
source ./install/local_setup.bash
sudo mkdir -p /opt/openvino_toolkit
sudo ln -sf ~/ros2_openvino_ws/src/ros2_openvino_toolkit /opt/openvino_toolkit
```
* Run demo
```bash
$ cd /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader
$ sudo python3 ./downloader.py --name mobilenet-ssd
$ sudo su
## root privilege
# FP32 precision model
$root python3 /opt/intel/openvino/deployment_tools/model_optimizer/mo.py --input_model /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/object_detection/common/mobilenet-ssd/caffe/mobilenet-ssd.caffemodel --output_dir /opt/intel/openvino/deployment_tools/open_model_zoo/models/object_detection/mobilenet-ssd/caffe/output/FP32 --mean_values [127.5,127.5,127.5] --scale_values [127.5]
# FP16 precision model
$root python3 /opt/intel/openvino/deployment_tools/model_optimizer/mo.py --input_model /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/object_detection/common/mobilenet-ssd/caffe/mobilenet-ssd.caffemodel --output_dir /opt/intel/openvino/deployment_tools/open_model_zoo/models/object_detection/mobilenet-ssd/caffe/output/FP16 --data_type=FP16 --mean_values [127.5,127.5,127.5] --scale_values [127.5]
$root exit
## root privilege
$ sudo cp /opt/openvino_toolkit/ros2_openvino_toolkit/data/labels/object_detection/mobilenet-ssd.labels /opt/intel/openvino/deployment_tools/open_model_zoo/models/object_detection/mobilenet-ssd/caffe/output/FP16
```
[setupvars.sh] OpenVINO environment initialized
# Training course
## Hands on
* Print all available topologies (pre-trained models)
```bash
$ cd <develop_toolkit...>/deployment_tools/tools/model_downloader/
$ sudo ./downloader.py --print_all
```
* Download topologies (pre-trained models)
```bash
$ cd <develop_toolkit...>/deployment_tools/tools/model_downloader/
$ sudo ./downloader.py --name mobilenet-ssd
```
* ==Model optimizer==
```bash
$ cd <develop_toolkit...>/open_model_zoo
$ sudo su
## root privilege
$root python3 ../model_optimizer/mo.py --input_model tools/downloader/object_detection/common/mobilenet-ssd/caffe/mobilenet-ssd.caffemodel --output_dir models/object_detection/mobilenet-ssd/caffe/output/FP32 --mean_values [127.5,127.5,127.5] --scale_values [127.5]
$root python3 ../model_optimizer/mo.py --input_model tools/downloader/object_detection/common/mobilenet-ssd/caffe/mobilenet-ssd.caffemodel --output_dir models/object_detection/mobilenet-ssd/caffe/output/FP16 --data_type=FP16 --mean_values [127.5,127.5,127.5] --scale_values [127.5]
$root exit
## root privilege
```
* Copy the object detection's data labels
```bash
sudo cp ~/ros2_openvino_ws/src/ros2_openvino_toolkit/data/labels/object_detection/mobilenet-ssd.labels /opt/openvino_toolkit/models/object_detection/mobilenet-ssd/caffe/output/FP16
```
* Run object detection demo
```bash
## Open a new terminal
source /opt/ros/dashing/setup.bash
source ~/.openvino_bashrc
source ~/ros2_openvino_ws/install/local_setup.bash
ros2 launch dynamic_vino_sample pipeline_object.launch.py
```
## AI vision integration
```bash
cd ~
git clone https://github.com/Adlink-ROS/vino_integration_demo
source ~/.openvino_bashrc
source ~/ros2_openvino_ws/install/local_setup.bash
cd ~/vino_integration_demo
colcon build --symlink-install
source install/local_setup.bash
ros2 run vino_integration vino_integration
## Run on terminal2 (ros2 env)
source ~/.openvino_bashrc
source ~/ros2_openvino_ws/install/local_setup.bash
ros2 launch dynamic_vino_sample pipeline_object_topic.launch.py
## Run on terminal3 (ros1 env)
roslaunch omni_base_driver omni_ekf.launch
## Run on terminal4 (ros1 bridge [fastrtps] env)
ros2 run ros1_bridge dynamic_bridge --bridge-all-topics
```