OpenPose的安装

来源:互联网 发布:vb语言程序设计 编辑:程序博客网 时间:2024/06/05 18:51

要求:

Ubuntu 14/16GPU 2GB/1.5GB (nvidia-smi查看显存)2GB RAM8核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 -j7sudo 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 cleanmake 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 successgithub 讨论帖:https://github.com/BVLC/caffe/issues/2348ps: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 statusmake: *** [build/tools/blob_proto_to_blob_binary.bin] Error 1make: *** 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
原创粉丝点击