Added configuration option to output character details in results

This commit is contained in:
psaintjust
2015-06-30 19:41:37 -04:00
parent 6d9d8201e1
commit 50f9d2d81a
4 changed files with 29 additions and 19 deletions

View File

@@ -187,8 +187,11 @@ namespace alpr
ocr->performOCR(&pipeline_data);
ocr->postProcessor.analyze(plateResult.region, topN);
const vector<PPResult> ppResults = ocr->postProcessor.getResults();
timespec resultsStartTime;
getTimeMonotonic(&resultsStartTime);
const vector<PPResult> ppResults = ocr->postProcessor.getResults();
int bestPlateIndex = 0;
@@ -204,20 +207,22 @@ namespace alpr
aplate.overall_confidence = ppResults[pp].totalscore;
aplate.matches_template = ppResults[pp].matchesTemplate;
// Grab detailed results for each character
for (unsigned int c_idx = 0; c_idx < ppResults[pp].letter_details.size(); c_idx++)
if (config->resultsCharacterDetails)
{
AlprChar character_details;
character_details.character = ppResults[pp].letter_details[c_idx].letter;
character_details.confidence = ppResults[pp].letter_details[c_idx].totalscore;
cv::Rect char_rect = pipeline_data.charRegions[ppResults[pp].letter_details[c_idx].charposition];
std::vector<AlprCoordinate> charpoints = getCharacterPoints(char_rect, &pipeline_data );
for (int cpt = 0; cpt < 4; cpt++)
character_details.corners[cpt] = charpoints[cpt];
aplate.character_details.push_back(character_details);
// Grab detailed results for each character
for (unsigned int c_idx = 0; c_idx < ppResults[pp].letter_details.size(); c_idx++)
{
AlprChar character_details;
character_details.character = ppResults[pp].letter_details[c_idx].letter;
character_details.confidence = ppResults[pp].letter_details[c_idx].totalscore;
cv::Rect char_rect = pipeline_data.charRegions[ppResults[pp].letter_details[c_idx].charposition];
std::vector<AlprCoordinate> charpoints = getCharacterPoints(char_rect, &pipeline_data );
for (int cpt = 0; cpt < 4; cpt++)
character_details.corners[cpt] = charpoints[cpt];
aplate.character_details.push_back(character_details);
}
plateResult.topNPlates.push_back(aplate);
}
plateResult.topNPlates.push_back(aplate);
}
if (plateResult.topNPlates.size() > bestPlateIndex)
@@ -234,6 +239,10 @@ namespace alpr
timespec plateEndTime;
getTimeMonotonic(&plateEndTime);
plateResult.processing_time_ms = diffclock(platestarttime, plateEndTime);
if (config->debugTiming)
{
cout << "Result Generation Time: " << diffclock(resultsStartTime, plateEndTime) << "ms." << endl;
}
if (plateResult.topNPlates.size() > 0)
{
@@ -252,9 +261,6 @@ namespace alpr
}
}
}
// Unwarp plate regions if necessary