ros2与深度学习教程-整合物体检测(mobilenet-ssd)
ros2与深度学习教程-整合物体检测(mobilenet-ssd)
说明:
- 介绍如何整合Openvino使用mobilenet-ssd模型
步骤:
- pipeline_object.launch.py物体识别
- 需要下载例子对应的模型文件
cd /opt/openvino_toolkit/models/
sudo python3 downloader.py --name mobilenet-ssd
- 下载到目录
/opt/openvino_toolkit/models/public/mobilenet-ssd
- mobilenet-ssd是caffe模型,需要转化caffe模型为openvino格式
#进入目录
cd /opt/intel/openvino_2021/deployment_tools/model_optimizer
#更改目录权限
sudo chmod -R 777 /opt/openvino_toolkit/models/public/mobilenet-ssd
#转化
python3 mo.py --input_model /opt/openvino_toolkit/models/public/mobilenet-ssd/mobilenet-ssd.caffemodel --output_dir /opt/openvino_toolkit/models/public/mobilenet-ssd/
- 复制labels文件
sudo cp ~/openvino2_ws/src/ros2_openvino_toolkit/data/labels/object_detection/mobilenet-ssd.labels /opt/openvino_toolkit/models/public/mobilenet-ssd/
- 并修改代码包里ros2_openvino_toolkit/sample/param目录下pipeline_object.launch.py对应的配置文件pipeline_object.yaml
- 内容如下:
Pipelines:
- name: object
inputs: [StandardCamera]
infers:
- name: ObjectDetection
model: /opt/openvino_toolkit/models/public/mobilenet-ssd/mobilenet-ssd.xml
engine: CPU
label: /opt/openvino_toolkit/models/public/mobilenet-ssd/obilenet-ssd.labels
batch: 1
confidence_threshold: 0.5
enable_roi_constraint: true # set enable_roi_constraint to false if you don't want to make the inferred ROI (region of interest) constrained into the camera frame
outputs: [ImageWindow, RosTopic, RViz]
connects:
- left: StandardCamera
right: [ObjectDetection]
- left: ObjectDetection
right: [ImageWindow]
- left: ObjectDetection
right: [RosTopic, RViz]
OpenvinoCommon:
测试:
- 接好usb摄像头
- 新开终端,执行命令
#run face detection sample code input from StandardCamera.
ros2 launch dynamic_vino_sample pipeline_object.launch.py
- 查看话题
ros2 run rqt_image_view rqt_image_view
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号