Skip to main content

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

SimpleLPR-3.5.2-cp39-cp39-win_amd64.whl (34.3 MB view details)

Uploaded CPython 3.9 Windows x86-64

SimpleLPR-3.5.2-cp39-cp39-manylinux_2_31_x86_64.whl (94.1 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.31+ x86-64

SimpleLPR-3.5.2-cp38-cp38-win_amd64.whl (34.3 MB view details)

Uploaded CPython 3.8 Windows x86-64

SimpleLPR-3.5.2-cp38-cp38-manylinux_2_31_x86_64.whl (94.1 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.31+ x86-64

File details

Details for the file SimpleLPR-3.5.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: SimpleLPR-3.5.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 34.3 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for SimpleLPR-3.5.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 fbe67bce1dbc6a7af8849c416f29ac1252b8c94e432b8cceb2ec62909fdbf867
MD5 4677b9c3789be5a4888e370437eb31f9
BLAKE2b-256 a5af19c260f50eb368c11e98d2a8ca88bfc6f163a8b071233a2ae0c5132f109a

See more details on using hashes here.

File details

Details for the file SimpleLPR-3.5.2-cp39-cp39-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for SimpleLPR-3.5.2-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 c9263fe20e9a302244d397ad758bd5bf775883eaf6514c06ba4bcbbd52494b76
MD5 00ae3e642ee2b71f96bd6de20287a9de
BLAKE2b-256 15598e740bac27dbd245f52a4b0380e561bfc79e7bab1c0d5b3255c21aba6a66

See more details on using hashes here.

File details

Details for the file SimpleLPR-3.5.2-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: SimpleLPR-3.5.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 34.3 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for SimpleLPR-3.5.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 666efc615381397bc14ed6290e7b63cea3314cf9740e4204c7508352331afa23
MD5 6339c96236ae38b4195555061e489870
BLAKE2b-256 44f6a71108a455e230131a43ac4d8a6d6dfe3f7777a85f41e68c66c7f862d17b

See more details on using hashes here.

File details

Details for the file SimpleLPR-3.5.2-cp38-cp38-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for SimpleLPR-3.5.2-cp38-cp38-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 b3e132f4d617c615af8529c8205df1e960fabc05d17b5f55eb89de7bd256fca3
MD5 4ee7e6d805902b42eeed1ad33c7fbdb7
BLAKE2b-256 0be822cb68d42e188cdf72d55cce236f62e89466609a84dff55ec3f2b39216d1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page