SimpleLPR License Plate Recognition (LPR/ANPR) library.
Project description
SimpleLPR is a software component for vehicle license plate recognition. It has a very simple programming interface that allows applications to supply a path to an image or a buffer in memory and returns the detected license plate text and its location in the input image. It can be used from C++, .NET-enabled programming languages, or Python.
Typical detection rates range between 85% and 95%, provided the license plates are in good condition, free of obstructions, and the text height is at least 20 pixels.
You can submit your questions/issues/bug reports/feedback to support@warelogic.com
Integration is simple and straightforward, as demonstrated in the following example:
import sys, os, argparse
# Import the SimpleLPR extension.
import simplelpr
# Lists all available countries.
def list_countries(eng):
print('List of available countries:')
for i in range(0, eng.numSupportedCountries):
print(eng.get_countryCode(i))
def analyze_file(eng, country_id, img_path, key_path):
# Enables syntax verification with the selected country.
eng.set_countryWeight(country_id, 1)
eng.realizeCountryWeights()
# If provided, supplies the product key as a file.
if key_path is not None:
eng.set_productKey(key_path)
# Alternatively, it could also be supplied from a buffer in memory:
#
# with open(key_path, mode='rb') as file:
# key_content = file.read()
# eng.set_productKey( key_content )
# Create a Processor object. Every working thread should use its own processor.
proc = eng.createProcessor()
# Enable the plate region detection and crop to plate region features.
proc.plateRegionDetectionEnabled = True
proc.cropToPlateRegionEnabled = True
# Looks for license plate candidates in an image in the file system.
cds = proc.analyze(img_path)
# Alternatively, the input image can be supplied through an object supporting the buffer protocol:
#
# fh = open(img_path, 'rb')
# try:
# ba = bytearray(fh.read())
# finally:
# fh.close()
# cds = proc.analyze(ba)
#
# or
#
# import numpy as np
# from PIL import Image
#
# im = Image.open(img_path)
# npi = np.asarray(im)
# cds = proc.analyze(npi)
#
# or
#
# import cv2
#
# im = cv2.imread(img_path)
# cds = proc.analyze(im)
# Show the detection results.
print('Number of detected candidates:', len(cds))
for cand in cds:
print('-----------------------------')
print('darkOnLight:', cand.darkOnLight, ', plateDetectionConfidence:', cand.plateDetectionConfidence)
print('boundingBox:', cand.boundingBox)
print('plateRegionVertices:', cand.plateRegionVertices)
for cm in cand.matches:
print('\tcountry:', "'{:}'".format(cm.country), ', countryISO:', "'{:}'".format(cm.countryISO),
', text:', "'{:}'".format(cm.text), ', confidence:', '{:.3f}'.format(cm.confidence))
for e in cm.elements:
print('\t\tglyph:', "'{:}'".format(e.glyph), ', confidence:', '{:.3f}'.format(e.confidence),
', boundingBox:', e.boundingBox)
def main():
try:
# The simplelpr extension requires 64-bit Python 3.8 or 3.9
if sys.version_info[0:2] != (3, 8) and sys.version_info[0:2] != (3, 9):
raise RuntimeError('This demo requires either Python 3.8 or 3.9')
if len(sys.argv) == 1:
sys.argv.append('--help')
# Create a SimpleLPR engine.
setupP = simplelpr.EngineSetupParms()
eng = simplelpr.SimpleLPR(setupP)
print("SimpleLPR version:",
"{:}.{:}.{:}.{:}".format(eng.versionNumber.A, eng.versionNumber.B, eng.versionNumber.C,
eng.versionNumber.D))
# Parse the command line arguments.
parser = argparse.ArgumentParser(description='SimpleLPR on Python demo application')
subparsers = parser.add_subparsers(dest='command', help='Sub-command help')
subparsers.add_parser('list', help='List all available countries')
parser_analyze = subparsers.add_parser('analyze', help='Looks for license plate candidates in an image')
parser_analyze.add_argument('country_id', type=str, help='Country string identifier')
parser_analyze.add_argument('img_path', type=str, help='Path to the image file')
parser_analyze.add_argument('key_path',
type=str,
nargs='?',
help="Path to the registration key file. In case you need to extend the 60-day "
"evaluation period you can send an e-mail to 'support@warelogic.com' to "
"request a trial key")
args = parser.parse_args()
if args.command == 'list':
# List countries.
list_countries(eng)
elif args.command == 'analyze':
# Analyze an image in the file system.
analyze_file(eng, args.country_id, args.img_path, args.key_path)
else:
# Shouldn't occur.
raise RuntimeError('Unknown command')
except Exception as e:
print('An exception occurred: {}'.format(e))
if __name__ == '__main__':
main()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for SimpleLPR-3.5.3-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fea2838ab5ea0cf0c22c3cd25adf542c8beb56a200f87e13f5539b7c3726d1a9 |
|
MD5 | 4d67300c39692a39ede7c2944d8cd7b6 |
|
BLAKE2b-256 | 6fcfd4aa12af892c26140076e5eac9bee9e760c1bff788a69cc75437abd4eb35 |
Hashes for SimpleLPR-3.5.3-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 722bba2514af1b8cd680143a89b22294ca0bb58c4cec784837453bdc46c7f1db |
|
MD5 | 0e86e9ee9e56fe785292fb5ffa10ac10 |
|
BLAKE2b-256 | d00484406fdb319cc086e54c35860e78f32a77b333af68e00896822ef2ceed38 |
Hashes for SimpleLPR-3.5.3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa717e6caae8ac858698489eac89c8ddd04dcdfd331d3d2f2f7f8e271834aa03 |
|
MD5 | 646a2c600499fe217a6faf1745c3dc43 |
|
BLAKE2b-256 | 1d58632025066aa03089a8cb218c8a7b811f0c557c56ffeccc5734ae68a4669d |
Hashes for SimpleLPR-3.5.3-cp38-cp38-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f6bc797be7d267cf129b0891ef824299b8bbc4029b88f9a02e8161e650bd5be |
|
MD5 | 94352f86382116bccba4e450f81c8932 |
|
BLAKE2b-256 | 67a616005b6ba328ebb3da209bd9c6ffcb8fd05342aa57a1871469cca2bac980 |