SSD(caffe) 如何运行ssd_detect.cpp

版权声明:原创博客未经允许请勿转载! https://blog.csdn.net/holmes_MX/article/details/85062206

0. 写作目的

好记性不如烂笔头。

1. 准备阶段

正确编译caffe-ssd,具体过程可以参考博客

建议使用anaconda下的opencv(2或者3,建议安装opencv2, opencv3后期可能出现视频不能读入的问题),不建议使用pip install安装的opencv。

 

2. 运行ssd_detect.cpp

在编译的过程中,ssd_detect.cpp已经被编译过了,不需要使用g++再次编译(而且这样编译也不正确)。

运行时的命令,首先进入caffe-ssd的caffe路径下,然后运行

build/examples/ssd/ssd_detect.bin model_file weights_file list_file

// model_file is the .prototxt file
   weights_file is the .caffemodel file
   list_file contains a list of image files with the format as follows:
         folder/img1.jpg
         folder/img2.jpg
   list_file can also contain a list of video files with the format as follows:
         folder/video1.mp4
         folder/video2.mp4

问题1:此过程中可能出现错误 error while loading shared libraries: libopencv_core.so.3.2 cannot open share

这是由于不能找到libopencv_core.so.3.2的原因。(推荐另一种方法将/home/xxx/anaconda3/envs/py2Caffe/lib中有关opencv的lib文件拷贝到/usr/local/lib下)

系统在/etc/ld.so.conf中去找.so文件,因此找不到,所以需要将anaconda中envs中的py2Caffe lib中的libopencv_core.so.3.2加入到其中。命令如下:

cd /etc/ld.so.conf
sudo vim libc.conf

## add this file

## /home/XXX/anaconda3/envs/py2Caffe/lib


## save  and activate

sudo ldconfig 

问题2: 出现错误 ‘boost::filesystem::filesystem_error’    what(): boost::filesystem::status: Permission denied: "/root/data./VOCdevkit/results/VOC2007/SSD_300X300/Main"

这是由于deploy.prototxt中 save_output_param{ output_directory: "./root/data/VOCdevkit/results/VOC2007" .... }保存的参数的问题。

修改方法:将这个注释掉。

问题3: 当读取视频时出现: Unable to stop the stream: Inappropriate ioctl for device

这是由于opencv中缺少 ffmpeg依赖。

如果使用系统中的opencv进行编译caffe,直接安装sudo apt-get install ffmpeg,然后重现编译opencv,重新编译caffe(编译opencv时需要加上with_ffmpen=on,具体参考博客。).

如果使用anaconda中的opencv进行编译的caffe,在anconda中安装conda install ffmpeg,然后仍然需要安装ffmpeg,重新编译caffe。

ubuntu14中安装ffmpeg的过程如下。

sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next 
sudo apt-get update 
sudo apt-get install ffmpeg

[Reference] 

[1] https://blog.csdn.net/qq_36362060/article/details/78501231

[2] https://blog.csdn.net/holmes_MX/article/details/81318377

[3] ffmpeg 安装: https://www.cnblogs.com/wanghuixi/p/7630737.html

猜你喜欢

转载自blog.csdn.net/holmes_MX/article/details/85062206