1. 程式人生 > >openpose編譯和簡單測試

openpose編譯和簡單測試

我是在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可以檢視命令的用法