ros_openvino_toolkit环境搭建纪实
文章目錄
- 先決條件
- 一、配置環(huán)境
- 1. 安裝Open VINO 2020.3.194環(huán)境
- a. 在Ubuntu系統(tǒng)上無(wú)sudo權(quán)限命令行安裝OpenVINO
- b. 驗(yàn)證安裝成功
- c. 安裝MO
 
- 2. 安裝ROS環(huán)境
- a. 換源
- b. 添加ros-latest.list并更新
- c. 激活ros環(huán)境
- d. 安裝ROS編譯相關(guān)的包
 
- 3. 安裝配置realsense相關(guān)環(huán)境
- 4. 安裝gflags-dev庫(kù)
- 5. 設(shè)置環(huán)境變量
 
- 三、編譯ros_openvino_toolkit
- 1. 下載
- 2. 編譯
- 3. 關(guān)于配置文件說(shuō)明
 
- 四. 下載模型
- 關(guān)于下載模型時(shí)可能遇到的問(wèn)題:
- 使用MO轉(zhuǎn)換模型
- 1. 更新protobuf
- 2. 設(shè)置快捷鍵
- 3. 模型轉(zhuǎn)換
 
- 給模型下載路徑設(shè)置鏈接
 
文章說(shuō)明:關(guān)于openvino環(huán)境版本,需要安裝OpenVINO 2020版本,筆者實(shí)測(cè),在OpenVINO 2020.3.194、2020.3.341、2020.3.355環(huán)境下都可以運(yùn)行ros_openvino_toolkit項(xiàng)目。
先決條件
- 支持的CPU型號(hào):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
 
- 操作系統(tǒng):Ubuntu 18.04 LTS
- ROS Melodic
- OpenVINO 2020.3 LTS
- RGB 攝像頭(RealSense D400 系列或標(biāo)準(zhǔn)USB 攝像頭)或 視頻/圖像文件作為輸入
一、配置環(huán)境
這里僅以無(wú)sudo權(quán)限安裝2020.3.194版本作為參考,僅僅只是提供一種思路。請(qǐng)讀者根據(jù)實(shí)際項(xiàng)目需求,自行選擇安裝版本和方式。
1. 安裝Open VINO 2020.3.194環(huán)境
參考
a. 在Ubuntu系統(tǒng)上無(wú)sudo權(quán)限命令行安裝OpenVINO
環(huán)境信息如下:
這里的安裝方式是下載安裝包并安裝。下載解壓步驟內(nèi)容不再贅述,官方教程里面講解很詳細(xì)。
 接下來(lái)進(jìn)入OpenVINO解壓后的目錄,這里以~/Downloads目錄為例:
執(zhí)行無(wú)UI安裝腳本后,按照提示安裝(這里我是通過(guò)默認(rèn)安裝,安裝目錄在~/intel/openvino)
接下來(lái)source ./bin文件夾下的setupvars.sh,并將以下命令添加到.bashrc文件中(如果默認(rèn)終端是zsh,就添加到.zshrc文件)
source ~/intel/openvino/bin/setupvars.shb. 驗(yàn)證安裝成功
進(jìn)入demo文件夾,執(zhí)行驗(yàn)證腳本
cd ~/intel/openvino/deployment_tools/demo # 將樣例和模型全下載下來(lái),并編譯 ./demo_squeezenet_download_convert_run.sh # 編譯通過(guò)后執(zhí)行 ~/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版本)
這里最好還是用虛擬環(huán)境,畢竟沒(méi)有root權(quán)限,無(wú)法在系統(tǒng)的/etc/python3/目錄下安裝。
 使用anaconda的python可以安裝,也可以使用它提供的額外的虛擬環(huán)境。
- 新建虛擬環(huán)境
 virtualenv --system-site-packages -p python3 ./venv
- 啟動(dòng)虛擬環(huán)境
 source ./venv/bin/activate
- 安裝MO
 cd ./install_prerequisites/ && ./install_prerequisites.sh
- 設(shè)置環(huán)境變量
 將 alias venv_activate='source ~/intel/openvino/deployment_tools/model_optimizer/venv/bin/activate'添加到.zshrc或者.bashrc中,需要激活虛擬環(huán)境時(shí),運(yùn)行venv_activate即可
2. 安裝ROS環(huán)境
a. 換源
# 備份原來(lái)的sources.list sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup # 修改sources.list sudo gedit /etc/apt/sources.list將sources.list替換成以下內(nèi)容:
# 默認(rèn)注釋了源碼鏡像以提高 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# 預(yù)發(fā)布軟件源,不建議啟用 # 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官方教程安裝時(shí),有可能會(huì)出現(xiàn)如圖所示的錯(cuò)誤,這時(shí)可以嘗試以下解決辦法:
 
參考鏈接:
c. 激活ros環(huán)境
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.bashrcd. 安裝ROS編譯相關(guān)的包
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential按照官網(wǎng)教程,運(yùn)行以下命令:
sudo rosdep init sudo rosdep fix-permissions rosdep update這時(shí)候報(bào)錯(cuò):cannot download default sources list
 
 解決辦法:
進(jìn)入網(wǎng)站 https://ip.tool.chinaz.com/raw.githubusercontent.com,我們可以看到raw.githubusercontent.com 的IPV4地址,將其添加到/etc/hosts中,如
185.199.109.133 raw.githubusercontent.com并嘗試運(yùn)行sudo rosdep init
 
 如果運(yùn)行rosdep init命令且終端顯示超時(shí)報(bào)錯(cuò)時(shí),可以嘗試以下辦法:
在文件末尾添加以下內(nèi)容:
nameserver 8.8.8.8 #google域名服務(wù)器 nameserver 8.8.4.4 #google域名服務(wù)器PS: 為了加速GitHub訪問(wèn),推薦將以下內(nèi)容添加到 /etc/hosts 文件中。
 參考鏈接: https://gitee.com/ineo6/hosts
3. 安裝配置realsense相關(guān)環(huán)境
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庫(kù)
sudo apt-get install -y libgflags-dev5. 設(shè)置環(huán)境變量
將以下內(nèi)容添加到.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如果網(wǎng)絡(luò)狀況不佳,下載緩慢,可以嘗試使用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. 關(guān)于配置文件說(shuō)明
修改 vino_launch/param文件夾下的yaml文件(以pipeline_object.yaml為例):
四. 下載模型
模型分為intel和public,我們先以intel的一個(gè)模型來(lái)做例子
關(guān)于下載模型時(shí)可能遇到的問(wèn)題:
OpenVINO中文社區(qū)針對(duì)國(guó)內(nèi)開(kāi)發(fā)者下載緩慢的痛點(diǎn),專門將常用public模型放入gitee倉(cāng)庫(kù)https://gitee.com/openvinotoolkit-prc/public_models.git中,歡迎大家共同維護(hù)!
git clone https://gitee.com/openvinotoolkit-prc/public_models.git使用MO轉(zhuǎn)換模型
1. 更新protobuf
如果在運(yùn)行mo時(shí)報(bào)錯(cuò):
[ ERROR ] Detected not satisfied dependencies:protobuf: not installed, required: 3.6.1根據(jù)提示,需要安裝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. 設(shè)置快捷鍵
添加以下命令到.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. 模型轉(zhuǎn)換
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給模型下載路徑設(shè)置鏈接
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總結(jié)
以上是生活随笔為你收集整理的ros_openvino_toolkit环境搭建纪实的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
 
                            
                        - 上一篇: TDD代码驱动测试基础
- 下一篇: [译] ROS C++ 代码规范
