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 could be supplied through an object supporting the buffer protocol:
    #
    # 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.0-cp39-cp39-win_amd64.whl (33.5 MB view details)

Uploaded CPython 3.9 Windows x86-64

SimpleLPR-3.5.0-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.0-cp38-cp38-win_amd64.whl (33.5 MB view details)

Uploaded CPython 3.8 Windows x86-64

SimpleLPR-3.5.0-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.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: SimpleLPR-3.5.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 33.5 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.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 cb45242ea026f188611fa06455753ac8ef158463f4c0a7dcb4420dd46912d545
MD5 97cb45875d0d07e55403455b5aa73d07
BLAKE2b-256 1dcde54073a61f3fd8b9eba314173f486a76e36e36cd4377bfb9d4b8fd9b5248

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for SimpleLPR-3.5.0-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 9f2a2478583968290f4055a71c47104e7ff7183092cb53ced313fc6f5943ee33
MD5 4aad5b12be39567e45bf6e868adebd83
BLAKE2b-256 1a00b8f041d0509e11d164999f4cc713af431ed25ca16ce45dbdaacdff32f6e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: SimpleLPR-3.5.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 33.5 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.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 beb75b3909a29c37c71ee32bfc1aa6bfe4eb3af9c9afbe52028cd4fb32fba43f
MD5 0a4d53c3940301582e57a2b2f5226ce6
BLAKE2b-256 9985dedb1fb3ce2e88157b7ca50046825078b464b84846efd28a42c6677dd356

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for SimpleLPR-3.5.0-cp38-cp38-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 637dd0f18b57ca0e81e26ca5c3fe2d2f74f84b04875056bff63ee708226d0c62
MD5 0940bec416836d503ea7001d20fbac6b
BLAKE2b-256 3f70a3a8e6ec13679fda9c38dc150ecaa45ccd5e16dd40a75683a77ddc792f2b

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