From 5e7d18e6b20c8d6341aac4eb7e3287a6f46f25e9 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 12 Mar 2015 19:25:43 -0400 Subject: [PATCH] Added arguments to Python test program --- src/bindings/python/test.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/bindings/python/test.py b/src/bindings/python/test.py index 9523632..1f96613 100644 --- a/src/bindings/python/test.py +++ b/src/bindings/python/test.py @@ -1,8 +1,24 @@ from openalpr import Alpr +from argparse import ArgumentParser +parser = ArgumentParser(description='OpenALPR Python Test Program') +parser.add_argument("-c", "--country", dest="country", action="store", default="us", + help="License plate Country" ) + +parser.add_argument("--config", dest="config", action="store", default="/etc/openalpr/openalpr.conf", + help="Path to openalpr.conf config file" ) + +parser.add_argument("--runtime_data", dest="runtime_data", action="store", default="/usr/share/openalpr/runtime_data", + help="Path to OpenALPR runtime_data directory" ) + +parser.add_argument('plate_image', help='License plate image file') + +options = parser.parse_args() + +alpr = None try: - alpr = Alpr("us", "/etc/openalpr/openalpr.conf", "/usr/share/openalpr/runtime_data") + alpr = Alpr(options.country, options.config, options.runtime_data) if not alpr.is_loaded(): print("Error loading OpenALPR") @@ -12,7 +28,7 @@ try: alpr.set_top_n(7) alpr.set_default_region("wa") alpr.set_detect_region(False) - jpeg_bytes = open("/storage/projects/alpr/samples/testing/car1.jpg", "rb").read() + jpeg_bytes = open(options.plate_image, "rb").read() results = alpr.recognize_array(jpeg_bytes) # Uncomment to see the full results structure