本文是FaceParse cvpr2015项目搭建: https://www.sifeiliu.net/face-parsing
1.命令行安装Matlab2016b,参见:https://www.cnblogs.com/Key-Ky/p/7918745.html
2. 按照官网安装caffe依赖。由于我的机器编译caffe失败,因此有必要查看所有的库是否已经安装好。没有安装好的自己手动源码安装。这里手动安装boost-1.69.0,opencv2.13.4,gflags
- opencv2编译见:https://blog.csdn.net/wzmsltw/article/details/52718472 特别注意要把 with-qt关闭掉。
- opencv3编译见:https://www.learnopencv.com/install-opencv3-on-ubuntu/
- gflags编译比较简单。
- boost源码编译,编译时选择python版本:
./bootstrap --with-python=/usr/bin/python3
./b2 cxxflags=-fPIC cflags=-fPIC --c++11
./b2 install --prefix=/usr/local/boost-1.69.0
3. 编译官网caffe与matcaffe Ubuntu16.04+cuda8+matlab2016b,见:https://blog.csdn.net/tomato_ljl/article/details/79169028
4. 主要把Makefile.config考到本项目中,修改相应Makefile,编译。本项目已经成功编译运行demo,参见我的 github makefile。注意的是用opencv3!Face_parsing_2016 中,重新make clean, make , make
注意:以上时编译matlab接口,不要用下面的anaconda lib,编译python接口可以用
遇到的错误:
1. anaconda/lib/libpng16.so.16:对‘inflateValidate@ZLIB_1.2.9’未定义的引用
我的解决方法是在Makefile.config加入下列信息:
LINKFLAGS := -Wl,-rpath,$(HOME)/anaconda3/lib
Makefile.config中是python3,open_cv3,加上上述语句是用anaconda的lib
2.在/usr/lib/x86_64-linux-gnu目录下,
sudo ln libhdf5_serial.so.10.1.0 libhdf5.so
sudo ln libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so
否则会提示:
/usr/bin/ld: 找不到 -lhdf5_hl
/usr/bin/ld: 找不到 -lhdf5
3. 在配置文件里找到python相关,我用的是anaconda:
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
ANACONDA_HOME := $(HOME)/anaconda3
PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
$(ANACONDA_HOME)/include/python3.5m \
$(ANACONDA_HOME)/lib/python3.5/site-packages/numpy/core/include
#注意,上面打HOME变量是系统默认的/home/用户名
这一行取消注释
# Uncomment to support layers written in Python (will link against Python libs)
WITH_PYTHON_LAYER := 1
4. 如果是python3编译,需要取消注释
PYTHON_LIBRARIES := boost_python3 python3.5m
否则会报错:/python/caffe/_caffe.so: undefined symbol: _ZN5boost6python6detail11init_moduleER11PyModuleDefPFvvE
5. 有关的找不到so:
cd x86_64-linux-gnu/
sudo ln -s libboost_python-py35.so libboost_python3.so
否则会报以下错误:
/usr/bin/ld: 找不到 -lboost_python3
collect2: error: ld returned 1 exit status
6.undefined reference to `cv::VideoCapture::VideoCapture()
modify : LIBRARIES += opencv_core opencv_highgui opencv_imgproc opencv_video
to: LIBRARIES += opencv_core opencv_highgui opencv_imgproc opencv_videoio
运行时错误:
ImportError: /lib/x86_64-linux-gnu/libz.so.1: version `ZLIB_1.2.9' not found (required by /home/dingyang/anaconda3/lib/libpng16.so.16)
Download Zlib 1.2.9 Then run those commands
tar -xvf ~/Downloads/zlib-1.2.9.tar.gz
cd zlib-1.2.9
sudo -s
./configure; make; make install
cd /lib/x86_64-linux-gnu
ln -s -f /usr/local/lib/libz.so.1.2.9/lib libz.so.1
cd ~
rm -rf zlib-1.2.9