Resolves issue #150 Automatically apply pattern matching for countries with only one pattern

This commit is contained in:
Matt Hill
2015-09-24 00:22:23 -04:00
parent 0c088fb2e8
commit c4d35e4e8d
3 changed files with 17 additions and 1 deletions

View File

@@ -277,7 +277,13 @@ namespace alpr
if (!pipeline_data.disqualified)
{
AlprPlateResult plateResult;
// If there's only one pattern for a country, use it. Otherwise use the default
if (country_recognizers.ocr->postProcessor.getPatterns().size() == 1)
plateResult.region = country_recognizers.ocr->postProcessor.getPatterns()[0];
else
plateResult.region = defaultRegion;
plateResult.regionConfidence = 0;
plateResult.plate_index = platecount++;

View File

@@ -386,6 +386,14 @@ namespace alpr
return true;
}
std::vector<string> PostProcess::getPatterns() {
vector<string> v;
for(map<string,std::vector<RegexRule*> >::iterator it = rules.begin(); it != rules.end(); ++it) {
v.push_back(it->first);
}
return v;
}
bool letterCompare( const Letter &left, const Letter &right )
{

View File

@@ -74,6 +74,8 @@ namespace alpr
bool regionIsValid(std::string templateregion);
std::vector<std::string> getPatterns();
private:
Config* config;