Added all TopN plates to JSON formatted results

This commit is contained in:
Matt Hill
2014-01-29 19:05:43 -06:00
parent 7c54bfd77c
commit da2a0da57e

View File

@@ -214,7 +214,7 @@ string AlprImpl::toJson(const vector< AlprResult > results)
cJSON* AlprImpl::createJsonObj(const AlprResult* result)
{
cJSON *root, *coords;
cJSON *root, *coords, *candidates;
root=cJSON_CreateObject();
@@ -238,6 +238,19 @@ cJSON* AlprImpl::createJsonObj(const AlprResult* result)
cJSON_AddItemToArray(coords, coords_object);
}
cJSON_AddItemToObject(root, "candidates", candidates=cJSON_CreateArray());
for (int i = 0; i < result->topNPlates.size(); i++)
{
cJSON *candidate_object;
candidate_object = cJSON_CreateObject();
cJSON_AddStringToObject(candidate_object, "plate", result->topNPlates[i].characters.c_str());
cJSON_AddNumberToObject(candidate_object, "confidence", result->topNPlates[i].overall_confidence);
cJSON_AddNumberToObject(candidate_object, "matches_template", result->topNPlates[i].matches_template);
cJSON_AddItemToArray(candidates, candidate_object);
}
return root;
}