Ubuntu 14.04下编译OpenPose

OpenPose是CMU开发的一个开源人体姿态检测模型,github地址为:https://github.com/CMU-Perceptual-Computing-Lab/openpose,下面为在ubuntu 14.04版本上编译的过程

  • 下载源码
    由于openpose依赖于第三方的caffe学习框架,所以在git clone一定要加上"--recursive"选项,如下所示:
#git clone --recursive https://github.com/CMU-Perceptual-Computing-Lab/openpose
  • 编译
    采用CMake方式编译,如下:
#mkdir build
#cd build
#cmake ..
#make -j10

编译过程中出现如下错误:

hank@hank-desktop:~/Study/CV/openpose/build$ make
[ 12%] Performing build step for 'openpose_caffe'
[  1%] Building CXX object src/caffe/CMakeFiles/caffeproto.dir/__/__/include/caffe/proto/caffe.pb.cc.o
In file included from /usr/include/c++/4.8/mutex:35:0,
                 from /usr/local/include/google/protobuf/stubs/mutex.h:33,
                 from /usr/local/include/google/protobuf/stubs/common.h:52,
                 from /home/hank/Study/CV/openpose/build/caffe/src/openpose_caffe-build/include/caffe/proto/caffe.pb.h:9,
                 from /home/hank/Study/CV/openpose/build/caffe/src/openpose_caffe-build/include/caffe/proto/caffe.pb.cc:4:
/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
In file included from /usr/local/include/google/protobuf/stubs/common.h:52:0,
                 from /home/hank/Study/CV/openpose/build/caffe/src/openpose_caffe-build/include/caffe/proto/caffe.pb.h:9,
                 from /home/hank/Study/CV/openpose/build/caffe/src/openpose_caffe-build/include/caffe/proto/caffe.pb.cc:4:
/usr/local/include/google/protobuf/stubs/mutex.h:58:3: error: ‘mutex’ in namespace ‘std’ does not name a type
   std::mutex mu_;

需要修改Caffe软件包的3rdparty/caffe/CMakeLists.txt文件,修改的地方如下:

# ---[ Flags
if(UNIX OR APPLE)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -std=c++11")
endif()

caffe_set_caffe_link()

if(USE_libstdcpp)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
  message("-- Warning: forcing libstdc++ (controlled by USE_libstdcpp option in cmake)")
endif()

# ---[ Warnings
caffe_warnings_disable(CMAKE_CXX_FLAGS -Wno-sign-compare -Wno-uninitialized)

# ---[ Config generation
configure_file(cmake/Templates/caffe_config.h.in "${PROJECT_BINARY_DIR}/caffe_config.h")

# ---[ Includes
set(Caffe_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
set(Caffe_SRC_DIR ${PROJECT_SOURCE_DIR}/src)
include_directories(${PROJECT_BINARY_DIR})

# ---[ Includes & defines for CUDA

# cuda_compile() does not have per-call dependencies or include pathes
# (cuda_compile() has per-call flags, but we set them here too for clarity)
#
# list(REMOVE_ITEM ...) invocations remove PRIVATE and PUBLIC keywords from collected definitions and include pathes
if(HAVE_CUDA)
  # pass include pathes to cuda_include_directories()
  set(Caffe_ALL_INCLUDE_DIRS ${Caffe_INCLUDE_DIRS})
  list(REMOVE_ITEM Caffe_ALL_INCLUDE_DIRS PRIVATE PUBLIC)
  cuda_include_directories(${Caffe_INCLUDE_DIR} ${Caffe_SRC_DIR} ${Caffe_ALL_INCLUDE_DIRS})

  # add definitions to nvcc flags directly
  set(Caffe_ALL_DEFINITIONS ${Caffe_DEFINITIONS})
  list(REMOVE_ITEM Caffe_ALL_DEFINITIONS PRIVATE PUBLIC)
  list(APPEND CUDA_NVCC_FLAGS ${Caffe_ALL_DEFINITIONS})
  set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std=c++11")
endif()

主要有两个地方:
(1)set(CMAKE_CXX_FLAGS "{CUDA_NVCC_FLAGS} -std=c++11")

修改后编译通过。

你可能感兴趣的:(Ubuntu 14.04下编译OpenPose)