diff --git a/src/openalpr/alpr_impl.cpp b/src/openalpr/alpr_impl.cpp index 372cffd..5ab7f77 100644 --- a/src/openalpr/alpr_impl.cpp +++ b/src/openalpr/alpr_impl.cpp @@ -451,6 +451,11 @@ AlprResults AlprImpl::fromJson(std::string json) { plateCandidate.matches_template = (cJSON_GetObjectItem(candidate, "matches_template")->valueint) != 0; plate.topNPlates.push_back(plateCandidate); + + if (c == 0) + { + plate.bestPlate = plateCandidate; + } } allResults.plates.push_back(plate); diff --git a/src/tests/runtests.cpp b/src/tests/runtests.cpp index 23372d5..cd9e508 100644 --- a/src/tests/runtests.cpp +++ b/src/tests/runtests.cpp @@ -78,6 +78,10 @@ TEST_CASE( "JSON Serialization/Deserialization", "[json]" ) { REQUIRE( roundTrip.plates[i].regionConfidence == origResults.plates[i].regionConfidence); REQUIRE( roundTrip.plates[i].requested_topn == origResults.plates[i].requested_topn); + REQUIRE( roundTrip.plates[i].bestPlate.characters == origResults.plates[i].bestPlate.characters); + REQUIRE( roundTrip.plates[i].bestPlate.matches_template == origResults.plates[i].bestPlate.matches_template); + REQUIRE( roundTrip.plates[i].bestPlate.overall_confidence == origResults.plates[i].bestPlate.overall_confidence); + REQUIRE( roundTrip.plates[i].topNPlates.size() == origResults.plates[i].topNPlates.size()); for (int j = 0; j < roundTrip.plates[i].topNPlates.size(); j++) {