Jetson TX2 部署SSD(Single Shot Detector)目标检测
实测视频
Realtime object detection is one of areas in computer vision that is still quite challenging performance-wise. When it comes to mobile/embedded application, GPUs certainly make a whole lot of difference allowing to achieve practically useful speeds. For example, SSD model described below runs at ~8.5 FPS on GPU and 0.03 FPS in CPU-only mode on TX1 board.
Single Shot MultiBox Detector (SSD) is one of the fastest currently available approaches to object detection on images. It achieves accuracy comparable to Faster-RCNN while in most cases performing faster than YOLO model. SSD is created by Wei Liu, Dragomir Anguelov, Dumitru Erhan, Christian Szegedy, Scott Reed, Cheng-Yang Fu, Alexander C. Berg. and is published on arXiv in December 2015.
来源
在前几天上手刷机完成后,发现和解决了几个问题:
- OpenCV版本是2.4,需要自己编译3.1的版本。
- 内置的32G储存卡容量不足,于是下单购买了一块250G的三星SSD做扩充。
- 购买了一个罗技c920摄像头,提高相机的水平。
- 原装套件中的天线功率不够,又买两根10DBI高增益的天线。
- 缺少固定SSD的螺丝,我购买外壳的淘宝店家居然没有送我,只好去电脑城里到处寻找合适长度的螺丝。缺少一根SATA线,同样在电脑城跑了十几家店终于买到了一根。
上面的问题都已经顺利解决,现在把硬盘,天线,相机都装了上去,并设置TX2从固态启动。

成功了,接下来我们部署一下SSD。
主要的流程是:
git clone https://github.com/weiliu89/caffe.git caffe-ssd
cd caffe-ssd
git checkout ssd
cp Makefile.config.example Makefile.config
Uncomment # USE_CUDNN := 1 to be USE_CUDNN := 1 (optional)
Uncomment # OPENCV_VERSION := 3 to be OPENCV_VERSION := 3
Change INCLUDE DIRS := to be INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
Add -gencode arch=compute_62,code=sm_62 and -gencode arch=compute_62,code=compute_62 to CUDA_ARCH:=\
如果报找不到hdf5需要做软链接。
cd /usr/lib/aarch64-linux-gnu/
sudo ln libhdf5_serial.so.10.1.0 libhdf5.so
sudo ln libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so
sudo ldconfig
make -j6
make test
make runtest
上面的两个链接中的内容合并起来看,基本可以完成caffe-ssd的编译。而在编译caffe的过程中,果不其然地出现了四五次编译错误,还好我已经有了两年多的caffe编译经验(😂),有惊无险地完成了编译。
然后按照第2个链接中的地址下载好模型。
./caffe-ssd/build/tools/caffe test \
--model="test.prototxt" \
--weights="VGG_VOC0712_SSD_300x300_iter_60000.caffemodel" \
--iterations="536870911" \
--gpu 0
就可以运行起来SSD啦!
然后,我把tx2开发板带到汽车上,尝试在车内进行实时的检测。由于没有显示器,我使用ssh -X来实时回传图像,可能是受到GPU能力和VGG较大模型的限制,SSD只能跑到8FPS左右。而且由于处理的延迟,需要2-3s才能在我的笔记本上显示出检测结果。
可以想象,这里的优化空间还是很大的。在真实的无人车上,延迟应该是以毫秒来计量,并且目标检测也应该和追踪结合,降低计算量,增强整个视觉感知的鲁棒性。
道路实测,又购买了一个飞利浦的220V逆变器。

这是在车上的设备。

摆放好之后,就可以用笔记本连接WIFI,使用ssh的X转发来看到视频啦!
下面是在车上实测的视频。