diff --git a/doc/release_notes.md b/doc/release_notes.md index fbf2a70d7a90cecafcbf55d2daee75b1931d40eb..3fd580175597dcb6179912e08634108de7eb0223 100644 --- a/doc/release_notes.md +++ b/doc/release_notes.md @@ -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. diff --git a/examples/tests/speed_test.sh b/examples/tests/speed_test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bb09195d7a382507130c539242a38bfb9ab1a25f --- /dev/null +++ b/examples/tests/speed_test.sh @@ -0,0 +1,11 @@ +# 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 diff --git a/examples/tutorial_wrapper/1_user_asynchronous.cpp b/examples/tutorial_wrapper/1_user_asynchronous.cpp index f57c422f8119661aa509c5755c4811c51396611b..4552d9e21ee12dc98b9a478857f88748b8d66e86 100644 --- a/examples/tutorial_wrapper/1_user_asynchronous.cpp +++ b/examples/tutorial_wrapper/1_user_asynchronous.cpp @@ -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>& 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> 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__); } diff --git a/examples/tutorial_wrapper/2_user_synchronous.cpp b/examples/tutorial_wrapper/2_user_synchronous.cpp index 1e4486d3e11bffa811f216153ca1f73f51f05fbe..939588dcb1c53b03b79deae359e930f4863d6c5b 100644 --- a/examples/tutorial_wrapper/2_user_synchronous.cpp +++ b/examples/tutorial_wrapper/2_user_synchronous.cpp @@ -276,6 +276,31 @@ public: // datum.poseKeypoints: Array 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) }