diff --git a/doc/output.md b/doc/output.md index 0d9e366d24cdd7d637f96fea0eb9323d7df98017..d5d3423191f3d777006a2a683252be19f599c996 100644 --- a/doc/output.md +++ b/doc/output.md @@ -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) @@ -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. diff --git a/src/openpose/filestream/cocoJsonSaver.cpp b/src/openpose/filestream/cocoJsonSaver.cpp index 6ec5216e32b7595a7d54901214703328125c4dff..4fae762ebb2c30f4f72327dcdf30c5872c1abdcc 100644 --- a/src/openpose/filestream/cocoJsonSaver.cpp +++ b/src/openpose/filestream/cocoJsonSaver.cpp @@ -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) : @@ -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{ @@ -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{19,20,21, 22,23,24}; else if (numberBodyParts == 23) @@ -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{0,1,2,3, 4,5,6,7, 8, 8,9,10,11, 11}; diff --git a/src/openpose/wrapper/wrapperAuxiliary.cpp b/src/openpose/wrapper/wrapperAuxiliary.cpp index 8939663bd4485e8432a9242c1aab1f3f89450337..7c2e48214d8d7e6f531af1eafb69436832a6639b 100644 --- a/src/openpose/wrapper/wrapperAuxiliary.cpp +++ b/src/openpose/wrapper/wrapperAuxiliary.cpp @@ -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,"