提交 23f10ff6 编写于 作者: X xfanplus 提交者: Gines

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
上级 efecb002
......@@ -60,7 +60,7 @@ namespace op
// keypoints - i.e. poseKeypoints
mJsonOfstream.key("keypoints");
mJsonOfstream.arrayOpen();
const std::vector<int> indexesInCocoOrder{0, 15, 14, 17, 16, 5, 2, 6, 3, 7, 4, 11, 8, 12, 9, 13, 10};
const std::vector<int> indexesInCocoOrder{0, 15, 14, 17, 16, 5, 2, 6, 3, 7, 4, 11, 8, 12, 9, 13, 10};
for (auto bodyPart = 0 ; bodyPart < indexesInCocoOrder.size() ; bodyPart++)
{
const auto finalIndex = 3*(person*numberBodyParts + indexesInCocoOrder.at(bodyPart));
......@@ -69,7 +69,7 @@ namespace op
mJsonOfstream.plainText(poseKeypoints[finalIndex+1]);
mJsonOfstream.comma();
mJsonOfstream.plainText(1);
if (bodyPart < numberBodyParts-1)
if (bodyPart < indexesInCocoOrder.size() - 1)
mJsonOfstream.comma();
}
mJsonOfstream.arrayClose();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册