Added a must_match_pattern config option. When a text pattern is available, all non-matching values will be disregarded.

This commit is contained in:
Matt Hill
2015-09-24 22:12:31 -04:00
parent c4d35e4e8d
commit 61f37ba596
4 changed files with 19 additions and 3 deletions

View File

@@ -42,6 +42,10 @@ max_detection_input_height = 720
; morphcpu - Experimental detector that detects white rectangles in an image. Does not require training. ; morphcpu - Experimental detector that detects white rectangles in an image. Does not require training.
detector = lbpcpu detector = lbpcpu
; If set to true, all results must match a postprocess text pattern if a pattern is available.
; If not, the result is disqualified.
must_match_pattern = 0
; Bypasses plate detection. If this is set to 1, the library assumes that each region provided is a likely plate area. ; Bypasses plate detection. If this is set to 1, the library assumes that each region provided is a likely plate area.
skip_detection = 0 skip_detection = 0

View File

@@ -176,6 +176,8 @@ namespace alpr
maxDetectionInputWidth = getInt(ini, "", "max_detection_input_width", 1280); maxDetectionInputWidth = getInt(ini, "", "max_detection_input_width", 1280);
maxDetectionInputHeight = getInt(ini, "", "max_detection_input_height", 768); maxDetectionInputHeight = getInt(ini, "", "max_detection_input_height", 768);
mustMatchPattern = getBoolean(ini, "", "must_match_pattern", false);
skipDetection = getBoolean(ini, "", "skip_detection", false); skipDetection = getBoolean(ini, "", "skip_detection", false);
prewarp = getString(ini, "", "prewarp", ""); prewarp = getString(ini, "", "prewarp", "");

View File

@@ -104,6 +104,8 @@ namespace alpr
std::string ocrLanguage; std::string ocrLanguage;
int ocrMinFontSize; int ocrMinFontSize;
bool mustMatchPattern;
float postProcessMinConfidence; float postProcessMinConfidence;
float postProcessConfidenceSkipLevel; float postProcessConfidenceSkipLevel;
unsigned int postProcessMinCharacters; unsigned int postProcessMinCharacters;

View File

@@ -381,11 +381,19 @@ namespace alpr
if (allPossibilitiesLetters.end() != allPossibilitiesLetters.find(possibility.letters)) if (allPossibilitiesLetters.end() != allPossibilitiesLetters.find(possibility.letters))
return false; return false;
// If mustMatchPattern is toggled in the config and a template is provided,
// only include this result if there is a pattern match
if (!config->mustMatchPattern || templateregion.size() == 0 ||
(config->mustMatchPattern && possibility.matchesTemplate))
{
allPossibilities.push_back(possibility); allPossibilities.push_back(possibility);
allPossibilitiesLetters.insert(possibility.letters); allPossibilitiesLetters.insert(possibility.letters);
return true; return true;
} }
return false;
}
std::vector<string> PostProcess::getPatterns() { std::vector<string> PostProcess::getPatterns() {
vector<string> v; vector<string> v;
for(map<string,std::vector<RegexRule*> >::iterator it = rules.begin(); it != rules.end(); ++it) { for(map<string,std::vector<RegexRule*> >::iterator it = rules.begin(); it != rules.end(); ++it) {