Skip to content

Commit 23f10ff

Browse files
xfanplusgineshidalgo99
authored andcommitted
fix wrong json file format (#157)
* fix wrong json file format COCO challenge only has 17 keypoints, so indexesInCocoOrder.size()==17. openpose added the neck keypoint (index 1), therefore numberBodyParts==18. numberBodyParts-1==17, Statement `if (bodyPart < numberBodyParts-1)` adds a comma for every bodyPart ([0..16]), add a extra comma in the end, causing a bad json format file, which can not be proporly parsed. * Update cocoJsonSaver.cpp
1 parent efecb00 commit 23f10ff

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/openpose/filestream/cocoJsonSaver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace op
6060
// keypoints - i.e. poseKeypoints
6161
mJsonOfstream.key("keypoints");
6262
mJsonOfstream.arrayOpen();
63-
const std::vector<int> indexesInCocoOrder{0, 15, 14, 17, 16, 5, 2, 6, 3, 7, 4, 11, 8, 12, 9, 13, 10};
63+
const std::vector<int> indexesInCocoOrder{0, 15, 14, 17, 16, 5, 2, 6, 3, 7, 4, 11, 8, 12, 9, 13, 10};
6464
for (auto bodyPart = 0 ; bodyPart < indexesInCocoOrder.size() ; bodyPart++)
6565
{
6666
const auto finalIndex = 3*(person*numberBodyParts + indexesInCocoOrder.at(bodyPart));
@@ -69,7 +69,7 @@ namespace op
6969
mJsonOfstream.plainText(poseKeypoints[finalIndex+1]);
7070
mJsonOfstream.comma();
7171
mJsonOfstream.plainText(1);
72-
if (bodyPart < numberBodyParts-1)
72+
if (bodyPart < indexesInCocoOrder.size() - 1)
7373
mJsonOfstream.comma();
7474
}
7575
mJsonOfstream.arrayClose();

0 commit comments

Comments
 (0)