Skip to content

Commit

Permalink
Improved error message and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
gineshidalgo99 committed Sep 2, 2019
1 parent 5283e28 commit bbef038
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
14 changes: 10 additions & 4 deletions doc/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ OpenPose Demo - Output
1. [Keypoint Ordering](#keypoint-ordering)
2. [Heatmap Ordering](#heatmap-ordering)
3. [Heatmap Saving in Float Format](#heatmap-saving-in-float-format)
4. [Face and Hands](#face-and-hands)
5. [Pose Output Format](#pose-output-format)
6. [Face Output Format](#face-output-format)
7. [Hand Output Format](#hand-output-format)
4. [Heatmap Scaling](#heatmap-scaling)
5. [Face and Hands](#face-and-hands)
6. [Pose Output Format](#pose-output-format)
7. [Face Output Format](#face-output-format)
8. [Hand Output Format](#hand-output-format)
3. [Reading Saved Results](#reading-saved-results)
4. [Keypoint Format in the C++ API](#keypoint-format-in-the-c-api)

Expand Down Expand Up @@ -153,6 +154,11 @@ arrayData = x[1+int(round(x[0])):]



### Heatmap Scaling
Note that `--net_resolution` sets the size of the network, thus also the size of the output heatmaps. This heatmaps are resized while keeping the aspect ratio. When aspect ratio of the the input and network are not the same, padding is added at the bottom and/or right part of the output heatmaps.



### Face and Hands
The output format is analogous for hand (`hand_left_keypoints`, `hand_right_keypoints`) and face (`face_keypoints`) JSON files.

Expand Down
24 changes: 21 additions & 3 deletions src/openpose/filestream/cocoJsonSaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@

namespace op
{
int getLastNumberWithErrorMessage(const std::string& imageName, const CocoJsonFormat cocoJsonFormat)
{
try
{
return getLastNumber(imageName);
}
catch (const std::exception& e)
{
const std::string errorMessage = "`--write_coco_json` is to be used with the original "
+ std::string(cocoJsonFormat == CocoJsonFormat::Car ? "car" : "COCO")
+ " dataset images. If you are not"
" applying those, OpenPose cannot obtain the ID from their file names. Error details: "
+ e.what();
error(errorMessage, __LINE__, __FUNCTION__, __FILE__);
return -1;
}
}

CocoJsonSaver::CocoJsonSaver(const std::string& filePathToSave, const PoseModel poseModel,
const bool humanReadable, const int cocoJsonVariants,
const CocoJsonFormat cocoJsonFormat, const int cocoJsonVariant) :
Expand Down Expand Up @@ -97,7 +115,7 @@ namespace op
auto imageId = frameNumber;
if (cocoJsonFormat == CocoJsonFormat::Body)
{
imageId = getLastNumber(imageName);
imageId = getLastNumberWithErrorMessage(imageName, CocoJsonFormat::Body);
// Body
if (numberBodyParts == 23)
indexesInCocoOrder = std::vector<int>{
Expand All @@ -120,7 +138,7 @@ namespace op
// Foot
else if (cocoJsonFormat == CocoJsonFormat::Foot)
{
imageId = getLastNumber(imageName);
imageId = getLastNumberWithErrorMessage(imageName, CocoJsonFormat::Foot);
if (numberBodyParts == 25 || numberBodyParts > 60)
indexesInCocoOrder = std::vector<int>{19,20,21, 22,23,24};
else if (numberBodyParts == 23)
Expand Down Expand Up @@ -160,7 +178,7 @@ namespace op
// Car
else if (cocoJsonFormat == CocoJsonFormat::Car)
{
imageId = getLastNumber(imageName);
imageId = getLastNumberWithErrorMessage(imageName, CocoJsonFormat::Car);
// Car12
if (numberBodyParts == 12)
indexesInCocoOrder = std::vector<int>{0,1,2,3, 4,5,6,7, 8, 8,9,10,11, 11};
Expand Down
7 changes: 4 additions & 3 deletions src/openpose/wrapper/wrapperAuxiliary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ namespace op
}
}
if (!wrapperStructOutput.writeVideo.empty() && producerSharedPtr == nullptr)
error("Writting video is only available if the OpenPose producer is used (i.e."
" producerSharedPtr cannot be a nullptr).",
__LINE__, __FUNCTION__, __FILE__);
error("Writting video (`--write_video`) is only available if the OpenPose producer is used (i.e."
" producerSharedPtr cannot be a nullptr). Otherwise, OpenPose would not know the frame rate"
" of that output video nor whether all the images maintain the same resolution. You might"
" use `--write_images` instead.", __LINE__, __FUNCTION__, __FILE__);
if (wrapperStructPose.poseMode == PoseMode::Disabled && !wrapperStructFace.enable
&& !wrapperStructHand.enable)
error("Body, face, and hand keypoint detectors are disabled. You must enable at least one (i.e,"
Expand Down

0 comments on commit bbef038

Please sign in to comment.