OpenPose的安裝

要求:

Ubuntu 14/16
GPU 2GB/1.5GB (nvidia-smi查看顯存)
2GB RAM
8核CPU

非常重要:
如果安裝CUDA8的ubuntu14/16:
一.需要:CUDA, cuDNN, OpenCV, Atlas
1.OpenCV:

sudo apt-get install libopencv-dev

如果已經安裝OpenCV3, 修改相關makefile,把對應行改爲:# OPENCV_VERSION := 3
需要opencv_contrib模塊。安裝方法:

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=<path to opencv_contrib/modules/> ..

例如:

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=/home/wsh/software/opencv-3.1.0/opencv_contrib/modules/ .. 

然後:

make -j7
sudo make install

並在makefile中的LIBRARIES += opencv_core opencv_highgui opencv_imgproc 最後加上opencv_contrib
3.Atlas:

sudo apt-get install libatlas-base-dev

也可以安裝OpenBLAS或Inter MKL,並將BLAS := atlas改爲相應的.
二. 安裝Caffe 和 OpenPose

chmod u+x install_caffe_and_openpose.sh
./install_caffe_and_openpose.sh

如果想用CUDA7,安裝Caffe:

cd 3rdparty/caffe/
    # Select your desired Makefile file (run only one of the next 4 commands)
    cp Makefile.config.Ubuntu14_cuda_7.example Makefile.config # Ubuntu 14, cuda 7
    cp Makefile.config.Ubuntu14.example Makefile.config # Ubuntu 14, cuda 8
    cp Makefile.config.Ubuntu16_cuda_7.example Makefile.config # Ubuntu 16, cuda 7
    cp Makefile.config.Ubuntu16.example Makefile.config # Ubuntu 16, cuda 8
    # Change any custom flag from the resulting Makefile.config (e.g. OpenCV 3, Atlas/OpenBLAS/MKL, etc.)
    # Compile Caffe
    make all -j${number_of_cpus} && make distribute -j${number_of_cpus}
### Install OpenPose ###
    cd ../../models/
    ./getModels.sh # It just downloads the Caffe trained models
    cd ..
    # Same file cp command as the one used for Caffe
    cp Makefile.config.Ubuntu14_cuda_7.example Makefile.config
    # Change any custom flag from the resulting Makefile.config (e.g. OpenCV 3, Atlas/OpenBLAS/MKL, etc.)
    make all -j${number_of_cpus}

如果想使用自己的Caffe,按照Custom Caffe的方法安裝。
如果你需要修改東西,請:

make clean
make all -j$(NUM_CORES)

提示:
Makefile.config.Ubuntu##.example一共有2個,其中一個在../3rdparty/caffe/中,配置文件在其中,兩個文件的更改都要改:OpenCV 3 flag, Atlab/OpenBLAS/MKL flag, etc.
重新修改的方法:

make clean && cd 3rdparty/caffe && make clean

然後重新生成。
問題記錄:
1.出現:
CXX/LD -o .build_release/tools/convert_imageset.bin
.build_release/lib/libcaffe.so: undefined reference to cv::imread(cv::String const&, int)’ .build_release/lib/libcaffe.so: undefined reference tocv::imencode(cv::String const&, cv::_InputArray const&, std::vector >&, std::vector > const&)’
.build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)’
collect2: error: ld returned 1 exit status
make: * [.build_release/tools/convert_imageset.bin] Error 1

solution:
add "opencv_imgcodecs" in Makefile.(LIBRARIES += glog gflags protobuf leveldb snappy \
lmdb boost_system hdf5_hl hdf5 m \
opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs)
If you input "make all",the problem is the same again.But if you delete all the file in build(rm -rf ./build/*) before "make all"(I use make clean ),you will success.I just success
github 討論帖:https://github.com/BVLC/caffe/issues/2348
ps:
build/lib/libcaffe.a(image_io.o): In function caffe::ReadVideoToVolumeDatum(char const*, int, int, int, int, int, int, caffe::VolumeDatum*)': image_io.cpp:(.text+0x1905): undefined reference tocv::VideoCapture::VideoCapture()'
image_io.cpp:(.text+0x1abe): undefined reference to cv::VideoCapture::open(cv::String const&)' image_io.cpp:(.text+0x1ace): undefined reference tocv::VideoCapture::isOpened() const'
image_io.cpp:(.text+0x1c91): undefined reference to cv::VideoCapture::~VideoCapture()' image_io.cpp:(.text+0x1d22): undefined reference tocv::VideoCapture::get(int) const'
image_io.cpp:(.text+0x1d6d): undefined reference to cv::VideoCapture::set(int, double)' image_io.cpp:(.text+0x1de1): undefined reference tocv::VideoCapture::set(int, double)'
image_io.cpp:(.text+0x1e35): undefined reference to cv::VideoCapture::read(cv::_OutputArray const&)' image_io.cpp:(.text+0x1f7e): undefined reference tocv::VideoCapture::release()'
image_io.cpp:(.text+0x1fc3): undefined reference to cv::VideoCapture::read(cv::_OutputArray const&)' image_io.cpp:(.text+0x22e9): undefined reference tocv::VideoCapture::~VideoCapture()'
collect2: error: ld returned 1 exit status
make: *** [build/tools/blob_proto_to_blob_binary.bin] Error 1
make: *** Waiting for unfinished jobs....
same solution by adding opencv_videoio to LIBRARIES in the Makefile

類似問題,解決方案相同。
2.出現找不到opencv_contrib:
換成其中有的模塊
3.出現:
/home/usrname/opencv-3.0.0/modules/cudalegacy/src/graphcuts.cpp:120:54: error: ‘NppiGraphcutState’ has not been declared
typedef NppStatus (init_func_t)(NppiSize oSize, NppiGraphcutState* ppStat
/home/usrname/opencv-3.0.0/modules/cudalegacy/src/graphcuts.cpp:135:18: error: ‘NppiGraphcutState’ does not name a type
operator NppiGraphcutState*()
/home/usrname/opencv-3.0.0/modules/cudalegacy/src/graphcuts.cpp:141:9: error: ‘NppiGraphcutState’ does not name a type
NppiGraphcutState* pState;
解決方案:參考我的另外博客:
http://blog.csdn.net/yeluohanchan/article/details/75267438
4.出現:
fatal error: hdf5.h: 沒有那個文件或目錄 :
/opencv3.1.0/opencv_contrib/modules/hdf/include/opencv2/hdf/hdf5.hpp
把:

#include <hdf5.h>

改爲:

#include </usr/include/hdf5/serial/hdf5.h>

5.運行出錯:
./build/examples/openpose/rtpose.bin: error while loading shared libraries: libopencv_core.so.3.1: cannot open shared object file: No such file or directory
解決方法:

sudo ldconfig
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章