从 0 到 1 学习使用 DepthAI -手掌检测

这篇文章将介绍如何在 DepthAI 上实现手掌检测
你可以在演示中使用以下一组预先训练的模型:
▪ palm_detection 检测手掌
1.分析项目
项目地址
Palm Detection Model:https://google.github.io/mediapipe/solutions/hands#palm-detection-model
Hand_Detection_and_Tracking:https://github.com/PINTO0309/PINTO_model_zoo/tree/main/033_Hand_Detection_and_Tracking/10_new_128x128
2.获取模型
初始模型从 PINTO_model_zoo 获取, 其原始模型是 tflite,经Katsuya Hyodo转换为 tensorflow (.pb) 文件
Palm detection: https://github.com/PINTO0309/PINTO_model_zoo/blob/main/033_Hand_Detection_and_Tracking/10_new_128x128/download_resources.sh
3.查看模型
使用 Netron 查看模型文件
开头 可以看到 输入层的形状和名称

结尾 可以看到输出层的名字


4.模型转换为 IR 文件
openvino 支持直接转换 tensorflow 的模型:https://docs.openvinotoolkit.org/cn/latest/openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_TensorFlow.html
转换TensorFlow *模型
❶ 转到<OPENVINO_INSTALL_DIR>/deployment_tools/model_optimizer目录
❷ 使用mo.py脚本可以简单地将具有权重的.pb模型转换为.xml和.bin 文件:
mo.py --reverse_input_channels \
--input_model palm_detection.pb \
--model_name palm_detection \
--input input \
--output classificators,regressors \
--input_shape [1,128,128,3] \
--data_type FP16 \
--scale 127.5 \
--mean_values [127.5,127.5,127.5]
5.查看转换的 IR 文件
使用 Netron 查看 xml 文件
与之前比对

这时可以看到 输出的形状


6.IR 转换为 blob文件
将IR文件转换为blob文件:
export MYRIAD_COMPILE=$(find /opt/intel/ -iname myriad_compile)
$MYRIAD_COMPILE -m palm_detection.xml \
-ip U8 \
-VPU_MYRIAD_PLATFORM VPU_MYRIAD_2480 \
-VPU_NUMBER_OF_SHAVES 4 \
-VPU_NUMBER_OF_CMX_SLICES 4
7. 演示
手掌检测演示:https://docs.oakchina.cn/en/latest/pages/samples/palm_detection/

国内在哪里能买到DepthAI?
目前国内唯一的购买渠道是派驰的淘宝店:
OAK-D -派驰电子 淘宝:https://sourl.cn/9YEFE5
OAK-1 -派驰电子 淘宝:https://sourl.cn/4CpZUZ
参考链接:
OAK 中国:https://sourl.cn/6wt8sm
OAK 中文文档:https://sourl.cn/rawPZD