提交 88f3ade3 编写于 作者: G gineshidalgo99

Tutorial wrapper: added how to read keypoint data

上级 4f81fe5b
......@@ -104,4 +104,6 @@ OpenPose Library - Release Notes
## Current version (future OpenPose 1.0.3)
1. Main improvements:
1. Added how to use keypoint data in `examples/tutorial_wrapper/`.
2. Main bugs fixed:
1. Windows version crashing with std::map copy.
# Script for internal use. We might completely change it continuously and we will not answer questions about it.
# USAGE EXAMPLE
# clear && clear && make all -j24 && bash ./examples/tests/speed_test.sh
# # Go back to main folder
# cd ../../
# Get model speed
~/devel/openpose_caffe_train/build/tools/caffe time -gpu 0 -model /mnt/DataUbuntu/openpose_train/training_results_light/pose/pose_training.prototxt
# ./3rdparty/caffe/build/tools/caffe time -gpu 0 -model /mnt/DataUbuntu/openpose_train/training_results_light/pose/pose_training.prototxt
......@@ -242,6 +242,37 @@ public:
else
op::log("Nullptr or empty datumsPtr found.", op::Priority::High, __LINE__, __FUNCTION__, __FILE__);
}
void printKeypoitns(const std::shared_ptr<std::vector<UserDatum>>& datumsPtr)
{
// Example: How to use the pose keypoints
if (datumsPtr != nullptr && !datumsPtr->empty())
{
op::log("\nKeypoints:");
// Accesing each element of the keypoints
const auto& poseKeypoints = datumsPtr->at(0).poseKeypoints;
op::log("Person pose keypoints:");
for (auto person = 0 ; person < poseKeypoints.getSize(0) ; person++)
{
op::log("Person " + std::to_string(person) + " (x, y, score):");
for (auto bodyPart = 0 ; bodyPart < poseKeypoints.getSize(1) ; bodyPart++)
{
std::string valueToPrint;
for (auto xyscore = 0 ; xyscore < poseKeypoints.getSize(2) ; xyscore++)
{
valueToPrint += std::to_string( poseKeypoints[{person, bodyPart, xyscore}] ) + " ";
}
op::log(valueToPrint);
}
}
op::log(" ");
// Alternative: just getting std::string equivalent
op::log("Face keypoints: " + datumsPtr->at(0).faceKeypoints.toString());
op::log("Left hand keypoints: " + datumsPtr->at(0).handKeypoints[0].toString());
op::log("Right hand keypoints: " + datumsPtr->at(0).handKeypoints[1].toString());
}
else
op::log("Nullptr or empty datumsPtr found.", op::Priority::High, __LINE__, __FUNCTION__, __FILE__);
}
};
int openPoseTutorialWrapper1()
......@@ -319,7 +350,10 @@ int openPoseTutorialWrapper1()
// Pop frame
std::shared_ptr<std::vector<UserDatum>> datumProcessed;
if (successfullyEmplaced && opWrapper.waitAndPop(datumProcessed))
{
userOutputClass.display(datumProcessed);
userOutputClass.printKeypoitns(datumProcessed);
}
else
op::log("Processed datum could not be emplaced.", op::Priority::High, __LINE__, __FUNCTION__, __FILE__);
}
......
......@@ -276,6 +276,31 @@ public:
// datum.poseKeypoints: Array<float> with the estimated pose
if (datumsPtr != nullptr && !datumsPtr->empty())
{
// Show in command line the resulting pose keypoints for body, face and hands
op::log("\nKeypoints:");
// Accesing each element of the keypoints
const auto& poseKeypoints = datumsPtr->at(0).poseKeypoints;
op::log("Person pose keypoints:");
for (auto person = 0 ; person < poseKeypoints.getSize(0) ; person++)
{
op::log("Person " + std::to_string(person) + " (x, y, score):");
for (auto bodyPart = 0 ; bodyPart < poseKeypoints.getSize(1) ; bodyPart++)
{
std::string valueToPrint;
for (auto xyscore = 0 ; xyscore < poseKeypoints.getSize(2) ; xyscore++)
{
valueToPrint += std::to_string( poseKeypoints[{person, bodyPart, xyscore}] ) + " ";
}
op::log(valueToPrint);
}
}
op::log(" ");
// Alternative: just getting std::string equivalent
op::log("Face keypoints: " + datumsPtr->at(0).faceKeypoints.toString());
op::log("Left hand keypoints: " + datumsPtr->at(0).handKeypoints[0].toString());
op::log("Right hand keypoints: " + datumsPtr->at(0).handKeypoints[1].toString());
// Display rendered output image
cv::imshow("User worker GUI", datumsPtr->at(0).cvOutputData);
cv::waitKey(1); // It displays the image and sleeps at least 1 ms (it usually sleeps ~5-10 msec to display the image)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册