From 672f46d3dc5a354f87888eafa1608fb4854450c3 Mon Sep 17 00:00:00 2001 From: Stefan Matheis Date: Sat, 11 Jun 2016 17:18:53 +0200 Subject: [PATCH 1/8] sort eu-patterns by country --- runtime_data/postprocess/eu.patterns | 160 +++++++++++++-------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/runtime_data/postprocess/eu.patterns b/runtime_data/postprocess/eu.patterns index bdd91ec..f474a61 100644 --- a/runtime_data/postprocess/eu.patterns +++ b/runtime_data/postprocess/eu.patterns @@ -1,138 +1,138 @@ -al @@###@@ ad @#### -am ###@@### -am ##@@### +al @@###@@ am ###@@## +am ###@@### am ##@@## -at @@??? -at @@???? -at @@????? -at @@?????? +am ##@@### at @??? at @???? at @????? at @?????? +at @@??? +at @@???? +at @@????? +at @@?????? az ##@@### -by ####@@# -be #@@@### -be ###@@@ ba [AEJKMOT]##[AEJKMOT]### ba [T][A]###### -ba [T][T]###### -ba ######[AEJKT] -bg @@####@@ +ba ######[AEJKT] +ba [T][T]###### +be ###@@@ +be #@@@### bg @####@@ -hr @@###@@ -hr @@####@@ -hr @@###@ -hr @@####@ +bg @@####@@ +by ####@@# +ch @@###### +ch [APM]###### cy @@@### cz #@##### cz #@@#### dk @@##### ee ###@@@ +es ####@@@ +es @####@@@ fi @@@### fr @@###@@ +gb @@##@@@ ge @@###@@ gi [G]####@ gr @@@#### +hr @@####@ +hr @@####@@ +hr @@###@ +hr @@###@@ hu @@@### -is @@@## -ie ##[12][CDGLTW]###### -ie ##[12][CDGKLMORSTW][DEHKLMNOSWXY]###### -ie ##[12][CDGLTW]##### -ie ##[12][CDGKLMORSTW][DEHKLMNOSWXY]##### -ie ##[12][CDGLTW]#### -ie ##[12][CDGKLMORSTW][DEHKLMNOSWXY]#### -ie ##[12][CDGLTW]### ie ##[12][CDGKLMORSTW][DEHKLMNOSWXY]### -ie ##[CDGLTW]###### -ie ##[CDGKLMORSTW][DEHKLMNOSWXY]###### -ie ##[CDGLTW]##### -ie ##[CDGKLMORSTW][DEHKLMNOSWXY]##### -ie ##[CDGLTW]#### -ie ##[CDGKLMORSTW][DEHKLMNOSWXY]#### -ie ##[CDGLTW]### +ie ##[12][CDGKLMORSTW][DEHKLMNOSWXY]#### +ie ##[12][CDGKLMORSTW][DEHKLMNOSWXY]##### +ie ##[12][CDGKLMORSTW][DEHKLMNOSWXY]###### +ie ##[12][CDGLTW]### +ie ##[12][CDGLTW]#### +ie ##[12][CDGLTW]##### +ie ##[12][CDGLTW]###### ie ##[CDGKLMORSTW][DEHKLMNOSWXY]### +ie ##[CDGKLMORSTW][DEHKLMNOSWXY]#### +ie ##[CDGKLMORSTW][DEHKLMNOSWXY]##### +ie ##[CDGKLMORSTW][DEHKLMNOSWXY]###### +ie ##[CDGLTW]### +ie ##[CDGLTW]#### +ie ##[CDGLTW]##### +ie ##[CDGLTW]###### +is @@@## it @@###@@ kz ###@@@ -lv @@#### -lv @@### -lv @#### -lv @### -li @@##### -li @@#### li @@### +li @@#### +li @@##### lt @@@### lu @@#### +lv @### +lv @#### +lv @@### +lv @@#### +mc ???? +md @@@@# +md @@@@## +md @@@@### +md [CK]@@# +md [CK]@@## +md [CK]@@### +me @@@@### mk @@####@@ mt @@@### -md @@@@### -md [CK]@@### -md @@@@## -md [CK]@@## -md @@@@# -md [CK]@@# -mc ???? -me @@@@### -nl @@#### nl ####@@ -nl ##@@## -nl @@##@@ -nl @@@@## -nl ##@@@@ -nl ##@@@# -nl #@@@## -nl @@###@ -nl @###@@ -nl @@@##@ -nl @##@@@ -nl #@@### nl ###@@# -no @@##### +nl ##@@## +nl ##@@@# +nl ##@@@@ +nl #@@### +nl #@@@## +nl @###@@ +nl @##@@@ +nl @@#### +nl @@###@ +nl @@##@@ +nl @@@##@ +nl @@@@## no ##### +no @@##### pl @@##### pl @@####@ pl @@###@@ pl @@#@### pl @@#@@## -pl @@@@### -pl @@@##@@ -pl @@@#@## -pl @@@##@# -pl @@@#@@# -pl @@@@@## pl @@@##### pl @@@####@ pl @@@###@@ -pt @@#### +pl @@@##@# +pl @@@##@@ +pl @@@#@## +pl @@@#@@# +pl @@@@### +pl @@@@@## pt ####@@ pt ##@@## +pt ##@@@@ +pt @@#### pt @@##@@ pt @@@@## -pt ##@@@@ -ro @@###@@@ -ro @@##@@@ ro @###@@@ ro @##@@@ +ro @@###@@@ +ro @@##@@@ +rs @@###@@ ru @###@@## ru @###@@### -sm @#### -sm @### -rs @@###@@ -sk @@###@@ -si @@@@### -es ####@@@ -es @####@@@ se @@@### -ch @@###### -ch [APM]###### +si @@@@### +sk @@###@@ +sm @### +sm @#### tr ##@#### tr ##@##### tr ##@@### tr ##@@#### tr ##@@@## ua @@####@@ -gb @@##@@@ -va [S][C][V]##### va [C][V]##### +va [S][C][V]##### From 0818ba7c3d470775bdd9b826f395c006d3489138 Mon Sep 17 00:00:00 2001 From: steffkes Date: Sun, 12 Jun 2016 11:31:06 +0200 Subject: [PATCH 2/8] sort eu-patterns by country, keep order within each country --- runtime_data/postprocess/eu.patterns | 116 +++++++++++++-------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/runtime_data/postprocess/eu.patterns b/runtime_data/postprocess/eu.patterns index f474a61..41dc6b5 100644 --- a/runtime_data/postprocess/eu.patterns +++ b/runtime_data/postprocess/eu.patterns @@ -1,26 +1,26 @@ ad @#### al @@###@@ -am ###@@## am ###@@### -am ##@@## am ##@@### -at @??? -at @???? -at @????? -at @?????? +am ###@@## +am ##@@## at @@??? at @@???? at @@????? at @@?????? +at @??? +at @???? +at @????? +at @?????? az ##@@### ba [AEJKMOT]##[AEJKMOT]### ba [T][A]###### -ba ######[AEJKT] ba [T][T]###### -be ###@@@ +ba ######[AEJKT] be #@@@### -bg @####@@ +be ###@@@ bg @@####@@ +bg @####@@ by ####@@# ch @@###### ch [APM]###### @@ -37,102 +37,102 @@ gb @@##@@@ ge @@###@@ gi [G]####@ gr @@@#### -hr @@####@ +hr @@###@@ hr @@####@@ hr @@###@ -hr @@###@@ +hr @@####@ hu @@@### -ie ##[12][CDGKLMORSTW][DEHKLMNOSWXY]### -ie ##[12][CDGKLMORSTW][DEHKLMNOSWXY]#### -ie ##[12][CDGKLMORSTW][DEHKLMNOSWXY]##### -ie ##[12][CDGKLMORSTW][DEHKLMNOSWXY]###### -ie ##[12][CDGLTW]### -ie ##[12][CDGLTW]#### -ie ##[12][CDGLTW]##### ie ##[12][CDGLTW]###### -ie ##[CDGKLMORSTW][DEHKLMNOSWXY]### -ie ##[CDGKLMORSTW][DEHKLMNOSWXY]#### -ie ##[CDGKLMORSTW][DEHKLMNOSWXY]##### -ie ##[CDGKLMORSTW][DEHKLMNOSWXY]###### -ie ##[CDGLTW]### -ie ##[CDGLTW]#### -ie ##[CDGLTW]##### +ie ##[12][CDGKLMORSTW][DEHKLMNOSWXY]###### +ie ##[12][CDGLTW]##### +ie ##[12][CDGKLMORSTW][DEHKLMNOSWXY]##### +ie ##[12][CDGLTW]#### +ie ##[12][CDGKLMORSTW][DEHKLMNOSWXY]#### +ie ##[12][CDGLTW]### +ie ##[12][CDGKLMORSTW][DEHKLMNOSWXY]### ie ##[CDGLTW]###### +ie ##[CDGKLMORSTW][DEHKLMNOSWXY]###### +ie ##[CDGLTW]##### +ie ##[CDGKLMORSTW][DEHKLMNOSWXY]##### +ie ##[CDGLTW]#### +ie ##[CDGKLMORSTW][DEHKLMNOSWXY]#### +ie ##[CDGLTW]### +ie ##[CDGKLMORSTW][DEHKLMNOSWXY]### is @@@## it @@###@@ kz ###@@@ -li @@### -li @@#### li @@##### +li @@#### +li @@### lt @@@### lu @@#### -lv @### -lv @#### -lv @@### lv @@#### +lv @@### +lv @#### +lv @### mc ???? -md @@@@# -md @@@@## md @@@@### -md [CK]@@# -md [CK]@@## md [CK]@@### +md @@@@## +md [CK]@@## +md @@@@# +md [CK]@@# me @@@@### mk @@####@@ mt @@@### -nl ####@@ -nl ###@@# -nl ##@@## -nl ##@@@# -nl ##@@@@ -nl #@@### -nl #@@@## -nl @###@@ -nl @##@@@ nl @@#### -nl @@###@ +nl ####@@ +nl ##@@## nl @@##@@ -nl @@@##@ nl @@@@## -no ##### +nl ##@@@@ +nl ##@@@# +nl #@@@## +nl @@###@ +nl @###@@ +nl @@@##@ +nl @##@@@ +nl #@@### +nl ###@@# no @@##### +no ##### pl @@##### pl @@####@ pl @@###@@ pl @@#@### pl @@#@@## +pl @@@@### +pl @@@##@@ +pl @@@#@## +pl @@@##@# +pl @@@#@@# +pl @@@@@## pl @@@##### pl @@@####@ pl @@@###@@ -pl @@@##@# -pl @@@##@@ -pl @@@#@## -pl @@@#@@# -pl @@@@### -pl @@@@@## +pt @@#### pt ####@@ pt ##@@## -pt ##@@@@ -pt @@#### pt @@##@@ pt @@@@## -ro @###@@@ -ro @##@@@ +pt ##@@@@ ro @@###@@@ ro @@##@@@ +ro @###@@@ +ro @##@@@ rs @@###@@ ru @###@@## ru @###@@### se @@@### si @@@@### sk @@###@@ -sm @### sm @#### +sm @### tr ##@#### tr ##@##### tr ##@@### tr ##@@#### tr ##@@@## ua @@####@@ -va [C][V]##### va [S][C][V]##### +va [C][V]##### From f10451882adb24934a1cd93efed6ed0fc18014ba Mon Sep 17 00:00:00 2001 From: steffkes Date: Sun, 12 Jun 2016 17:05:09 +0200 Subject: [PATCH 3/8] adding blank lines between countries --- runtime_data/postprocess/eu.patterns | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/runtime_data/postprocess/eu.patterns b/runtime_data/postprocess/eu.patterns index 41dc6b5..5a599b4 100644 --- a/runtime_data/postprocess/eu.patterns +++ b/runtime_data/postprocess/eu.patterns @@ -1,9 +1,12 @@ ad @#### + al @@###@@ + am ###@@### am ##@@### am ###@@## am ##@@## + at @@??? at @@???? at @@????? @@ -12,36 +15,56 @@ at @??? at @???? at @????? at @?????? + az ##@@### + ba [AEJKMOT]##[AEJKMOT]### ba [T][A]###### ba [T][T]###### ba ######[AEJKT] + be #@@@### be ###@@@ + bg @@####@@ bg @####@@ + by ####@@# + ch @@###### ch [APM]###### + cy @@@### + cz #@##### cz #@@#### + dk @@##### + ee ###@@@ + es ####@@@ es @####@@@ + fi @@@### + fr @@###@@ + gb @@##@@@ + ge @@###@@ + gi [G]####@ + gr @@@#### + hr @@###@@ hr @@####@@ hr @@###@ hr @@####@ + hu @@@### + ie ##[12][CDGLTW]###### ie ##[12][CDGKLMORSTW][DEHKLMNOSWXY]###### ie ##[12][CDGLTW]##### @@ -58,28 +81,40 @@ ie ##[CDGLTW]#### ie ##[CDGKLMORSTW][DEHKLMNOSWXY]#### ie ##[CDGLTW]### ie ##[CDGKLMORSTW][DEHKLMNOSWXY]### + is @@@## + it @@###@@ + kz ###@@@ + li @@##### li @@#### li @@### + lt @@@### + lu @@#### + lv @@#### lv @@### lv @#### lv @### + mc ???? + md @@@@### md [CK]@@### md @@@@## md [CK]@@## md @@@@# md [CK]@@# + me @@@@### + mk @@####@@ mt @@@### + nl @@#### nl ####@@ nl ##@@## @@ -94,8 +129,10 @@ nl @@@##@ nl @##@@@ nl #@@### nl ###@@# + no @@##### no ##### + pl @@##### pl @@####@ pl @@###@@ @@ -110,29 +147,40 @@ pl @@@@@## pl @@@##### pl @@@####@ pl @@@###@@ + pt @@#### pt ####@@ pt ##@@## pt @@##@@ pt @@@@## pt ##@@@@ + ro @@###@@@ ro @@##@@@ ro @###@@@ ro @##@@@ + rs @@###@@ + ru @###@@## ru @###@@### + se @@@### + si @@@@### + sk @@###@@ + sm @#### sm @### + tr ##@#### tr ##@##### tr ##@@### tr ##@@#### tr ##@@@## + ua @@####@@ + va [S][C][V]##### va [C][V]##### From d40717b7df855ca9a6366e4f98e99dc97491ae0f Mon Sep 17 00:00:00 2001 From: steffkes Date: Thu, 16 Jun 2016 10:22:54 +0200 Subject: [PATCH 4/8] add initial set of german license-plate patterns tl;dr license-plates are typically composed of three parts. the city/ region where the plate was issued (one to tree letters) followed by a random string (one to three letters too) and finally a random number (one to four digits). the larger the city or region the shorter the identifier they use. obviously having more cars to be registered, the random letters and numbers are often longer/larger in those areas. depending on the type of the car, implemented suffixes are: H: Historic Cars / Oldtimers E: Electronic Cards wikipedia has a very long and detailed article which tries to explain where all this comes from and why this is (still) needed: https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Germany --- runtime_data/postprocess/eu.patterns | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/runtime_data/postprocess/eu.patterns b/runtime_data/postprocess/eu.patterns index 5a599b4..b24ea47 100644 --- a/runtime_data/postprocess/eu.patterns +++ b/runtime_data/postprocess/eu.patterns @@ -39,6 +39,22 @@ cy @@@### cz #@##### cz #@@#### +de @@@@#### +de @@@@### +de @@@@## +de @@@@# +de @@@#### +de @@@### +de @@@## +de @@@# +de @@@@####[HE] +de @@@@###[HE] +de @@@@##[HE] +de @@@####[HE] +de @@@###[HE] +de @@@##[HE] +de @@@#[HE] + dk @@##### ee ###@@@ From 1efabe35bd50f3cdd64d031be0390a282940b431 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Fri, 17 Jun 2016 10:12:07 -0400 Subject: [PATCH 5/8] math function code fixes for Windows compatibility --- src/openalpr/edges/edgefinder.cpp | 3 ++- src/statedetection/line_segment.cpp | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/openalpr/edges/edgefinder.cpp b/src/openalpr/edges/edgefinder.cpp index bbe8dd7..55413f9 100644 --- a/src/openalpr/edges/edgefinder.cpp +++ b/src/openalpr/edges/edgefinder.cpp @@ -19,6 +19,7 @@ #include "edgefinder.h" #include "textlinecollection.h" +#include "support/timing.h" using namespace std; using namespace cv; @@ -325,7 +326,7 @@ namespace alpr { for (unsigned int x = 0; x < crop.cols; x += stride) { - contrast += pow( ((crop.at(y,x) / 255.0) - avg_intensity), 2.0f); + contrast += pow( ((crop.at(y,x) / 255.0) - avg_intensity), 2.0); } } contrast /= ((float) rows) * ((float)cols); diff --git a/src/statedetection/line_segment.cpp b/src/statedetection/line_segment.cpp index 68ee97d..030674b 100644 --- a/src/statedetection/line_segment.cpp +++ b/src/statedetection/line_segment.cpp @@ -124,6 +124,10 @@ Point LineSegment::midpoint() return Point(midX, midY); } +int round_int(double r) { + return (r > 0.0) ? (r + 0.5) : (r - 0.5); +} + LineSegment LineSegment::getParallelLine(float distance) { float diff_x = p2.x - p1.x; @@ -132,8 +136,8 @@ LineSegment LineSegment::getParallelLine(float distance) float dist_x = distance * cos(angle); float dist_y = -distance * sin(angle); - int offsetX = (int)round(dist_x); - int offsetY = (int)round(dist_y); + int offsetX = (int)round_int(dist_x); + int offsetY = (int)round_int(dist_y); LineSegment result(p1.x + offsetX, p1.y + offsetY, p2.x + offsetX, p2.y + offsetY); From cc24fe04065bbeed79bcb49db4005050c2814d47 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Fri, 17 Jun 2016 10:12:30 -0400 Subject: [PATCH 6/8] Re-added timeval for newer Windows compilers --- src/openalpr/support/timing.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openalpr/support/timing.h b/src/openalpr/support/timing.h index 9ac4727..a78bfa3 100644 --- a/src/openalpr/support/timing.h +++ b/src/openalpr/support/timing.h @@ -17,7 +17,7 @@ long tv_nsec; // Nanoseconds - [0, 999999999] }; #else - //#define timespec timeval + #define timespec timeval #endif #else #include From b49e694edb9cfbedb27d8044ff1fcf656ff89e68 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Fri, 17 Jun 2016 10:12:58 -0400 Subject: [PATCH 7/8] Updated export for Windows Go library --- src/bindings/go/openalprgo.cpp | 7 ------- src/bindings/go/openalprgo.h | 27 ++++++++++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/bindings/go/openalprgo.cpp b/src/bindings/go/openalprgo.cpp index e9465ad..8516155 100644 --- a/src/bindings/go/openalprgo.cpp +++ b/src/bindings/go/openalprgo.cpp @@ -7,13 +7,6 @@ extern "C" { -#if defined(_MSC_VER) - // Microsoft -#define OPENALPR_EXPORT __declspec(dllexport) -#else - // do nothing -#define OPENALPR_EXPORT -#endif //using namespace alpr; OPENALPR_EXPORT Alpr AlprInit(char* country, char* configFile, char* runtimeDir) { diff --git a/src/bindings/go/openalprgo.h b/src/bindings/go/openalprgo.h index 78a2551..e232386 100644 --- a/src/bindings/go/openalprgo.h +++ b/src/bindings/go/openalprgo.h @@ -1,17 +1,26 @@ + +#if defined(_MSC_VER) +// Microsoft +#define OPENALPR_EXPORT __declspec(dllexport) +#else +// do nothing +#define OPENALPR_EXPORT +#endif + #ifdef __cplusplus extern "C" { #endif typedef void* Alpr; - Alpr AlprInit(char* country, char* configFile, char* runtimeDir); - void SetDetectRegion(Alpr alpr, int detectRegion); - void SetTopN(Alpr alpr, int topN); - void SetDefaultRegion(Alpr alpr, char* region); - int IsLoaded(Alpr alpr); - void Unload(Alpr alpr); - char* RecognizeByFilePath(Alpr alpr, char* filePath); - char* RecognizeByBlob(Alpr alpr, char* imageBytes, int len); - char* GetVersion(); + OPENALPR_EXPORT Alpr AlprInit(char* country, char* configFile, char* runtimeDir); + OPENALPR_EXPORT void SetDetectRegion(Alpr alpr, int detectRegion); + OPENALPR_EXPORT void SetTopN(Alpr alpr, int topN); + OPENALPR_EXPORT void SetDefaultRegion(Alpr alpr, char* region); + OPENALPR_EXPORT int IsLoaded(Alpr alpr); + OPENALPR_EXPORT void Unload(Alpr alpr); + OPENALPR_EXPORT char* RecognizeByFilePath(Alpr alpr, char* filePath); + OPENALPR_EXPORT char* RecognizeByBlob(Alpr alpr, char* imageBytes, int len); + OPENALPR_EXPORT char* GetVersion(); #ifdef __cplusplus } #endif From a6b0e597b3a535c894f5cc8f4f8ecb0d0cc4023e Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Fri, 17 Jun 2016 10:14:17 -0400 Subject: [PATCH 8/8] Ignore unit tests for Windows --- src/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 53178f3..bf5a7f0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -62,6 +62,11 @@ IF (WIN32 AND WITH_DAEMON) SET(WITH_DAEMON OFF) ENDIF() +IF (WIN32 AND WITH_TESTS) + MESSAGE(WARNING "Skipping unit tests, as it is not supported in Windows.") + SET(WITH_TESTS OFF) +ENDIF() + IF(Tesseract_FRAMEWORK_PATH AND Leptonica_FRAMEWORK_PATH) MESSAGE(STATUS "Using Tesseract iOS framework: ${Tesseract_FRAMEWORK_PATH}") MESSAGE(STATUS "Using Leptonica iOS framework: ${Leptonica_FRAMEWORK_PATH}")