mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 01:36:51 +08:00
Added configuration option to output character details in results
This commit is contained in:
@@ -59,6 +59,8 @@ postprocess_confidence_skip_level = 80
|
|||||||
postprocess_min_characters = 4
|
postprocess_min_characters = 4
|
||||||
postprocess_max_characters = 8
|
postprocess_max_characters = 8
|
||||||
|
|
||||||
|
; Return detailed results for each character
|
||||||
|
results_character_details = 0
|
||||||
|
|
||||||
debug_general = 0
|
debug_general = 0
|
||||||
debug_timing = 0
|
debug_timing = 0
|
||||||
|
@@ -187,8 +187,11 @@ namespace alpr
|
|||||||
|
|
||||||
ocr->performOCR(&pipeline_data);
|
ocr->performOCR(&pipeline_data);
|
||||||
ocr->postProcessor.analyze(plateResult.region, topN);
|
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;
|
int bestPlateIndex = 0;
|
||||||
|
|
||||||
@@ -204,20 +207,22 @@ namespace alpr
|
|||||||
aplate.overall_confidence = ppResults[pp].totalscore;
|
aplate.overall_confidence = ppResults[pp].totalscore;
|
||||||
aplate.matches_template = ppResults[pp].matchesTemplate;
|
aplate.matches_template = ppResults[pp].matchesTemplate;
|
||||||
|
|
||||||
// Grab detailed results for each character
|
if (config->resultsCharacterDetails)
|
||||||
for (unsigned int c_idx = 0; c_idx < ppResults[pp].letter_details.size(); c_idx++)
|
|
||||||
{
|
{
|
||||||
AlprChar character_details;
|
// Grab detailed results for each character
|
||||||
character_details.character = ppResults[pp].letter_details[c_idx].letter;
|
for (unsigned int c_idx = 0; c_idx < ppResults[pp].letter_details.size(); c_idx++)
|
||||||
character_details.confidence = ppResults[pp].letter_details[c_idx].totalscore;
|
{
|
||||||
cv::Rect char_rect = pipeline_data.charRegions[ppResults[pp].letter_details[c_idx].charposition];
|
AlprChar character_details;
|
||||||
std::vector<AlprCoordinate> charpoints = getCharacterPoints(char_rect, &pipeline_data );
|
character_details.character = ppResults[pp].letter_details[c_idx].letter;
|
||||||
for (int cpt = 0; cpt < 4; cpt++)
|
character_details.confidence = ppResults[pp].letter_details[c_idx].totalscore;
|
||||||
character_details.corners[cpt] = charpoints[cpt];
|
cv::Rect char_rect = pipeline_data.charRegions[ppResults[pp].letter_details[c_idx].charposition];
|
||||||
aplate.character_details.push_back(character_details);
|
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)
|
if (plateResult.topNPlates.size() > bestPlateIndex)
|
||||||
@@ -234,6 +239,10 @@ namespace alpr
|
|||||||
timespec plateEndTime;
|
timespec plateEndTime;
|
||||||
getTimeMonotonic(&plateEndTime);
|
getTimeMonotonic(&plateEndTime);
|
||||||
plateResult.processing_time_ms = diffclock(platestarttime, 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)
|
if (plateResult.topNPlates.size() > 0)
|
||||||
{
|
{
|
||||||
@@ -252,9 +261,6 @@ namespace alpr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unwarp plate regions if necessary
|
// Unwarp plate regions if necessary
|
||||||
|
@@ -180,6 +180,8 @@ namespace alpr
|
|||||||
postProcessMinCharacters = getInt(ini, "", "postprocess_min_characters", 100);
|
postProcessMinCharacters = getInt(ini, "", "postprocess_min_characters", 100);
|
||||||
postProcessMaxCharacters = getInt(ini, "", "postprocess_max_characters", 100);
|
postProcessMaxCharacters = getInt(ini, "", "postprocess_max_characters", 100);
|
||||||
|
|
||||||
|
resultsCharacterDetails = getBoolean(ini,"", "results_character_details", false);
|
||||||
|
|
||||||
debugGeneral = getBoolean(ini, "", "debug_general", false);
|
debugGeneral = getBoolean(ini, "", "debug_general", false);
|
||||||
debugTiming = getBoolean(ini, "", "debug_timing", false);
|
debugTiming = getBoolean(ini, "", "debug_timing", false);
|
||||||
debugPrewarp = getBoolean(ini, "", "debug_prewarp", false);
|
debugPrewarp = getBoolean(ini, "", "debug_prewarp", false);
|
||||||
@@ -329,4 +331,4 @@ namespace alpr
|
|||||||
string val = string(pszValue);
|
string val = string(pszValue);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -101,10 +101,10 @@ namespace alpr
|
|||||||
|
|
||||||
float postProcessMinConfidence;
|
float postProcessMinConfidence;
|
||||||
float postProcessConfidenceSkipLevel;
|
float postProcessConfidenceSkipLevel;
|
||||||
unsigned int postProcessMaxSubstitutions;
|
|
||||||
unsigned int postProcessMinCharacters;
|
unsigned int postProcessMinCharacters;
|
||||||
unsigned int postProcessMaxCharacters;
|
unsigned int postProcessMaxCharacters;
|
||||||
|
|
||||||
|
unsigned int resultsCharacterDetails;
|
||||||
|
|
||||||
bool debugGeneral;
|
bool debugGeneral;
|
||||||
bool debugTiming;
|
bool debugTiming;
|
||||||
@@ -153,4 +153,4 @@ namespace alpr
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif // OPENALPR_CONFIG_H
|
#endif // OPENALPR_CONFIG_H
|
||||||
|
Reference in New Issue
Block a user