Home » ROS2与深度学习教程 » ros2与深度学习教程-整合openvino kit和ros2_openvino_toolkit
  • 上一篇: 没有了
  • 下一篇: 没有了

ros2与深度学习教程-整合openvino kit和ros2_openvino_toolkit

ros2与深度学习教程-整合openvino kit

说明:

  • 介绍如何在ubuntu 20.04的ros2版本foxy下整合openvino kit
  • 测试环境:nuc ubuntu 20.04

安装openvinokit步骤:

请输入图片描述

  • 再填写邮箱,提交即可下载。
  • 或者使用我们这个版本,这个离线安装版本有600多M
wget https://registrationcenter-download.intel.com/akdlm/irc_nas/18319/l_openvino_toolkit_p_2021.4.752.tgz
  • 解压包
tar -xvzf l_openvino_toolkit_p_2021.4.752.tgz
  • 进入目录
cd l_openvino_toolkit_p_2021.4.752
  • 运行界面安装,推荐
sudo ./install_GUI.sh
  • 打开界面

请输入图片描述

  • 根据提示,一步步完成安装
  • 安装完成界面

请输入图片描述

  • 安装位置
For root or administrator: /opt/intel/openvino_<version>/
For regular users: /home/<USER>/intel/openvino_<version>/
  • 安装额外的依赖
cd /opt/intel/openvino_2021/install_dependencies
sudo -E ./install_openvino_dependencies.sh
  • 加载环境
source /opt/intel/openvino_2021/bin/setupvars.sh
  • 或者增加加载脚本到bashrc
vim ~/.bashrc
source /opt/intel/openvino_2021/bin/setupvars.sh
  • 输入:wq 保存

  • 配置模型优化

  • 可以针对 Caffe, TensorFlow 2.x, MXNet, Kaldi, and ONNX做优化

cd /opt/intel/openvino_2021/deployment_tools/model_optimizer/install_prerequisites
sudo ./install_prerequisites.sh

测试例子:

  • 编译demo
 # root is required instead of sudo
 source /opt/intel/openvino_2021/bin/setupvars.sh
 cd /opt/intel/openvino_2021/deployment_tools/open_model_zoo/demos
 source build_demos.sh
  • 编译后执行文件的位置
/home/ubuntu/omz_demos_build/intel64/Release
  • 下载模型
  • 进入open_model_zoo路径
cd /opt/intel/openvino_2021/deployment_tools/open_model_zoo/tools/downloader
  • 查看所有模型
./downloader.py --print_all
  • 下载face-detection模型:
sudo ./downloader.py --name face-detection-retail-0004
  • 目录位于:
 /opt/intel/openvino_2021.4.752/deployment_tools/open_model_zoo/tools/downloader/intel/face-detection-retail-0004/FP32/face-detection-retail-0004.xml
  • 下载视频例子
mkdir -p ~/tools/openvino
cd ~/tools/openvino
git clone https://github.com/intel-iot-devkit/sample-videos.git
  • 运行例子
#进入目录
cd ~/omz_demos_build/intel64/Release
#source环境
source /opt/intel/openvino_2021/bin/setupvars.sh
#执行例子
./multi_channel_face_detection_demo -m /opt/intel/openvino_2021.4.752/deployment_tools/open_model_zoo/tools/downloader/intel/face-detection-retail-0004/FP16-INT8/face-detection-retail-0004.xml -d CPU -i ~/tools/openvino/sample-videos/head-pose-face-detection-female-and-male.mp4 -i ~/tools/openvino/sample-videos/head-pose-face-detection-female.mp4 -i ~/tools/openvino/sample-videos/head-pose-face-detection-male.mp4 -i ~/tools/openvino/sample-videos/people-detection.mp4 -i ~/tools/openvino/sample-videos/face-demographics-walking-and-pause.mp4 -i ~/tools/openvino/sample-videos/face-demographics-walking.mp4
  • 成功执行之后,显示一个界面,标识人脸。
  • 更多例子介绍:https://docs.openvino.ai/latest/omz_demos.html

安装ros2_openvino_toolkit步骤

  • 编译ros2_openvino_toolkit
mkdir -p ~/openvino2_ws/src
cd ~/openvino2_ws/src
git clone https://github.com/intel/ros2_openvino_toolkit -b dev-ov.2021.3
git clone https://github.com/intel/ros2_object_msgs
git clone https://github.com/intel/ros2_intel_realsense.git -b refactor
cd ~/openvino2_ws
source /opt/intel/openvino_2021/bin/setupvars.sh
colcon build --symlink-install
source ./install/local_setup.bash
  • 测试例子1,参考说明
  • 需要下载例子对应的模型文件
cd /opt/intel/openvino_2021/deployment_tools/open_model_zoo/tools/downloader
sudo  ./downloader.py --name face-detection-adas-0001 
  • 并修改代码包里ros2_openvino_toolkit/sample/param目录下
  • pipeline_people.launch.py对应的配置文件pipeline_people.yaml
  • xml和labels的路径都做变更
  • 内容如下:
- name: FaceDetection
  model: /opt/intel/openvino_2021.4.752/deployment_tools/open_model_zoo/tools/downloader/intel/face-detection-adas-0001/FP16-INT8/face-detection-adas-0001.xml
  engine: CPU
  label: /home/ubuntu/openvino2_ws/src/ros2_openvino_toolkit/data/labels/face_detection/face-detection-adas-0001.labels
  batch: 1
  • 所有可执行的launch文件
#run face detection sample code input from StandardCamera.
ros2 launch dynamic_vino_sample pipeline_people.launch.py
  • 测试例子2
  • 需要下载例子对应的模型文件
cd /opt/intel/openvino_2021/deployment_tools/open_model_zoo/tools/downloader
sudo ./downloader.py --name mobilenet-ssd
  • 下载到目录
/opt/intel/openvino_2021.4.752/deployment_tools/open_model_zoo/tools/downloader/public/mobilenet-ssd
  • 需要转化caffe模型为openvino格式
#进入目录
cd /opt/intel/openvino_2021/deployment_tools/model_optimizer
#新建临时目录用于保存转化文件
mkdir -p ~/tools/openvino/mobilenet-ssd
#转化
python3 mo.py --input_model /opt/intel/openvino_2021.4.752/deployment_tools/open_model_zoo/tools/downloader/public/mobilenet-ssd/mobilenet-ssd.caffemodel --output_dir ~/tools/openvino/mobilenet-ssd
#复制文件到
sudo cp ~/tools/openvino/mobilenet-ssd/* /opt/intel/openvino_2021.4.752/deployment_tools/open_model_zoo/tools/downloader/public/mobilenet-ssd/
  • 并修改代码包里ros2_openvino_toolkit/sample/param目录下
  • pipeline_object.launch.py对应的配置文件pipeline_object.yaml
  • xml和labels的路径都做变更
  • 内容如下:
- name: FaceDetection
  model: /opt/intel/openvino_2021.4.752/deployment_tools/open_model_zoo/tools/downloader/public/mobilenet-ssd/mobilenet-ssd.xml
  engine: CPU
  label: /home/ubuntu/openvino2_ws/src/ros2_openvino_toolkit/data/labels/mobilenet-ssd/mobilenet-ssd.labels
  batch: 1
  • 所有可执行的launch文件
#run face detection sample code input from StandardCamera.
ros2 launch dynamic_vino_sample pipeline_object.launch.py

参考:

  • https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_linux.html#install-openvino
  • https://github.com/intel/ros2_openvino_toolkit/blob/master/doc/getting_started_with_Foxy_Ubuntu20.04.md
  • https://docs.openvino.ai/latest/model_zoo.html
  • https://github.com/openvinotoolkit/open_model_zoo/
  • https://docs.openvino.ai/latest/get_started.html

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: ros2与深度学习教程

  • 上一篇: 没有了
  • 下一篇: 没有了