Handled a crash condition when no plate candidates score above the minimum threshold

This commit is contained in:
Matt Hill
2016-03-13 14:55:14 -04:00
parent 74c789187e
commit 0a10773710

View File

@@ -220,29 +220,32 @@ namespace alpr
} }
} }
// Figure out the best region for this cluster if (sorted_results.size() > 0)
ResultRegionScore regionResults = findBestRegion(clusters[unique_plate_idx]);
AlprPlateResult firstResult = clusters[unique_plate_idx][0];
AlprPlateResult copyResult;
copyResult.bestPlate = sorted_results[0].second.plate;
copyResult.plate_index = firstResult.plate_index;
copyResult.region = regionResults.region;
copyResult.regionConfidence = regionResults.confidence;
copyResult.processing_time_ms = firstResult.processing_time_ms;
copyResult.requested_topn = firstResult.requested_topn;
for (int p_idx = 0; p_idx < 4; p_idx++)
copyResult.plate_points[p_idx] = firstResult.plate_points[p_idx];
for (int i = 0; i < sorted_results.size(); i++)
{ {
if (i >= topn) // Figure out the best region for this cluster
break; ResultRegionScore regionResults = findBestRegion(clusters[unique_plate_idx]);
copyResult.topNPlates.push_back(sorted_results[i].second.plate); AlprPlateResult firstResult = clusters[unique_plate_idx][0];
AlprPlateResult copyResult;
copyResult.bestPlate = sorted_results[0].second.plate;
copyResult.plate_index = firstResult.plate_index;
copyResult.region = regionResults.region;
copyResult.regionConfidence = regionResults.confidence;
copyResult.processing_time_ms = firstResult.processing_time_ms;
copyResult.requested_topn = firstResult.requested_topn;
for (int p_idx = 0; p_idx < 4; p_idx++)
copyResult.plate_points[p_idx] = firstResult.plate_points[p_idx];
for (int i = 0; i < sorted_results.size(); i++)
{
if (i >= topn)
break;
copyResult.topNPlates.push_back(sorted_results[i].second.plate);
}
response.results.plates.push_back(copyResult);
} }
response.results.plates.push_back(copyResult);
} }
} }