本文主要介绍了在树莓派(Raspbian 3b+)上搭建openvino相关环境以及实现一个简单人脸识别功能的详细步骤
硬件准备:
-
树莓派3b+,8G版本
-
SD卡一张、读卡器一枚
-
神经计算棒一枚(Intel Neural Compute Stick2, NCS2)
软件准备:
-
Raspberry Pi OS (32bit) :32位的树莓派操作系统
-
Rasberry Pi Imager:树莓派官方提供的将树莓派操作系统写入sd卡的软件工具
-
树莓派版本的Openvino工具
-
VNC Viewer/Xshell:远程查看操作树莓派工具
2.树莓派配置
第一步:打开 Raspberry Pi Imager

第二步:选择相应的操作系统

第三步:选择SD卡

第四步:然后开始写入

第五步:安装好后,将SD卡插入树莓派,启动树莓派,开启ssh/VNC权限 依次打开 菜单(Menu) > 首选项(Preferences) > Raspberry Pi Configuration: 点击 Interfaces 栏,选择“enable” SSH/VNC服务

第六步:在Terminal中使用ifconfig
命令,查询树莓派ip地址
第七步:输入树莓派ip地址,使用Xshell工具链接到树莓派:

第八步:进入Downloads文件夹,下载openvino Raspberry工具
第九步:创建一个用来保存软件主体的文件夹,并解压到该文件夹
sudo mkdir -p /opt/intel/openvino
sudo tar -xf l_openvino_toolkit_runtime_raspbian_p_2021.3.394.tgz --strip 1 -C /opt/intel/openvino
第十步:设置环境变量
echo "source /opt/intel/openvino/bin/setupvars.sh" >> ~/.bashrc
新开一个Terminal有如下初始化提示时便说明配置成功

第十一步:配置USB规则
sudo usermod -a -G users "$(whoami)
第十二步:运行如下命令以能够使用神经计算棒

第十三步:创建build文件夹
mkdir ~/build && cd ~/build
第十四步: 编译样例
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-march=armv7-a" /opt/intel/openvino/deployment_tools/inference_engine/samples/cpp
第十五步: 编译`object detecion_sample_ssd样例
make -j2 object_detection_sample_ssd

编译成功后,还需要下载添加模型文件才能完成完成检测
下载权重文件和模型文件 下载Inter仓库中预训练好模型的权重文件和模型文件:
wget --no-check-certificate https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.3/models_bin/2/face-detection-adas-0001/FP16/face-detection-adas-0001.bin
wget --no-check-certificate https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.3/models_bin/2/face-detection-adas-0001/FP16/face-detection-adas-0001.xml
最后: 测试结果 在网上下载一张带有人脸的图片,然后使用如下指令进行推理测试:
./armv7l/Release/object_detection_sample_ssd -m face-detection-adas-0001.xml -d MYRIAD -i face.png
控制台输出如下所示:


至此,基于树莓派的openvino人脸检测部署就全部完成了
网友评论