From b46b7d4c2b8e421a9cb7aef3467144e7527ce805 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Sun, 14 Feb 2016 16:01:13 -0500 Subject: [PATCH] Added set_country function to Python bindings --- src/bindings/python/openalpr/openalpr.py | 13 +++++++++++++ src/bindings/python/openalprpy.cpp | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/src/bindings/python/openalpr/openalpr.py b/src/bindings/python/openalpr/openalpr.py index 63981dd..439715c 100644 --- a/src/bindings/python/openalpr/openalpr.py +++ b/src/bindings/python/openalpr/openalpr.py @@ -78,6 +78,8 @@ class Alpr(): self._free_json_mem_func = self._openalprpy_lib.freeJsonMem + self._set_country_func = self._openalprpy_lib.setCountry + self._set_country_func.argtypes = [ctypes.c_void_p, ctypes.c_char_p] self._set_default_region_func = self._openalprpy_lib.setDefaultRegion self._set_default_region_func.argtypes = [ctypes.c_void_p, ctypes.c_char_p] @@ -168,6 +170,17 @@ class Alpr(): """ self._set_top_n_func(self.alpr_pointer, topn) + def set_country(self, country): + """ + This sets the country for detecting license plates. For example, + setting country to "us" for United States or "eu" for Europe. + + :param region: A unicode/ascii string (Python 2/3) or bytes array (Python 3) + :return: None + """ + country = _convert_to_charp(country) + self._set_country_func(self.alpr_pointer, country) + def set_default_region(self, region): """ This sets the default region for detecting license plates. For example, diff --git a/src/bindings/python/openalprpy.cpp b/src/bindings/python/openalprpy.cpp index 331df29..5a4d039 100644 --- a/src/bindings/python/openalprpy.cpp +++ b/src/bindings/python/openalprpy.cpp @@ -96,6 +96,14 @@ extern "C" { return membuffer; } + OPENALPR_EXPORT void setCountry(Alpr* nativeAlpr, char* ccountry) + { + // Convert strings from java to C++ and release resources + std::string country(ccountry); + + nativeAlpr->setCountry(country); + } + OPENALPR_EXPORT void setDefaultRegion(Alpr* nativeAlpr, char* cdefault_region) { // Convert strings from java to C++ and release resources