编译构建的openpose姿态预测格式
目录
输出格式
OpenPose 有两种可选的输出保存方式:
- 采用 write_json flag 将人体姿态数据结果保存为 JSON writer 格式.
# Only body
./build/examples/openpose/openpose.bin
--video examples/media/video.avi
--write_json output/
--display 0
--render_pose 0
# Body + face + hands
./build/examples/openpose/openpose.bin
--video examples/media/video.avi
--write_video output/result.avi
--write_json output/
--display 0
--render_pose 0
--face
--hand
# Only body
./build/examples/openpose/openpose.bin
--video examples/media/video.avi
--write_json output/
--display 0
--render_pose 0
# Body + face + hands
./build/examples/openpose/openpose.bin
--video examples/media/video.avi
--write_video output/result.avi
--write_json output/
--display 0
--render_pose 0
--face
--hand
C++ API 中 Keypoints 格式
在 Datum 类中有 3 种不同的关键点 Array 元素:
- 数组 poseKeypoints - 为了访问 Person person 和 Body Part part(其中,index 对应于 POSE_COCO_BODY_PARTS 或 POSE_MPI_BODY_PARTS),简单输出如下:
// Common patrameters needed
const auto numberPeopleDetected = poseKeypoints.getSize(0);
const auto numberBodyParts = poseKeypoints.getSize(1);
// Easy version
const auto x = poseKeypoints[{person, part, 0}];
const auto y = poseKeypoints[{person, part, 1}];
const auto score = poseKeypoints[{person, part, 2}];
// Slightly more efficient version
// If you want to access these elements on a huge loop, you can get the index
// by your own, but it is usually not faster enough to be worthy
const auto baseIndex = poseKeypoints.getSize(2)*(person*numberBodyParts + part);
const auto x = poseKeypoints[baseIndex];
const auto y = poseKeypoints[baseIndex + 1];
const auto score = poseKeypoints[baseIndex + 2];
- 数组 faceKeypoints - 完全类似于 poseKeypoints.
// Common parameters needed
const auto numberPeopleDetected = faceKeypoints.getSize(0);
const auto numberFaceParts = faceKeypoints.getSize(1);
// Easy version
const auto x = faceKeypoints[{person, part, 0}];
const auto y = faceKeypoints[{person, part, 1}];
const auto score = faceKeypoints[{person, part, 2}];
// Slightly more efficient version
const auto baseIndex = faceKeypoints.getSize(2)*(person*numberFaceParts + part);
const auto x = faceKeypoints[baseIndex];
const auto y = faceKeypoints[baseIndex + 1];
const auto score = faceKeypoints[baseIndex + 2];
- std::array<Array, 2> handKeypoints, 其中,handKeypoints[0] 对应于 left hand,handKeypoints[1] 对应于 right hand. 每个 handKeypoints[i] 类似于 poseKeypoints 和 faceKeypoints:
// Common parameters needed
const auto numberPeopleDetected = handKeypoints[0].getSize(0); // = handKeypoints[1].getSize(0)
const auto numberHandParts = handKeypoints[0].getSize(1); // = handKeypoints[1].getSize(1)
// Easy version
// Left Hand
const auto xL = handKeypoints[0][{person, part, 0}];
const auto yL = handKeypoints[0][{person, part, 1}];
const auto scoreL = handKeypoints[0][{person, part, 2}];
// Right Hand
const auto xR = handKeypoints[1][{person, part, 0}];
const auto yR = handKeypoints[1][{person, part, 1}];
const auto scoreR = handKeypoints[1][{person, part, 2}];
// Slightly more efficient version
const auto baseIndex = handKeypoints[0].getSize(2)*(person*numberHandParts + part);
// Left Hand
const auto xL = handKeypoints[0][baseIndex];
const auto yL = handKeypoints[0][baseIndex + 1];
const auto scoreL = handKeypoints[0][baseIndex + 2];
// Right Hand
const auto xR = handKeypoints[1][baseIndex];
const auto yR = handKeypoints[1][baseIndex + 1];
const auto scoreR = handKeypoints[1][baseIndex + 2];
来自:https://www.aiuai.cn/aifarm712.htm