简介原创
是一个关于人体动作捕捉的库。
# 前置要求
# General Tips
必须保证 models
文件夹下相关存在。如:
- 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/.
# mac cmake
// 如果 mac 未安装 brew ,执行这条命令。 安装过的不用执行命令安装
bash scripts/osx/install_brew.sh
// 通过 brew 安装 cmake 不是最新 mac 系统不建议用这个
brew cask install cmake
// 使用脚本命令安装 Caffe, OpenCV, and Caffe prerequisite 不是最新 mac 系统不建议用这个
bash scripts/osx/install_deps.sh
// bash scripts/osx/install_deps.sh 会检测 brew 升级,可以通过 ctrl+c 终止升级,以继续进行安装。
install_deps.sh
中需要安装的依赖有:openblas snappy leveldb gflags glog szip lmdb hdf5 opencv protobuf boost cmake viennacl 等。
如果无法通过 brew 安装 cmake ,可以到官网下载 (opens new window),请下载对应的系统版本!
我的是黑苹果 10.13 (opens new window)
安装完成后记得进行配置,不然无法使用 cmake
命令。
这种方法可以通过 Cmake.App
的菜单栏中的 Tools
下的 How to install For Command Libe Use
快速进行配置。
我使用第二种方法,直接执行 sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install
执行完后在 terminal
中使用 cmake --version
测试是否配置成功。
# CUDA
安装参考 (opens new window)
安装参考2 (opens new window)
使用参考2中的百度网盘连接,不然自己无法下载。
首先得确定自己显卡的驱动版本号,由于我的是黑苹果, GTX1050Ti 。
在 NVIDIA Driver Mananger
中,Updates
栏下 NVIDIA Web Driver
获取自己显卡的版本号。如我的是:387.10.10.10.40.105
。
# CUDA 下载
官网下载 (opens new window)
我的 GTX1050Ti
的 NVIDIA Web Driver
版本号 387.10.10.10.40.105
对应的 CUDA
版本号为 CUDA 396.148 driver for MAC
下载链接 (opens new window)
但是我安装的是 NVIDIA CUDA 418.163 FOR MACOS
不知道自己 CUDA
对应版本号,可以直接在网页中搜索自己 NVIDIA Web Driver
来比对。
# CUDA Toolkit
!!! 无法从官网下载最新版本
还需要安装 CUDA Toolkit
,我安装的是Visual Profiler (opens new window) ,其他系统下载win Linu 下载 (opens new window)
# openpose install
mac 安装与初始化。
需要注意的是,需要 Mac OSX Mavericks
以上系统,即 mac 10.9
以上系统。
git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose
cd openpose/
git submodule update --init --recursive --remote
# 安装 caffe 和 pybind11
cd 3rdparty
rm -rf caffe
rm -rf pybind11
git clone https://github.com/CMU-Perceptual-Computing-Lab/caffe
git clone https://github.com/pybind/pybind11
cd 3rdparty/caffe && git apply ../../scripts/osx/mac_opencl_patch.txt
# 安装 numpy 和 opencv-python
sudo -H python3 -m pip install numpy
pip3 install opencv-python==4.2.0.34
# openpose cmake 配置
# mac
// 进入 openpose 的文件夹
cd {OpenPose_folder}
// 创建 build 文件夹
mkdir build/
// 进入 build 文件夹
cd build/
// 打开 cmake-gui
cmake-gui ..
在打开的 cmake-gui 窗口中设置进行对应的设置,前提是必须完成前置要求,不然会报错。
选择好2个路径,然后点击 Configure
完成后在队相关内容进行设置:
BUILD_CAFFE set to false
GPU_MODE set to CPU_ONLY (as recommended for MacOS)
Caffe_INCLUDE_DIRS set to /usr/local/include/caffe
Caffe_LIBS set to /usr/local/lib/libcaffe.dylib
再点击 Generate
。
# 编译
在 build 文件夹下进行编译。
make -j
sysctl -n hw.logicalcpu
# 分析
# 分析图片
GPU
请加上参数 --num_gpu_start 1
,不然会报错。
./MacBuilds/examples/openpose/openpose.bin --image_dir examples/media/ --num_gpu_start 1
# 分析视频
./MacBuilds/examples/openpose/openpose.bin --video examples/media/video.avi --num_gpu_start 1
# 错误处理
- 错误1
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find vecLib (missing: vecLib_INCLUDE_DIR)
Call Stack (most recent call first):
/Applications/CMake.app/Contents/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
cmake/Modules/FindvecLib.cmake:23 (find_package_handle_standard_args)
cmake/Dependencies.cmake:254 (find_package)
CMakeLists.txt:127 (include)
原因是找不到 vecLib,没有它的路径。
解决方法:打开build/caffe/src/openpose_lib-build/CMakeCache.txt文件,找到vecLib_INCLUDE_DIR:PATH=vecLib_INCLUDE_DIR-NOTFOUND一行,从本机搜索找到vecLib.h文件后将其路径覆盖掉vecLib_INCLUDE_DIR-NOTFOUND。
建议在下面的路径中搜索:
/Library/Developer/CommandLineTools/SDKs/
- 错误2
error: too many arguments to function call, expected single argument 'total_bytes_limit', have 2 arguments
coded_input->SetTotalBytesLimit(kProtoReadBytesLimit, 536870912);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~
错误原因:protobuf 的新旧版本对 SetTotalBytesLimits 的定义不同。SetTotalBytesLimits 的作用是设置文件字节大小的上限,新版本只有一个参数就是上限(int),老版本有两个参数,分别是上限(int)和警告阈值(int)。于是去翻出错位置./3rdparty/caffe/src/caffe/util/io.cpp的代码:删除 SetTotalBytesLimit 函数的第二个参数即可。
// coded_input->SetTotalBytesLimit(kProtoReadBytesLimit, 536870912);
coded_input->SetTotalBytesLimit(kProtoReadBytesLimit);
- 错误3
GPU
报错!
The default dynamic `--net_resolution` is not supported in MKL (MKL CPU Caffe) and OpenCL Caffe versions. Please, use a static `net_resolution` (recommended `--net_resolution 656x368`) or use the Caffe CUDA master branch when processing images and/or when using your custom image reader. OpenPose has automatically set the resolution to 656x368.
---------------------------------- WARNING ----------------------------------
We have introduced an additional boost in accuracy in the CUDA version of about 0.2% with respect to the CPU/OpenCL versions. We will not port this to CPU given the considerable slow down in speed it would add to it. Nevertheless, this accuracy boost is almost insignificant so the CPU/OpenCL versions can be safely used.
-------------------------------- END WARNING --------------------------------
Auto-detecting all available GPUs... Detected 2 GPU(s), using 2 of them starting at GPU 0.
ViennaCL: FATAL ERROR: Kernel start failed for 'conv_forward'.
Error:
ViennaCL: FATAL ERROR: CL_INVALID_WORK_ITEM_SIZE
The work item size is invalid. If you have set this value manually, please reconsider your choice.
If you think that this is a bug in ViennaCL, please report it at viennacl-support@lists.sourceforge.net and supply at least the following information:
* Operating System
* Which OpenCL implementation (AMD, NVIDIA, etc.)
* ViennaCL version
Many thanks in advance!