ubuntu20.04 版本下安装Openpose (包括Opencv,caffe,cuda,cudnn)的超详细笔记--更新于2021-4-14 (3)

添加打印,发现caffe的include是:caffe_INCLUDE_DIRS PUBLIC;/usr/include;PUBLIC;/usr/include;PUBLIC;/usr/include;PUBLIC;/usr/include;PUBLIC;/usr/include/hdf5/serial;PUBLIC;/usr/include;PUBLIC;/usr/include;PRIVATE;/usr/include;PUBLIC;/usr/local/cuda/include;PUBLIC;/usr/local/include/opencv4;PUBLIC;/usr/include/x86_64-linux-gnu;/usr/include/x86_64-linux-gnu; PRIVATE;/usr/include/python3.8;/usr/lib/python3/dist-packages/numpy/core/include;PUBLIC;/usr/include

所以需要将这个文件的根目录:/home/edward/git/libs/openpose2021/3rdparty/caffe/include/

直接修改CMakeLists.txt

set(Caffe_INCLUDE_DIRS ${Caffe_INCLUDE_DIRS};${PROJECT_SOURCE_DIR}/include)

--看起来是有效的,需要generate

cudnn的问题(去除cudnn)

1)home/edward/git/libs/openpose2021/3rdparty/caffe/src/caffe/layers/cudnn_conv_layer.cpp:136:7: error: ‘CUDNN_CONVOLUTION_FWD_SPECIFY_WORKSPACE_LIMIT’ was not declared in this scope

CUDNN_CONVOLUTION_FWD_SPECIFY_WORKSPACE_LIMIT,

suggested alternative: ‘CUDNN_CONVOLUTION_FWD_ALGO_DIRECT’

这个修改都按照最新cudnn的API来作适当的修改。

2)/home/edward/git/libs/openpose2021/3rdparty/caffe/src/caffe/layers/cudnn_conv_layer.cpp:131:17: error: there are no arguments to ‘cudnnGetConvolutionForwardAlgorithm’ that depend on a template parameter, so a declaration of ‘cudnnGetConvolutionForwardAlgorithm’ must be available [-fpermissive]

3)在Opencv3 cv::CV_LOAD_IMAGE_COLOR 已经找不到了,都用cv::IMREAD_COLOR替换

This means you need to use cv::CV_LOAD_IMAGE_COLOR when using OpenCv 3.0 instead of cv::IMREAD_COLOR

CV_LOAD_IMAGE_GRAYSCALE to cv::IMREAD_GRAYSCALE

The documentation for OpenCV 3.0 can be found here:

The current enum responsible for imread is:

enum cv::ImreadModes {

cv::IMREAD_UNCHANGED = -1,

cv::IMREAD_GRAYSCALE = 0,

cv::IMREAD_COLOR = 1,

cv::IMREAD_ANYDEPTH = 2,

cv::IMREAD_ANYCOLOR = 4,

cv::IMREAD_LOAD_GDAL = 8

}

4)向_v7转变主要涉及到conv_layer,deconv_layer等几个文件,都在layers目录下。

.

其他的一些问题:

7.1、编译得好好的之后(删除掉了use_Cudnn)莫名其妙出现

edward@Server-adiAi:~/software/openpose/3rdparty/caffe$ sudo make clean

Package opencv was not found in the pkg-config search path.

Perhaps you should add the directory containing `opencv.pc\'

to the PKG_CONFIG_PATH environment variable

No package \'opencv\' found

7.2执行如下语句时出现:pkg-config --cflags opencv

出现找不到opencv的错误

解决方法

cd /usr/local/lib

sudo mkdir pkgconfig

cd pkgconfig

sudo touch opencv.pc

---在文件中加入

prefix=http://www.likecs.com/usr/local

exec_prefix=${prefix}

includedir=${prefix}/include

libdir=${exec_prefix}/lib

Name: opencv

Description: The opencv library

Version:4.0.1

Cflags: -I${includedir}/opencv4

Libs: -L${libdir} -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core

7.3 设定PKG_CONFIG_PATH

export PKG_CONFIG_PATH=http://www.likecs.com/usr/local/lib/pkgconfig

可以写入到/etc/profile.d/cuda.sh,在Ubuntu系统中,/etc/profile.d/下面的sh文件都会在开机时启动。所以创建cuda.sh,在这个sh里面配置系统变量。

vim /etc/profile.d/cuda.sh

chmod a+x /etc/profile.d/cuda.sh

文件中添加:

export PKG_CONFIG_PATH=http://www.likecs.com/usr/local/lib/pkgconfig

检测结果可以执行:pkg-config --cflags --libs opencv

7.4. 编译Openpose的错误

fatal error: caffe/proto/caffe.pb.h: No such file or directory

解决:

打开终端,进入caffe所在路径

执行以下指令

mkdir include/caffe/proto

protoc ./src/caffe/proto/caffe.proto --cpp_out=.

mv ./src/caffe/proto/caffe.pb.h ./include/caffe/proto/

附录:caffe中Makefile.config详解

https://blog.csdn.net/jiaxinhong/article/details/82826391

#提前下好model减少配置时间sudo -- 可以直接通过 ./getModles.sh来操作

- [BODY_25 model](): download in `models/pose/body_25/`.

- [COCO model](): download in `models/pose/coco/`.

- [MPI model](): download in `models/pose/mpi/`.

- [Face model](): download in `models/face/`.

- [Hands model](): download in `models/hand/`.

将下好的model和caffe分别放入/openpose/models和/3rdparty/caffe

2、下载Models

cd models

./getModels.sh

cd ..

3、使用cmake-gui编译安装

使用cmake-gui进行配置检查opencv、cuda路径(配置步骤如下)

ubuntu20.04 版本下安装Openpose (包括Opencv,caffe,cuda,cudnn)的超详细笔记--更新于2021-4-14

这里因为已经将caffe编译好了,所以可以直接编译openpose。去掉BUILD_CAFFE选项。BUID_PYTHON选项需要在仔细观察以下。

出现:

cmake-gui .. 出现

CMake Error at python/openpose/CMakeLists.txt:6 (pybind11_add_module): Unknown CMake command "pybind11_add_module".异常

解决办法:在3rdparty目录下执行:

git clone https://github.com/pybind/pybind11.git

在openpose目录下创建build文件夹:

sudo mkdir build

cd build

sudo /pathto/cmake-gui ..

sudo make

sudo make install

OpenCV的安装

安装OpenCV的依赖:

#启动

$ sudo apt-get update

$ sudo apt-get upgrade

# 安装依赖

$ sudo apt-get install build-essential cmake git unzip pkg-config

$ sudo apt-get install libjpeg-dev libpng-dev libtiff-dev

$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev

$ sudo apt-get install libgtk2.0-dev libcanberra-gtk*

$ sudo apt-get install python3-dev python3-numpy python3-pip

$ sudo apt-get install libxvidcore-dev libx264-dev libgtk-3-dev

$ sudo apt-get install libtbb2 libtbb-dev libdc1394-22-dev

$ sudo apt-get install libv4l-dev v4l-utils

$ sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev

$ sudo apt-get install libavresample-dev libvorbis-dev libxine2-dev

$ sudo apt-get install libfaac-dev libmp3lame-dev libtheora-dev

$ sudo apt-get install libopencore-amrnb-dev libopencore-amrwb-dev

$ sudo apt-get install libopenblas-dev libatlas-base-dev libblas-dev

$ sudo apt-get install liblapack-dev libeigen3-dev gfortran

$ sudo apt-get install libhdf5-dev protobuf-compiler

$ sudo apt-get install libprotobuf-dev libgoogle-glog-dev libgflags-dev

# 创建 symlink to videodev.h

$ cd /usr/include/linux

$ sudo ln -s -f ../libv4l1-videodev.h videodev.h

$ cd ~

下载OpenCV

需要下载两个:opencv.zip 和 opencv_contrib.zip。也可到 https://opencv.org/releases/下载最新版本

git下载,并指定版本:

sudo git clone https://github.com/opencv/opencv.git

sudo git clone https://github.com/opencv/opencv_contrib.git

cd opencv

sudo git checkout -f 4.4.0

cd ../opencv_contrib

sudo git checkout -f 4.4.0

===

$ cd ~

$ wget -O opencv.zip https://github.com/opencv/opencv/archive/4.4.0.zip

$ wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.4.0.zip

$ unzip opencv.zip

$ unzip opencv_contrib.zip

$ mv opencv-4.4.0 opencv

$ mv opencv_contrib-4.4.0 opencv_contrib

$ cd opencv

$ mkdir build

$ cd build

$ sudo cmake-gui ..

这里推荐采用cmake-gui进行安装。

首先安装cmake-gui

然后再opencv下创建一个build, 进入build目录后,执行 /pathTo/cmake-gui ..

点击configure,然后再图形上进行配置,完成配置后,点generate。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwddjw.html