From 6e94703dea53a0b48312a22c57bbcc602ba72a1c Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Mon, 10 Aug 2015 23:03:22 -0400 Subject: [PATCH] Using configured regex letter/number values to build pre-compiled postprocess regexes --- src/openalpr/postprocess/postprocess.cpp | 2 +- src/openalpr/postprocess/regexrule.cpp | 6 +++--- src/openalpr/postprocess/regexrule.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/openalpr/postprocess/postprocess.cpp b/src/openalpr/postprocess/postprocess.cpp index dcdf043..3d7bc5b 100644 --- a/src/openalpr/postprocess/postprocess.cpp +++ b/src/openalpr/postprocess/postprocess.cpp @@ -36,7 +36,7 @@ namespace alpr string region, pattern; while (infile >> region >> pattern) { - RegexRule* rule = new RegexRule(region, pattern); + RegexRule* rule = new RegexRule(region, pattern, config->postProcessRegexLetters, config->postProcessRegexNumbers); //cout << "REGION: " << region << " PATTERN: " << pattern << endl; if (rules.find(region) == rules.end()) diff --git a/src/openalpr/postprocess/regexrule.cpp b/src/openalpr/postprocess/regexrule.cpp index 57bd619..aa8226e 100644 --- a/src/openalpr/postprocess/regexrule.cpp +++ b/src/openalpr/postprocess/regexrule.cpp @@ -28,7 +28,7 @@ tthread::mutex regexrule_mutex_m; namespace alpr { - RegexRule::RegexRule(string region, string pattern) + RegexRule::RegexRule(string region, string pattern, std::string letters_regex, std::string numbers_regex) //: re2_regex("") { this->original = pattern; @@ -80,11 +80,11 @@ namespace alpr } else if (utf_character == "@") { - regexval << "\\pL"; + regexval << letters_regex; } else if (utf_character == "#") { - regexval << "\\pN"; + regexval << numbers_regex; } else if ((utf_character == "*") || (utf_character == "+")) { diff --git a/src/openalpr/postprocess/regexrule.h b/src/openalpr/postprocess/regexrule.h index d071f61..d369a92 100644 --- a/src/openalpr/postprocess/regexrule.h +++ b/src/openalpr/postprocess/regexrule.h @@ -33,7 +33,7 @@ namespace alpr class RegexRule { public: - RegexRule(std::string region, std::string pattern); + RegexRule(std::string region, std::string pattern, std::string letters_regex, std::string numbers_regex); virtual ~RegexRule(); bool match(std::string text);