diff --git a/doc/installation_deprecated.md b/doc/installation_deprecated.md index 00b11a576f8a5b2708b59d3f001c039407a5829d..2d0a1b35a100e4b5b7d8d29fa7b113edea6d88ae 100644 --- a/doc/installation_deprecated.md +++ b/doc/installation_deprecated.md @@ -56,7 +56,7 @@ Build Caffe & the OpenPose library + download the required Caffe models for Ubun ```bash bash ./ubuntu/install_caffe_and_openpose_if_cuda8.sh ``` -**Highly important**: This script only works with CUDA 8 and Ubuntu 14 or 16. Otherwise, see [doc/installation_cmake.md](installation_cmake.md) or [Installation - Manual Compilation](#installation---manual-compilation). +**Highly important**: This script only works with CUDA 8 and Ubuntu 14 or 16. Otherwise, see [doc/installation.md](installation.md) or [Installation - Manual Compilation](#installation---manual-compilation). @@ -126,7 +126,7 @@ You just need to remove the OpenPose folder, by default called `openpose/`. E.g. 3. [**cuDNN 5.1**](https://developer.nvidia.com/cudnn): Once you have downloaded it, just unzip it and copy (merge) the contents on the CUDA folder, `C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0`. #### CMake Installer -Recommended installation method, it is simpler and offers more customization settings. See [doc/installation_cmake.md](installation_cmake.md). Note that it is a beta version, post in GitHub any issue you find. +Recommended installation method, it is simpler and offers more customization settings. See [doc/installation.md](installation.md). Note that it is a beta version, post in GitHub any issue you find. #### Deprecated Windows Installer diff --git a/doc/openpose_3d_reconstruction_demo.md b/doc/openpose_3d_reconstruction_demo.md index 1826fb99d8bd12e18176b06244b487e5ab2c060d..cef765613fa0eb4ce1a001d816ac2d7d66930ced 100644 --- a/doc/openpose_3d_reconstruction_demo.md +++ b/doc/openpose_3d_reconstruction_demo.md @@ -56,7 +56,7 @@ In order to verify that the camera parameters introduced by the user are sorted ## Installing the OpenPose 3-D Reconstruction Module -Check the [doc/installation_cmake.md#openpose-3d-reconstruction-module-and-demo](./installation_cmake.md#openpose-3d-reconstruction-module-and-demo) instructions. +Check the [doc/installation.md#openpose-3d-reconstruction-module-and-demo](./installation.md#openpose-3d-reconstruction-module-and-demo) instructions. diff --git a/doc/release_notes.md b/doc/release_notes.md index e97eabe14ed2ca25b4f208edd8de26fc9f886bad..0ab3c79de08d2f0f6c6bf73bdb7460b4bdfe48a5 100644 --- a/doc/release_notes.md +++ b/doc/release_notes.md @@ -182,6 +182,7 @@ OpenPose Library - Release Notes 10. 3-D Reconstruction demo cleaned, implemented in Ubuntu too, and now defined as experimental module of OpenPose rather than just a demo. 2. Main bugs fixed: 1. Slight speed up (~1%) for performing the non-maximum suppression stage only in the body part heatmaps channels, and not also in the PAF channels. + 2. Fixed core-dumped in PoseRenderer with GUI when changed element to be rendered to something else than skeleton. diff --git a/include/openpose/face/faceParameters.hpp b/include/openpose/face/faceParameters.hpp index 42eb1b62e0f71360d156eb3a3baea9573c447b3c..a5f1141d1e8538a8f7865dbb4b13cd42f4f626e9 100644 --- a/include/openpose/face/faceParameters.hpp +++ b/include/openpose/face/faceParameters.hpp @@ -2,6 +2,7 @@ #define OPENPOSE_FACE_FACE_PARAMETERS_HPP #include +#include namespace op { diff --git a/include/openpose/hand/handParameters.hpp b/include/openpose/hand/handParameters.hpp index 9cf6f206424b3b421d9140148686f88b23d7129c..a131be94df6f1df36f42e3acc4bdc31d33ccb3b4 100644 --- a/include/openpose/hand/handParameters.hpp +++ b/include/openpose/hand/handParameters.hpp @@ -2,6 +2,7 @@ #define OPENPOSE_HAND_HAND_PARAMETERS_HPP #include +#include namespace op { diff --git a/include/openpose/pose/poseCpuRenderer.hpp b/include/openpose/pose/poseCpuRenderer.hpp index 0e6695fcdb45aed78b8cb5dec09658088cf2a3f1..7d65fc0b74061476cd23390b7f7b36def7880808 100644 --- a/include/openpose/pose/poseCpuRenderer.hpp +++ b/include/openpose/pose/poseCpuRenderer.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace op @@ -15,7 +15,8 @@ namespace op public: PoseCpuRenderer(const PoseModel poseModel, const float renderThreshold, const bool blendOriginalFrame = true, const float alphaKeypoint = POSE_DEFAULT_ALPHA_KEYPOINT, - const float alphaHeatMap = POSE_DEFAULT_ALPHA_HEAT_MAP); + const float alphaHeatMap = POSE_DEFAULT_ALPHA_HEAT_MAP, + const unsigned int elementToRender = 0u); std::pair renderPose(Array& outputData, const Array& poseKeypoints, const float scaleInputToOutput, diff --git a/include/openpose/pose/poseParameters.hpp b/include/openpose/pose/poseParameters.hpp index 20245264737a9cb76a67814717b648e98429e06a..7eb89b53e49351a1046577ef52bfac8b6bb8922a 100644 --- a/include/openpose/pose/poseParameters.hpp +++ b/include/openpose/pose/poseParameters.hpp @@ -4,7 +4,6 @@ #include #include #include -#include namespace op { diff --git a/include/openpose/pose/poseParametersRender.hpp b/include/openpose/pose/poseParametersRender.hpp index a1f53479affeb9b6d7dea3f3d07b37f91008a70c..7bd85acfc9ffb881bc4b04c62594bc53577eeba5 100644 --- a/include/openpose/pose/poseParametersRender.hpp +++ b/include/openpose/pose/poseParametersRender.hpp @@ -200,6 +200,7 @@ namespace op OP_API const std::vector& getPoseScales(const PoseModel poseModel); OP_API const std::vector& getPoseColors(const PoseModel poseModel); OP_API const std::vector& getPoseBodyPartPairsRender(const PoseModel poseModel); + OP_API unsigned int getNumberElementsToRender(const PoseModel poseModel); } #endif // OPENPOSE_POSE_POSE_PARAMETERS_RENDER_HPP diff --git a/include/openpose/pose/renderPose.hpp b/include/openpose/pose/renderPose.hpp index 5891b53fda0362f4b3a1353b685184244e3f42ae..860dad64fda5bb5f589ca204bc724f83d91a7041 100644 --- a/include/openpose/pose/renderPose.hpp +++ b/include/openpose/pose/renderPose.hpp @@ -4,7 +4,7 @@ #include // cv::Mat #include #include -#include +#include namespace op { diff --git a/include/openpose/utilities/errorAndLog.hpp b/include/openpose/utilities/errorAndLog.hpp index 74df3860c268cb7e938183800fe47bbcd3d007f6..1fe63f006e6c74a6e85bc806f39c0af97ca82c46 100644 --- a/include/openpose/utilities/errorAndLog.hpp +++ b/include/openpose/utilities/errorAndLog.hpp @@ -23,28 +23,35 @@ namespace op // Error managment - How to use: // error(message, __LINE__, __FUNCTION__, __FILE__); - OP_API void error(const std::string& message, const int line = -1, const std::string& function = "", const std::string& file = ""); + OP_API void error(const std::string& message, const int line = -1, const std::string& function = "", + const std::string& file = ""); template - inline void error(const T& message, const int line = -1, const std::string& function = "", const std::string& file = "") + inline void error(const T& message, const int line = -1, const std::string& function = "", + const std::string& file = "") { error(tToString(message), line, function, file); } // Printing info - How to use: - // log(message, desiredPriority, __LINE__, __FUNCTION__, __FILE__); // It will print info if desiredPriority >= sPriorityThreshold - OP_API void log(const std::string& message, const Priority priority = Priority::Max, const int line = -1, const std::string& function = "", const std::string& file = ""); + // It will print info if desiredPriority >= sPriorityThreshold + // log(message, desiredPriority, __LINE__, __FUNCTION__, __FILE__); + OP_API void log(const std::string& message, const Priority priority = Priority::Max, const int line = -1, + const std::string& function = "", const std::string& file = ""); template - inline void log(const T& message, const Priority priority = Priority::Max, const int line = -1, const std::string& function = "", const std::string& file = "") + inline void log(const T& message, const Priority priority = Priority::Max, const int line = -1, + const std::string& function = "", const std::string& file = "") { log(tToString(message), priority, line, function, file); } // If only desired on debug mode (no computational cost at all on release mode): - // dLog(message, desiredPriority, __LINE__, __FUNCTION__, __FILE__); // It will print info if desiredPriority >= sPriorityThreshold + // It will print info if desiredPriority >= sPriorityThreshold + // dLog(message, desiredPriority, __LINE__, __FUNCTION__, __FILE__); template - inline void dLog(const T& message, const Priority priority = Priority::Max, const int line = -1, const std::string& function = "", const std::string& file = "") + inline void dLog(const T& message, const Priority priority = Priority::Max, const int line = -1, + const std::string& function = "", const std::string& file = "") { #ifndef NDEBUG log(message, priority, line, function, file); diff --git a/include/openpose/wrapper/wrapper.hpp b/include/openpose/wrapper/wrapper.hpp index 6171d99679c739300bd3998b7f6087b366405ecc..a15f0da22e767f06b63f9844dc228448232ec33c 100644 --- a/include/openpose/wrapper/wrapper.hpp +++ b/include/openpose/wrapper/wrapper.hpp @@ -665,9 +665,10 @@ namespace op // CPU rendering if (wrapperStructPose.renderMode == RenderMode::Cpu) { - poseCpuRenderer = std::make_shared(wrapperStructPose.poseModel, - wrapperStructPose.renderThreshold, - wrapperStructPose.blendOriginalFrame); + poseCpuRenderer = std::make_shared( + wrapperStructPose.poseModel, wrapperStructPose.renderThreshold, + wrapperStructPose.blendOriginalFrame, alphaKeypoint, alphaHeatMap, + wrapperStructPose.defaultPartToRender); cpuRenderers.emplace_back(std::make_shared>(poseCpuRenderer)); } } diff --git a/include/openpose/wrapper/wrapperStructPose.hpp b/include/openpose/wrapper/wrapperStructPose.hpp index dbe7c4b0b1496cd5235d88dbbaa676d94cba7b8c..cc3274c50ccf4b78c0d6b995e28b37e7c113e533 100644 --- a/include/openpose/wrapper/wrapperStructPose.hpp +++ b/include/openpose/wrapper/wrapperStructPose.hpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace op { diff --git a/src/openpose/core/renderer.cpp b/src/openpose/core/renderer.cpp index d2720f99f589653cfae99df989c21387cdd64b69..85e9bf008c875f19a20f0544e85b4221aa466c8f 100644 --- a/src/openpose/core/renderer.cpp +++ b/src/openpose/core/renderer.cpp @@ -19,6 +19,11 @@ namespace op { try { + // Security checks + if (*spNumberElementsToRender == 0) + error("Number elements to render cannot be 0 for this function.", + __LINE__, __FUNCTION__, __FILE__); + // Get current element to be rendered auto elementToRender = (((int)(*spElementToRender) + increment) % (int)(*spNumberElementsToRender)); // Handling negative increments while (elementToRender < 0) diff --git a/src/openpose/hand/handCpuRenderer.cpp b/src/openpose/hand/handCpuRenderer.cpp index d3ad5069ed93bdc47f970c73b917cff34d55153c..0f780c4d003534372e0198567e26652e5d5b3e9a 100644 --- a/src/openpose/hand/handCpuRenderer.cpp +++ b/src/openpose/hand/handCpuRenderer.cpp @@ -17,7 +17,8 @@ namespace op if (outputData.empty()) error("Empty Array outputData.", __LINE__, __FUNCTION__, __FILE__); if (handKeypoints[0].getSize(0) != handKeypoints[1].getSize(0)) - error("Wrong hand format: handKeypoints.getSize(0) != handKeypoints.getSize(1).", __LINE__, __FUNCTION__, __FILE__); + error("Wrong hand format: handKeypoints.getSize(0) != handKeypoints.getSize(1).", + __LINE__, __FUNCTION__, __FILE__); // CPU rendering renderHandKeypointsCpu(outputData, handKeypoints, mRenderThreshold); } diff --git a/src/openpose/pose/poseCpuRenderer.cpp b/src/openpose/pose/poseCpuRenderer.cpp index 18ad9e16c3a51b63352b81bf9ea7514430b81d1b..cde813e8039d6c23b0ce9814928a6d7e09d1947d 100644 --- a/src/openpose/pose/poseCpuRenderer.cpp +++ b/src/openpose/pose/poseCpuRenderer.cpp @@ -6,8 +6,9 @@ namespace op { PoseCpuRenderer::PoseCpuRenderer(const PoseModel poseModel, const float renderThreshold, const bool blendOriginalFrame, const float alphaKeypoint, - const float alphaHeatMap) : - Renderer{renderThreshold, alphaKeypoint, alphaHeatMap, blendOriginalFrame}, + const float alphaHeatMap, const unsigned int elementToRender) : + Renderer{renderThreshold, alphaKeypoint, alphaHeatMap, blendOriginalFrame, elementToRender, + getNumberElementsToRender(poseModel)}, // mNumberElementsToRender PoseRenderer{poseModel} { } diff --git a/src/openpose/pose/poseGpuRenderer.cpp b/src/openpose/pose/poseGpuRenderer.cpp index ca6d2f1b679bb0b42f40531bf25dc611b7077835..dfce1daf2dda3dac3d57c92f887ca42ad5ecd09b 100644 --- a/src/openpose/pose/poseGpuRenderer.cpp +++ b/src/openpose/pose/poseGpuRenderer.cpp @@ -18,8 +18,7 @@ namespace op // + 3 (+whole pose +whole heatmaps +PAFs) // POSE_BODY_PART_MAPPING crashes on Windows, replaced by getPoseBodyPartMapping GpuRenderer{renderThreshold, alphaKeypoint, alphaHeatMap, blendOriginalFrame, elementToRender, - (unsigned int)(getPoseBodyPartMapping(poseModel).size() - + getPosePartPairs(poseModel).size()/2 + 3)}, // mNumberElementsToRender + getNumberElementsToRender(poseModel)}, // mNumberElementsToRender PoseRenderer{poseModel}, spPoseExtractor{poseExtractor}, pGpuPose{nullptr} diff --git a/src/openpose/pose/poseParameters.cpp b/src/openpose/pose/poseParameters.cpp index ac85228afe6e9b182de36ea488b3446fe03a9dff..b19a53c0ed6b34e1c04239579336a3b549b27322 100644 --- a/src/openpose/pose/poseParameters.cpp +++ b/src/openpose/pose/poseParameters.cpp @@ -1,3 +1,4 @@ +#include #include namespace op diff --git a/src/openpose/pose/poseParametersRender.cpp b/src/openpose/pose/poseParametersRender.cpp index edf1536cac86c44b028b50317e8b7c40bbd99989..b8d660ddaaa002b9e8ce45480d2313b50aba2b4b 100644 --- a/src/openpose/pose/poseParametersRender.cpp +++ b/src/openpose/pose/poseParametersRender.cpp @@ -1,3 +1,4 @@ +#include #include namespace op @@ -69,4 +70,18 @@ namespace op return POSE_BODY_PART_PAIRS_RENDER[(int)poseModel]; } } + + unsigned int getNumberElementsToRender(const PoseModel poseModel) + { + try + { + return (unsigned int)(getPoseBodyPartMapping(poseModel).size() + + getPosePartPairs(poseModel).size()/2 + 3); + } + catch (const std::exception& e) + { + error(e.what(), __LINE__, __FUNCTION__, __FILE__); + return 0u; + } + } } diff --git a/src/openpose/utilities/errorAndLog.cpp b/src/openpose/utilities/errorAndLog.cpp index 8cff22479dc86f014555db3f10ca7055410be8d0..3ee677caf596df32f0d9212a6d12ccefc7903030 100644 --- a/src/openpose/utilities/errorAndLog.cpp +++ b/src/openpose/utilities/errorAndLog.cpp @@ -23,8 +23,8 @@ namespace op return false; } - std::string createFullMessage(const std::string& message, const int line = -1, const std::string& function = "", const std::string& file = "") - // std::string createFullMessage(const std::string& message, const int line, const std::string& function, const std::string& file) + std::string createFullMessage(const std::string& message, const int line = -1, const std::string& function = "", + const std::string& file = "") { const auto hasMessage = (!message.empty()); const auto hasLocation = (line != -1 || !function.empty() || !file.empty()); @@ -34,10 +34,14 @@ namespace op if (hasMessage) { fullMessage += message; - // // Add dot at the end if the sentence does not finish in a programming file path (this happens when the error is propagated over several error) + // // Add dot at the end if the sentence does not finish in a programming file path (this happens when the + // error is propagated over several error) // if (*message.crbegin() != '.' // && (message.size() < 4 - // || (message.substr(message.size() - 4, 4) != ".cpp" && message.substr(message.size() - 4, 4) != ".hpp" && message.substr(message.size() - 4, 4) != ".h" && message.substr(message.size() - 4, 4) != ".c"))) + // || (message.substr(message.size() - 4, 4) != ".cpp" + // && message.substr(message.size() - 4, 4) != ".hpp" + // && message.substr(message.size() - 4, 4) != ".h" + // && message.substr(message.size() - 4, 4) != ".c"))) // fullMessage += "."; if (hasLocation) @@ -74,8 +78,9 @@ namespace op // Common timeStruct.tm_mon++; timeStruct.tm_year += 1900; - return std::to_string(timeStruct.tm_year) + '_' + std::to_string(timeStruct.tm_mon) + '_' + std::to_string(timeStruct.tm_mday) + "___" - + std::to_string(timeStruct.tm_hour) + '_' + std::to_string(timeStruct.tm_min) + '_' + std::to_string(timeStruct.tm_sec); + return std::to_string(timeStruct.tm_year) + '_' + std::to_string(timeStruct.tm_mon) + + '_' + std::to_string(timeStruct.tm_mday) + "___" + std::to_string(timeStruct.tm_hour) + + '_' + std::to_string(timeStruct.tm_min) + '_' + std::to_string(timeStruct.tm_sec); } void fileLogging(const std::string& message) @@ -89,7 +94,8 @@ namespace op // Continue at the end of the file or delete it and re-write it (according to current file size) const auto maxLogSize = 15 * 1024 * 1024; // 15 MB - std::ofstream loggingFile{fileToOpen, (currentSizeBytes < maxLogSize ? std::ios_base::app : std::ios_base::trunc)}; + std::ofstream loggingFile{fileToOpen, + (currentSizeBytes < maxLogSize ? std::ios_base::app : std::ios_base::trunc)}; // Message to write loggingFile << getTime(); @@ -116,14 +122,16 @@ namespace op // If first error if (message.size() < errorInit.size() || message.substr(0, errorInit.size()) != errorInit) { - errorMessageToPrint = errorInit + createFullMessage(message) + "\n\nComing from:\n" + errorEnum + createFullMessage("", line, function, file); + errorMessageToPrint = errorInit + createFullMessage(message) + "\n\nComing from:\n" + errorEnum + + createFullMessage("", line, function, file); errorMessageToPropagate = errorMessageToPrint + "\n"; } // If error propagated among different errors else { errorMessageToPrint = errorEnum + createFullMessage("", line, function, file); - errorMessageToPropagate = createFullMessage(message.substr(0, message.size()-1)) + "\n" + errorMessageToPrint + "\n"; + errorMessageToPropagate = createFullMessage(message.substr(0, message.size()-1)) + "\n" + + errorMessageToPrint + "\n"; } // std::cerr @@ -139,7 +147,8 @@ namespace op throw std::runtime_error{errorMessageToPropagate}; } - void log(const std::string& message, const Priority priority, const int line, const std::string& function, const std::string& file) + void log(const std::string& message, const Priority priority, const int line, const std::string& function, + const std::string& file) { if (priority >= ConfigureLog::getPriorityThreshold()) {