提交 e8ec52e9 编写于 作者: G gineshidalgo99

Fixed CPU pose renderer/GUI core dumped

上级 30ff0252
...@@ -56,7 +56,7 @@ Build Caffe & the OpenPose library + download the required Caffe models for Ubun ...@@ -56,7 +56,7 @@ Build Caffe & the OpenPose library + download the required Caffe models for Ubun
```bash ```bash
bash ./ubuntu/install_caffe_and_openpose_if_cuda8.sh 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. ...@@ -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`. 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 #### 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 #### Deprecated Windows Installer
......
...@@ -56,7 +56,7 @@ In order to verify that the camera parameters introduced by the user are sorted ...@@ -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 ## 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.
......
...@@ -182,6 +182,7 @@ OpenPose Library - Release Notes ...@@ -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. 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: 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. 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.
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define OPENPOSE_FACE_FACE_PARAMETERS_HPP #define OPENPOSE_FACE_FACE_PARAMETERS_HPP
#include <openpose/pose/poseParameters.hpp> #include <openpose/pose/poseParameters.hpp>
#include <openpose/pose/poseParametersRender.hpp>
namespace op namespace op
{ {
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define OPENPOSE_HAND_HAND_PARAMETERS_HPP #define OPENPOSE_HAND_HAND_PARAMETERS_HPP
#include <openpose/pose/poseParameters.hpp> #include <openpose/pose/poseParameters.hpp>
#include <openpose/pose/poseParametersRender.hpp>
namespace op namespace op
{ {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <openpose/core/renderer.hpp> #include <openpose/core/renderer.hpp>
#include <openpose/pose/enumClasses.hpp> #include <openpose/pose/enumClasses.hpp>
#include <openpose/pose/poseExtractor.hpp> #include <openpose/pose/poseExtractor.hpp>
#include <openpose/pose/poseParameters.hpp> #include <openpose/pose/poseParametersRender.hpp>
#include <openpose/pose/poseRenderer.hpp> #include <openpose/pose/poseRenderer.hpp>
namespace op namespace op
...@@ -15,7 +15,8 @@ namespace op ...@@ -15,7 +15,8 @@ namespace op
public: public:
PoseCpuRenderer(const PoseModel poseModel, const float renderThreshold, const bool blendOriginalFrame = true, PoseCpuRenderer(const PoseModel poseModel, const float renderThreshold, const bool blendOriginalFrame = true,
const float alphaKeypoint = POSE_DEFAULT_ALPHA_KEYPOINT, 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<int, std::string> renderPose(Array<float>& outputData, const Array<float>& poseKeypoints, std::pair<int, std::string> renderPose(Array<float>& outputData, const Array<float>& poseKeypoints,
const float scaleInputToOutput, const float scaleInputToOutput,
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include <map> #include <map>
#include <openpose/core/common.hpp> #include <openpose/core/common.hpp>
#include <openpose/pose/enumClasses.hpp> #include <openpose/pose/enumClasses.hpp>
#include <openpose/pose/poseParametersRender.hpp>
namespace op namespace op
{ {
......
...@@ -200,6 +200,7 @@ namespace op ...@@ -200,6 +200,7 @@ namespace op
OP_API const std::vector<float>& getPoseScales(const PoseModel poseModel); OP_API const std::vector<float>& getPoseScales(const PoseModel poseModel);
OP_API const std::vector<float>& getPoseColors(const PoseModel poseModel); OP_API const std::vector<float>& getPoseColors(const PoseModel poseModel);
OP_API const std::vector<unsigned int>& getPoseBodyPartPairsRender(const PoseModel poseModel); OP_API const std::vector<unsigned int>& getPoseBodyPartPairsRender(const PoseModel poseModel);
OP_API unsigned int getNumberElementsToRender(const PoseModel poseModel);
} }
#endif // OPENPOSE_POSE_POSE_PARAMETERS_RENDER_HPP #endif // OPENPOSE_POSE_POSE_PARAMETERS_RENDER_HPP
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <opencv2/core/core.hpp> // cv::Mat #include <opencv2/core/core.hpp> // cv::Mat
#include <openpose/core/common.hpp> #include <openpose/core/common.hpp>
#include <openpose/pose/enumClasses.hpp> #include <openpose/pose/enumClasses.hpp>
#include <openpose/pose/poseParameters.hpp> #include <openpose/pose/poseParametersRender.hpp>
namespace op namespace op
{ {
......
...@@ -23,28 +23,35 @@ namespace op ...@@ -23,28 +23,35 @@ namespace op
// Error managment - How to use: // Error managment - How to use:
// error(message, __LINE__, __FUNCTION__, __FILE__); // 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<typename T> template<typename T>
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); error(tToString(message), line, function, file);
} }
// Printing info - How to use: // Printing info - How to use:
// log(message, desiredPriority, __LINE__, __FUNCTION__, __FILE__); // It will print info if desiredPriority >= sPriorityThreshold // 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 = ""); // 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<typename T> template<typename T>
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); log(tToString(message), priority, line, function, file);
} }
// If only desired on debug mode (no computational cost at all on release mode): // 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<typename T> template<typename T>
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 #ifndef NDEBUG
log(message, priority, line, function, file); log(message, priority, line, function, file);
......
...@@ -665,9 +665,10 @@ namespace op ...@@ -665,9 +665,10 @@ namespace op
// CPU rendering // CPU rendering
if (wrapperStructPose.renderMode == RenderMode::Cpu) if (wrapperStructPose.renderMode == RenderMode::Cpu)
{ {
poseCpuRenderer = std::make_shared<PoseCpuRenderer>(wrapperStructPose.poseModel, poseCpuRenderer = std::make_shared<PoseCpuRenderer>(
wrapperStructPose.renderThreshold, wrapperStructPose.poseModel, wrapperStructPose.renderThreshold,
wrapperStructPose.blendOriginalFrame); wrapperStructPose.blendOriginalFrame, alphaKeypoint, alphaHeatMap,
wrapperStructPose.defaultPartToRender);
cpuRenderers.emplace_back(std::make_shared<WPoseRenderer<TDatumsPtr>>(poseCpuRenderer)); cpuRenderers.emplace_back(std::make_shared<WPoseRenderer<TDatumsPtr>>(poseCpuRenderer));
} }
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <openpose/core/enumClasses.hpp> #include <openpose/core/enumClasses.hpp>
#include <openpose/pose/enumClasses.hpp> #include <openpose/pose/enumClasses.hpp>
#include <openpose/pose/poseParameters.hpp> #include <openpose/pose/poseParameters.hpp>
#include <openpose/pose/poseParametersRender.hpp>
namespace op namespace op
{ {
......
...@@ -19,6 +19,11 @@ namespace op ...@@ -19,6 +19,11 @@ namespace op
{ {
try 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)); auto elementToRender = (((int)(*spElementToRender) + increment) % (int)(*spNumberElementsToRender));
// Handling negative increments // Handling negative increments
while (elementToRender < 0) while (elementToRender < 0)
......
...@@ -17,7 +17,8 @@ namespace op ...@@ -17,7 +17,8 @@ namespace op
if (outputData.empty()) if (outputData.empty())
error("Empty Array<float> outputData.", __LINE__, __FUNCTION__, __FILE__); error("Empty Array<float> outputData.", __LINE__, __FUNCTION__, __FILE__);
if (handKeypoints[0].getSize(0) != handKeypoints[1].getSize(0)) 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 // CPU rendering
renderHandKeypointsCpu(outputData, handKeypoints, mRenderThreshold); renderHandKeypointsCpu(outputData, handKeypoints, mRenderThreshold);
} }
......
...@@ -6,8 +6,9 @@ namespace op ...@@ -6,8 +6,9 @@ namespace op
{ {
PoseCpuRenderer::PoseCpuRenderer(const PoseModel poseModel, const float renderThreshold, PoseCpuRenderer::PoseCpuRenderer(const PoseModel poseModel, const float renderThreshold,
const bool blendOriginalFrame, const float alphaKeypoint, const bool blendOriginalFrame, const float alphaKeypoint,
const float alphaHeatMap) : const float alphaHeatMap, const unsigned int elementToRender) :
Renderer{renderThreshold, alphaKeypoint, alphaHeatMap, blendOriginalFrame}, Renderer{renderThreshold, alphaKeypoint, alphaHeatMap, blendOriginalFrame, elementToRender,
getNumberElementsToRender(poseModel)}, // mNumberElementsToRender
PoseRenderer{poseModel} PoseRenderer{poseModel}
{ {
} }
......
...@@ -18,8 +18,7 @@ namespace op ...@@ -18,8 +18,7 @@ namespace op
// + 3 (+whole pose +whole heatmaps +PAFs) // + 3 (+whole pose +whole heatmaps +PAFs)
// POSE_BODY_PART_MAPPING crashes on Windows, replaced by getPoseBodyPartMapping // POSE_BODY_PART_MAPPING crashes on Windows, replaced by getPoseBodyPartMapping
GpuRenderer{renderThreshold, alphaKeypoint, alphaHeatMap, blendOriginalFrame, elementToRender, GpuRenderer{renderThreshold, alphaKeypoint, alphaHeatMap, blendOriginalFrame, elementToRender,
(unsigned int)(getPoseBodyPartMapping(poseModel).size() getNumberElementsToRender(poseModel)}, // mNumberElementsToRender
+ getPosePartPairs(poseModel).size()/2 + 3)}, // mNumberElementsToRender
PoseRenderer{poseModel}, PoseRenderer{poseModel},
spPoseExtractor{poseExtractor}, spPoseExtractor{poseExtractor},
pGpuPose{nullptr} pGpuPose{nullptr}
......
#include <openpose/pose/poseParametersRender.hpp>
#include <openpose/pose/poseParameters.hpp> #include <openpose/pose/poseParameters.hpp>
namespace op namespace op
......
#include <openpose/pose/poseParameters.hpp>
#include <openpose/pose/poseParametersRender.hpp> #include <openpose/pose/poseParametersRender.hpp>
namespace op namespace op
...@@ -69,4 +70,18 @@ namespace op ...@@ -69,4 +70,18 @@ namespace op
return POSE_BODY_PART_PAIRS_RENDER[(int)poseModel]; 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;
}
}
} }
...@@ -23,8 +23,8 @@ namespace op ...@@ -23,8 +23,8 @@ namespace op
return false; 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 = -1, const std::string& function = "",
// std::string createFullMessage(const std::string& message, const int line, const std::string& function, const std::string& file) const std::string& file = "")
{ {
const auto hasMessage = (!message.empty()); const auto hasMessage = (!message.empty());
const auto hasLocation = (line != -1 || !function.empty() || !file.empty()); const auto hasLocation = (line != -1 || !function.empty() || !file.empty());
...@@ -34,10 +34,14 @@ namespace op ...@@ -34,10 +34,14 @@ namespace op
if (hasMessage) if (hasMessage)
{ {
fullMessage += message; 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() != '.' // if (*message.crbegin() != '.'
// && (message.size() < 4 // && (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 += "."; // fullMessage += ".";
if (hasLocation) if (hasLocation)
...@@ -74,8 +78,9 @@ namespace op ...@@ -74,8 +78,9 @@ namespace op
// Common // Common
timeStruct.tm_mon++; timeStruct.tm_mon++;
timeStruct.tm_year += 1900; timeStruct.tm_year += 1900;
return std::to_string(timeStruct.tm_year) + '_' + std::to_string(timeStruct.tm_mon) + '_' + std::to_string(timeStruct.tm_mday) + "___" return std::to_string(timeStruct.tm_year) + '_' + std::to_string(timeStruct.tm_mon)
+ std::to_string(timeStruct.tm_hour) + '_' + std::to_string(timeStruct.tm_min) + '_' + std::to_string(timeStruct.tm_sec); + '_' + 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) void fileLogging(const std::string& message)
...@@ -89,7 +94,8 @@ namespace op ...@@ -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) // 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 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 // Message to write
loggingFile << getTime(); loggingFile << getTime();
...@@ -116,14 +122,16 @@ namespace op ...@@ -116,14 +122,16 @@ namespace op
// If first error // If first error
if (message.size() < errorInit.size() || message.substr(0, errorInit.size()) != errorInit) 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"; errorMessageToPropagate = errorMessageToPrint + "\n";
} }
// If error propagated among different errors // If error propagated among different errors
else else
{ {
errorMessageToPrint = errorEnum + createFullMessage("", line, function, file); 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 // std::cerr
...@@ -139,7 +147,8 @@ namespace op ...@@ -139,7 +147,8 @@ namespace op
throw std::runtime_error{errorMessageToPropagate}; 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()) if (priority >= ConfigureLog::getPriorityThreshold())
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册