mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 15:06:50 +08:00
Added all TopN plates to JSON formatted results
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user