Added arguments to Python test program

This commit is contained in:
Matt Hill
2015-03-12 19:25:43 -04:00
parent 26e3ef26dc
commit 5e7d18e6b2

View File

@@ -1,8 +1,24 @@
from openalpr import Alpr 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: 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(): if not alpr.is_loaded():
print("Error loading OpenALPR") print("Error loading OpenALPR")
@@ -12,7 +28,7 @@ try:
alpr.set_top_n(7) alpr.set_top_n(7)
alpr.set_default_region("wa") alpr.set_default_region("wa")
alpr.set_detect_region(False) 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) results = alpr.recognize_array(jpeg_bytes)
# Uncomment to see the full results structure # Uncomment to see the full results structure