Git網址:https://github.com/leonzfa/iResNet
首先安装caffe,安装过程请参考:
https://blog.csdn.net/zhuiqiuzhuoyue583/article/details/88756053
我已经安装cuda8.0,cudnn5.1,opencv3.1,caffe1.0.0
下載源代碼:https://github.com/leonzfa/iResNet.git
將文件命名爲“iResNet”,在iResNet目錄下,進行編譯。
cd iResNet
sudo make clean
sudo make all -j 12 tools
问题1:/usr/include/opencv2/gpu/gpu.hpp(438): error: vector is not a template
解决方法:
将 iResNet/src/caffe/layers/resample_layer.cu中的
#include <opencv2/gpu/gpu.hpp> 注释掉
即:
//#include <opencv2/gpu/gpu.hpp>
或者 在 #include <opencv2/gpu/gpu.hpp> 上面一行加上 using namespace std; (我用的此方法)
即:
using namespace std;
#include <opencv2/gpu/gpu.hpp>
參考:https://github.com/liruoteng/FlowNet/issues/11
https://blog.csdn.net/qq_34570910/article/details/78245706
https://stackoverflow.com/questions/26121604/opencv-2-4-9-compilation-error-with-cuda-6-5/29916815
问题2:tools/convert_imageset_and_disparity.cpp:156:31: error: ‘numeric_limits’ is not a member of ‘std’
value=std::numeric_limits<short>::max();
解决方法:
tools/convert_imageset_and_disparity.cpp 中添加
#include <limits>
注意,這裏會出現多個”‘numeric_limits’ is not a member of ‘std’
value=std::numeric_limits<short>::max();“
需要在相應的cpp文件中添加 ”#include <limits>“
參考:https://github.com/opencv/opencv_contrib/issues/836
https://github.com/lmb-freiburg/flownet2/issues/75
https://blog.csdn.net/shanpenghui/article/details/79487015
https://blog.csdn.net/midi666/article/details/83151729
https://www.cnblogs.com/Jacket-K/p/9830239.html
ubuntu16.04 使用C++11:https://blog.csdn.net/zhuiqiuzhuoyue583/article/details/88903719
问题3:.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
报错原因:
解决方法:
在“Makefile.config”中默认使用的是opencv2,因此出现这个错误。
Makefile.config中OPENCV_VERSION := 3
取消注释(亲测可用,建議使用這種方法)
或者
很明显是OpenCV出了问题,网上查阅后,得知是因为lib文件opencv_imgcodecs
在Makefile
文件中未添加,修改如下:
LIBRARIES += glog gflags protobuf leveldb snappy \
lmdb boost_system hdf5_hl hdf5 m \
opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs
此外,还有一些Makefile文件这么写,也是可行的:
ifeq ($(USE_OPENCV), 1)
LIBRARIES += opencv_core opencv_highgui opencv_imgproc
ifeq ($(OPENCV_VERSION), 3)
LIBRARIES += opencv_imgcodecs
endif
endif
參考:https://blog.csdn.net/u011636440/article/details/82660697