From 26ad9f73482b732c424efce14838d3c2c138c316 Mon Sep 17 00:00:00 2001 From: gineshidalgo99 Date: Wed, 12 Jul 2017 12:55:02 -0400 Subject: [PATCH] Fixed crash when no saving & empty keypoints --- README.md | 10 +++++----- src/openpose/filestream/fileStream.cpp | 6 ++++-- src/openpose/gui/gui.cpp | 6 ++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d3728f93..42eee278 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ OpenPose ==================================== ## Latest News -- Apr 2017: Body released! -- May 2017: Windows version released! -- Jun 2017: Face released! -- Jul 2017: Hands released! -- Jul 2017: Windows: New non-installation-required [portable demo](doc/installation.md#installation---demo) and [easier library installation](doc/installation.md#installation---library)! +- Apr 2017: **Body** released! +- May 2017: **Windows** version released! +- Jun 2017: **Face** released! +- Jul 2017: **Hands** released! +- Jul 2017: **Windows**, New [**portable demo**](doc/installation.md#installation---demo) **and** [**easier library installation**](doc/installation.md#installation---library)! - Check all the [release notes](doc/release_notes.md). - Interested in an internship on CMU as OpenPose programmer? See [this link](https://docs.google.com/document/d/14SygG39NjIRZfx08clewTdFMGwVdtRu2acyCi3TYcHs/edit?usp=sharing) for details. diff --git a/src/openpose/filestream/fileStream.cpp b/src/openpose/filestream/fileStream.cpp index ac08a8f3..0d3a0849 100644 --- a/src/openpose/filestream/fileStream.cpp +++ b/src/openpose/filestream/fileStream.cpp @@ -76,14 +76,16 @@ namespace op { try { + // Security checks if (format == DataFormat::Json && CV_MAJOR_VERSION < 3) error(errorMessage, __LINE__, __FUNCTION__, __FILE__); if (cvMats.size() != cvMatNames.size()) error("cvMats.size() != cvMatNames.size()", __LINE__, __FUNCTION__, __FILE__); - + // Save cv::Mat data cv::FileStorage fileStorage{getFullName(fileNameNoExtension, format), cv::FileStorage::WRITE}; for (auto i = 0 ; i < cvMats.size() ; i++) - fileStorage << cvMatNames[i] << cvMats[i]; + fileStorage << cvMatNames[i] << (cvMats[i].empty() ? cv::Mat{} : cvMats[i]); + // Release file fileStorage.release(); } catch (const std::exception& e) diff --git a/src/openpose/gui/gui.cpp b/src/openpose/gui/gui.cpp index e236b440..d7a1adc7 100644 --- a/src/openpose/gui/gui.cpp +++ b/src/openpose/gui/gui.cpp @@ -8,6 +8,8 @@ namespace op { + const std::string OPEN_POSE_TEXT{"OpenPose 1.0.1"}; + inline void showGuiHelp() { try @@ -17,7 +19,7 @@ namespace op if (!helpCvMat.empty()) { const auto fullScreen = false; - FrameDisplayer frameDisplayer{Point{helpCvMat.cols, helpCvMat.rows}, "OpenPose - GUI Help", fullScreen}; + FrameDisplayer frameDisplayer{Point{helpCvMat.cols, helpCvMat.rows}, OPEN_POSE_TEXT + " - GUI Help", fullScreen}; frameDisplayer.displayFrame(helpCvMat, 33); } } @@ -152,7 +154,7 @@ namespace op Gui::Gui(const bool fullScreen, const Point& outputSize, const std::shared_ptr>& isRunningSharedPtr, const std::shared_ptr, std::atomic>>& videoSeekSharedPtr, const std::vector>& poseExtractors, const std::vector>& poseRenderers) : - mFrameDisplayer{outputSize, "OpenPose - GUI", fullScreen}, + mFrameDisplayer{outputSize, OPEN_POSE_TEXT, fullScreen}, mPoseExtractors{poseExtractors}, mPoseRenderers{poseRenderers}, spIsRunning{isRunningSharedPtr}, -- GitLab