Skip to content

Commit bbef038

Browse files
Improved error message and doc
1 parent 5283e28 commit bbef038

File tree

3 files changed

+35
-10
lines changed

3 files changed

+35
-10
lines changed

doc/output.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ OpenPose Demo - Output
88
1. [Keypoint Ordering](#keypoint-ordering)
99
2. [Heatmap Ordering](#heatmap-ordering)
1010
3. [Heatmap Saving in Float Format](#heatmap-saving-in-float-format)
11-
4. [Face and Hands](#face-and-hands)
12-
5. [Pose Output Format](#pose-output-format)
13-
6. [Face Output Format](#face-output-format)
14-
7. [Hand Output Format](#hand-output-format)
11+
4. [Heatmap Scaling](#heatmap-scaling)
12+
5. [Face and Hands](#face-and-hands)
13+
6. [Pose Output Format](#pose-output-format)
14+
7. [Face Output Format](#face-output-format)
15+
8. [Hand Output Format](#hand-output-format)
1516
3. [Reading Saved Results](#reading-saved-results)
1617
4. [Keypoint Format in the C++ API](#keypoint-format-in-the-c-api)
1718

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

154155

155156

157+
### Heatmap Scaling
158+
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.
159+
160+
161+
156162
### Face and Hands
157163
The output format is analogous for hand (`hand_left_keypoints`, `hand_right_keypoints`) and face (`face_keypoints`) JSON files.
158164

src/openpose/filestream/cocoJsonSaver.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@
66

77
namespace op
88
{
9+
int getLastNumberWithErrorMessage(const std::string& imageName, const CocoJsonFormat cocoJsonFormat)
10+
{
11+
try
12+
{
13+
return getLastNumber(imageName);
14+
}
15+
catch (const std::exception& e)
16+
{
17+
const std::string errorMessage = "`--write_coco_json` is to be used with the original "
18+
+ std::string(cocoJsonFormat == CocoJsonFormat::Car ? "car" : "COCO")
19+
+ " dataset images. If you are not"
20+
" applying those, OpenPose cannot obtain the ID from their file names. Error details: "
21+
+ e.what();
22+
error(errorMessage, __LINE__, __FUNCTION__, __FILE__);
23+
return -1;
24+
}
25+
}
26+
927
CocoJsonSaver::CocoJsonSaver(const std::string& filePathToSave, const PoseModel poseModel,
1028
const bool humanReadable, const int cocoJsonVariants,
1129
const CocoJsonFormat cocoJsonFormat, const int cocoJsonVariant) :
@@ -97,7 +115,7 @@ namespace op
97115
auto imageId = frameNumber;
98116
if (cocoJsonFormat == CocoJsonFormat::Body)
99117
{
100-
imageId = getLastNumber(imageName);
118+
imageId = getLastNumberWithErrorMessage(imageName, CocoJsonFormat::Body);
101119
// Body
102120
if (numberBodyParts == 23)
103121
indexesInCocoOrder = std::vector<int>{
@@ -120,7 +138,7 @@ namespace op
120138
// Foot
121139
else if (cocoJsonFormat == CocoJsonFormat::Foot)
122140
{
123-
imageId = getLastNumber(imageName);
141+
imageId = getLastNumberWithErrorMessage(imageName, CocoJsonFormat::Foot);
124142
if (numberBodyParts == 25 || numberBodyParts > 60)
125143
indexesInCocoOrder = std::vector<int>{19,20,21, 22,23,24};
126144
else if (numberBodyParts == 23)
@@ -160,7 +178,7 @@ namespace op
160178
// Car
161179
else if (cocoJsonFormat == CocoJsonFormat::Car)
162180
{
163-
imageId = getLastNumber(imageName);
181+
imageId = getLastNumberWithErrorMessage(imageName, CocoJsonFormat::Car);
164182
// Car12
165183
if (numberBodyParts == 12)
166184
indexesInCocoOrder = std::vector<int>{0,1,2,3, 4,5,6,7, 8, 8,9,10,11, 11};

src/openpose/wrapper/wrapperAuxiliary.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ namespace op
102102
}
103103
}
104104
if (!wrapperStructOutput.writeVideo.empty() && producerSharedPtr == nullptr)
105-
error("Writting video is only available if the OpenPose producer is used (i.e."
106-
" producerSharedPtr cannot be a nullptr).",
107-
__LINE__, __FUNCTION__, __FILE__);
105+
error("Writting video (`--write_video`) is only available if the OpenPose producer is used (i.e."
106+
" producerSharedPtr cannot be a nullptr). Otherwise, OpenPose would not know the frame rate"
107+
" of that output video nor whether all the images maintain the same resolution. You might"
108+
" use `--write_images` instead.", __LINE__, __FUNCTION__, __FILE__);
108109
if (wrapperStructPose.poseMode == PoseMode::Disabled && !wrapperStructFace.enable
109110
&& !wrapperStructHand.enable)
110111
error("Body, face, and hand keypoint detectors are disabled. You must enable at least one (i.e,"

0 commit comments

Comments
 (0)