项目地址:https://github.com/CMU-Perceptual-Computing-Lab/openpose
安装参考官方文档:https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/installation.md
我是在docker内安装的,没有界面,只能安装cmake,无法使用cmake-gui
准备
需要预先安装opencv
然后安装caffe
增加链接库的位置,改名字:
把/usr/lib/x86_64-linux-gnu/gconv/和/usr/lib/x86_64-linux-gnu/audit加到/etc/ld.so.conf.d/x86_64-linux-gnu.conf末尾,运行ldconfig命令
这时发现还是出现一大堆错误,错误信息:
Linking CXX shared library libopenpose.so
/usr/bin/ld: cannot find -lsotruss-lib
/usr/bin/ld: cannot find -lISO_5428
/usr/bin/ld: cannot find -lGREEK7
/usr/bin/ld: cannot find -lTIS-620
/usr/bin/ld: cannot find -lANSI_X3.110
/usr/bin/ld: cannot find -lIBM918
/usr/bin/ld: cannot find -lISO8859-9E
/usr/bin/ld: cannot find -lKOI8-RU
/usr/bin/ld: cannot find -lIBM420
/usr/bin/ld: cannot find -lISO-2022-CN
/usr/bin/ld: cannot find -lIBM869
原因:虽然库的目录被加入搜索路径了,但是/usr/lib/x86_64-linux-gnu/gconv/和/usr/lib/x86_64-linux-gnu/audit下的文件名字都是不带lib开头的,所以需要给每个文件一个带lib的链接
使用以下python脚本分别在这两个目录下执行一遍:
import os
file_list = os.listdir('./')
for file in file_list:
new_name = 'lib'+file
#print('new_name:'+new_name)
if (new_name not in file_list) and ('lib' not in file):
os.system('ln -s ' + file + ' ' + new_name)
print('ln -s '+ file + ' ' + new_name)
上述python脚本执行完毕,再次执行ldconfig命令,更新系统搜索动态库的缓存。
在openpose源码目录下创建目录:
cd openpose
mkdir build
cd build
运行openpose的cmake:
cmake -DOpenCV_INCLUDE_DIRS=/usr/include/opencv \
-DOpenCV_LIBS_DIR=/usr/lib/x86_64-linux-gnu/ \
-DCaffe_INCLUDE_DIRS=/caffe/build/install/include/ \
-DCaffe_LIBS=/caffe/build/lib/libcaffe.so -DBUILD_CAFFE=OFF ..
在build下运行make命令。
成功了。
简单测试:
在docker内部测试,没有x window。所以禁用了显示。输出内容保存到磁盘上的视频文件。
./build/examples/openpose/openpose.bin --video examples/media/video.avi --face --hand --display 0 --write_video examples/media/video_out.avi --num_gpu 0
发现输出的视频和源视频一样,没有任何动作的叠加输出。
经过测试,指定显卡就会有叠加输出
./build/examples/openpose/openpose.bin --video examples/asia_office.mp4 --face --hand --display 0 --write_video examples/asia_office_out.avi --num_gpu 1 --num_gpu_start 1
速度
指定使用显卡1,对于11秒720P的视频用了292秒。速度不快啊。我的显卡是tesla K80。
去掉hand和face,再测,结果用了100秒。大约3.3帧/秒
其它:./build/examples/openpose/openpose.bin –help可以查看命令的用法