ros_openvino_toolkit环境搭建纪实
文章目錄
- 先決條件
- 一、配置環境
- 1. 安裝Open VINO 2020.3.194環境
- a. 在Ubuntu系統上無sudo權限命令行安裝OpenVINO
- b. 驗證安裝成功
- c. 安裝MO
- 2. 安裝ROS環境
- a. 換源
- b. 添加ros-latest.list并更新
- c. 激活ros環境
- d. 安裝ROS編譯相關的包
- 3. 安裝配置realsense相關環境
- 4. 安裝gflags-dev庫
- 5. 設置環境變量
- 三、編譯ros_openvino_toolkit
- 1. 下載
- 2. 編譯
- 3. 關于配置文件說明
- 四. 下載模型
- 關于下載模型時可能遇到的問題:
- 使用MO轉換模型
- 1. 更新protobuf
- 2. 設置快捷鍵
- 3. 模型轉換
- 給模型下載路徑設置鏈接
文章說明:關于openvino環境版本,需要安裝OpenVINO 2020版本,筆者實測,在OpenVINO 2020.3.194、2020.3.341、2020.3.355環境下都可以運行ros_openvino_toolkit項目。
先決條件
- 支持的CPU型號:x86_64,包括:
- 6th-8th Generation Intel? Core?
- Intel? Xeon? v5 family
- Intel? Xeon? v6 family
- 支持的集成顯卡配置(可選)
- 6th to 8th generation Intel? Core? processors with Iris? Pro graphics and Intel? HD Graphics
- 6th to 8th generation Intel? Xeon? processors with Iris Pro graphics and Intel HD Graphics (excluding the e5 product family, which does not have graphics)
- Intel? Pentium? processors N4200/5, N3350/5, N3450/5 with Intel HD Graphics
- 操作系統:Ubuntu 18.04 LTS
- ROS Melodic
- OpenVINO 2020.3 LTS
- RGB 攝像頭(RealSense D400 系列或標準USB 攝像頭)或 視頻/圖像文件作為輸入
一、配置環境
這里僅以無sudo權限安裝2020.3.194版本作為參考,僅僅只是提供一種思路。請讀者根據實際項目需求,自行選擇安裝版本和方式。
1. 安裝Open VINO 2020.3.194環境
參考
a. 在Ubuntu系統上無sudo權限命令行安裝OpenVINO
環境信息如下:
這里的安裝方式是下載安裝包并安裝。下載解壓步驟內容不再贅述,官方教程里面講解很詳細。
接下來進入OpenVINO解壓后的目錄,這里以~/Downloads目錄為例:
執行無UI安裝腳本后,按照提示安裝(這里我是通過默認安裝,安裝目錄在~/intel/openvino)
接下來source ./bin文件夾下的setupvars.sh,并將以下命令添加到.bashrc文件中(如果默認終端是zsh,就添加到.zshrc文件)
source ~/intel/openvino/bin/setupvars.shb. 驗證安裝成功
進入demo文件夾,執行驗證腳本
cd ~/intel/openvino/deployment_tools/demo # 將樣例和模型全下載下來,并編譯 ./demo_squeezenet_download_convert_run.sh # 編譯通過后執行 ~/inference_engine_samples_build/intel64/Release/classification_sample_async -i car.png -m ~/openvino_models/ir/public/squeezenet1.1/FP16/squeezenet1.1.xml -d CPU編譯成功截圖:
c. 安裝MO
參考Configuring the Model Optimizer(2020.3版本)
這里最好還是用虛擬環境,畢竟沒有root權限,無法在系統的/etc/python3/目錄下安裝。
使用anaconda的python可以安裝,也可以使用它提供的額外的虛擬環境。
- 新建虛擬環境
virtualenv --system-site-packages -p python3 ./venv - 啟動虛擬環境
source ./venv/bin/activate - 安裝MO
cd ./install_prerequisites/ && ./install_prerequisites.sh - 設置環境變量
將 alias venv_activate='source ~/intel/openvino/deployment_tools/model_optimizer/venv/bin/activate'添加到.zshrc或者.bashrc中,需要激活虛擬環境時,運行venv_activate即可
2. 安裝ROS環境
a. 換源
# 備份原來的sources.list sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup # 修改sources.list sudo gedit /etc/apt/sources.list將sources.list替換成以下內容:
# 默認注釋了源碼鏡像以提高 apt update 速度,如有需要可自行取消注釋 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse# 預發布軟件源,不建議啟用 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverseb. 添加ros-latest.list并更新
參考ROS wiki官方教程安裝時,有可能會出現如圖所示的錯誤,這時可以嘗試以下解決辦法:
參考鏈接:
c. 激活ros環境
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.bashrcd. 安裝ROS編譯相關的包
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential按照官網教程,運行以下命令:
sudo rosdep init sudo rosdep fix-permissions rosdep update這時候報錯:cannot download default sources list
解決辦法:
進入網站 https://ip.tool.chinaz.com/raw.githubusercontent.com,我們可以看到raw.githubusercontent.com 的IPV4地址,將其添加到/etc/hosts中,如
185.199.109.133 raw.githubusercontent.com并嘗試運行sudo rosdep init
如果運行rosdep init命令且終端顯示超時報錯時,可以嘗試以下辦法:
在文件末尾添加以下內容:
nameserver 8.8.8.8 #google域名服務器 nameserver 8.8.4.4 #google域名服務器PS: 為了加速GitHub訪問,推薦將以下內容添加到 /etc/hosts 文件中。
參考鏈接: https://gitee.com/ineo6/hosts
3. 安裝配置realsense相關環境
sudo apt-key adv --keyserver keys.gnupg.net --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE sudo add-apt-repository "deb http://realsense-hw-public.s3.amazonaws.com/Debian/apt-repo bionic main" -u sudo apt update sudo apt-get install librealsense2-dev sudo apt-get install ros-melodic-librealsense24. 安裝gflags-dev庫
sudo apt-get install -y libgflags-dev5. 設置環境變量
將以下內容添加到.bashrc或者.zshrc里面
export CPU_EXTENSION_LIB+=~/intel/openvino/deployment_tools/inference_engine/lib/intel64/libinference_engine.so export GFLAGS_LIB+=/usr/lib/x86_64-linux-gnu/libgflags_nothreads.a三、編譯ros_openvino_toolkit
1. 下載
獲取代碼
mkdir -p ~/catkin_ws/src cd ~/catkin_ws/src在工作空間下的src目錄中,下載ros_openvino_toolkit dev-ov2020.3:
git clone https://github.com/intel/ros_openvino_toolkit.git cd ros_openvino_toolkit/ git checkout dev-ov2020.3如果網絡狀況不佳,下載緩慢,可以嘗試使用gitee:
git clone https://gitee.com/openvinotoolkit-robotics/ros_openvino_toolkit.git cd ros_openvino_toolkit/ git checkout dev-ov2020.32. 編譯
在工作空間根目錄下編譯:
cd ~/catkin_ws catkin_make_isolated source ./devel_isolated/setup.bash3. 關于配置文件說明
修改 vino_launch/param文件夾下的yaml文件(以pipeline_object.yaml為例):
四. 下載模型
模型分為intel和public,我們先以intel的一個模型來做例子
關于下載模型時可能遇到的問題:
OpenVINO中文社區針對國內開發者下載緩慢的痛點,專門將常用public模型放入gitee倉庫https://gitee.com/openvinotoolkit-prc/public_models.git中,歡迎大家共同維護!
git clone https://gitee.com/openvinotoolkit-prc/public_models.git使用MO轉換模型
1. 更新protobuf
如果在運行mo時報錯:
[ ERROR ] Detected not satisfied dependencies:protobuf: not installed, required: 3.6.1根據提示,需要安裝protobuf,版本3.6.1
解決辦法:更新protobuf
- 參考鏈接: https://community.intel.com/t5/Intel-Distribution-of-OpenVINO/protobuf-not-installed-required-3-6-1/m-p/1154807/highlight/true?profile.language=zh-TW
2. 設置快捷鍵
添加以下命令到.zshrc或者.bashrc中:
alias model_printall='python3 ~/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --print_all' alias model_grep='python3 ~/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --print_all | grep' alias model_download_name='cd ~/intel/openvino/deployment_tools/open_model_zoo/tools/downloader && python3 ~/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name' alias cd_model_dir='cd ~/intel/openvino/deployment_tools/open_model_zoo/tools/downloader'3. 模型轉換
sudo python3 /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/converter.py --name=mobilenet-ssd --mo /opt/intel/openvino/deployment_tools/model_optimizer/mo.py給模型下載路徑設置鏈接
sudo mkdir -p /opt/ros_openvino_toolkit sudo ln -s /home/cxs/intel/openvino/deployment_tools/open_model_zoo/tools/downloader /opt/ros_openvino_toolkit/models總結
以上是生活随笔為你收集整理的ros_openvino_toolkit环境搭建纪实的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: TDD代码驱动测试基础
- 下一篇: 大于2的质数判断以及范围质数查找