项目中用到了OAK相机,在这里做一下小结与记录
OAK安装
-
对于windows, 下载.exe安装文件来安装depthai
-
在linux/ubuntu:
-
安装opencv库
sudo apt install libopencv-dev
-
下载depthai core的deb安装包(不要编源码,以免遇坑),然后(deb包名换成最新文件名)
sudo apt install ./depthai_2.15.0_x86_64_Shared.deb
-
depthai项目链接
项目 链接 备注 depthai https://gitee.com/oakchina/depthai depthai-python https://gitee.com/oakchina/depthai-python 示例在examples文件夹 depthai-experiments https://gitee.com/oakchina/depthai-experiments 更多python示例 depthai-core https://github.com/luxonis/depthai-core c++, 示例在examples文件夹
-
-
在Nvidia的Jetson以及Raspberry Pi OS,安装参考链接
-
另,OAK相关的产品手册与3D模型
YOLOv5训练
-
这里使用的是yolo_v5 v6.1,嫌配置CUDA麻烦可以拉nvidia的docker镜像。
-
注意,有可能遇到这个报错:
AttributeError: module ‘numpy‘ has no attribute ‘int‘.
一个简单的解决方法是搜一下yolo代码里的astype(np.int),全改astype(int),参见链接
-
常用命令行,注意OAK推荐检测尺寸是416或640,尺寸不是很大
python train.py --img 640 --batch 16 --epoch 150 --data data/self.yaml --cfg models/yolov5n.yaml --weights weights/yolov5n6.pt --hyp data/hyps/hyp.self-scratch-low.yaml --save-period 10 --cos-lr --device '0' python detect.py --weights runs/train/exp/weights/best.pt --save-txt --source /img_bat/vid_data/02
-
OAK相机onnx导出+转blob。
- 注意链接文章中export_onnx.py应稍微修改下167行,
model = attempt_load(input_model, map_location=device, inplace=True, fuse=True) #原链接中的代码 model = attempt_load(input_model, device=device, inplace=True, fuse=True) #修改后
- 转blob常用命令行
#export_onnx.py转onnx python export_onnx.py -w runs/train/exp/weights/best.pt -imgsz 640 #onnx->blob blobconverter --onnx ./best.onnx -sh 5 -o . --optimizer-params "scale=255 --reverse_input_channel" # OAK推荐链接中shaves设置成6,但我实际运行时报出warning提示"compiling for 5 shaves likely will yield in better performance", 故这里"-sh 5"
关于与深度检测结合的部分,后续更新