From 0d2141b4a13f4056c5d49e6446d05be470751158 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 23 Oct 2014 22:15:27 -0400 Subject: [PATCH] Added bestplate parsing and unit test --- src/openalpr/alpr_impl.cpp | 5 +++++ src/tests/runtests.cpp | 4 ++++ 2 files changed, 9 insertions(+) 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++) {