HyperLPR3 Documentation

repository·master·Indexed 27 days ago

https://github.com/szad670401/hyperlpr

A high-performance, cross-platform license plate recognition framework supporting Python, C++, and Android. It features a Python package installable via pip, a C/C++ SDK for Linux and Mac, and an Android SDK available via JitPack. The framework includes a command-line interface (CLI) for testing and a FastAPI-based REST API for image recognition via the /api/v1/rec endpoint.

Tokens
2.8K
Snippets
13
Records
22
Agent score
90%

What's inside HyperLPR3

  1. Build HyperLPR3 Android shared libraries

    master

    To cross-compile Android shared libraries, ensure the $ANDROID_NDK environment variable is set. Run the Android build script. The resulting libraries for arm64-v8a and armeabi-v7a will be placed in build/release_android/.

    sh command/build_release_android_share.sh
  2. Integrate HyperLPR3 into Android via JitPack

    master

    To quickly integrate HyperLPR3 into an Android project, add the JitPack repository and the HyperLPR3 dependency to your build.gradle files, then initialize and use the SDK.

    # Step 1: Add JitPack to your root build.gradle
    allprojects {
    	repositories {
    		...
    		maven { url 'https://jitpack.io' }
    	}
    }
    
    # Step 2: Add dependency to your app build.gradle
    dependencies {
    	implementation 'com.github.HyperInspire:hyperlpr3-android-sdk:1.0.3'
    }
    
    # Step 3: Use in your code
    HyperLPR3.getInstance().init(this, new HyperLPRParameter());
    
    // Recognize a plate from a bitmap
    Plate[] plates = HyperLPR3.getInstance().plateRecognition(bitmap, HyperLPR3.CAMERA_ROTATION_0, HyperLPR3.STREAM_BGRA);
  3. Compile HyperLPR3 Shared Library (Linux/Mac)

    master

    To compile the C++ shared library for Linux or Mac, ensure you have placed or linked third-party dependencies in the project root (same level as CMakeLists.txt).

    Note: When compiling C++ projects, OpenCV 4.0 and MNN 2.0 must be used.

    Run the build script:

    sh command/build_release_linux_share.sh

    Output is located in build/linux/install/hyperlpr3, containing include, lib, and resource directories.

  4. Build HyperLPR3 Linux/Mac shared libraries

    master

    To compile the C++ shared libraries for Linux or Mac, ensure third-party dependencies (OpenCV 4.0+ and MNN 2.0+) are placed in the project root. Run the provided build script.

    sh command/build_release_linux_share.sh
  5. Integrate HyperLPR3 in Android via JitPack

    master

    To quickly integrate the HyperLPR3 SDK into an Android project, add the JitPack repository and the dependency in your build.gradle files.

    Step 1: Add JitPack to root build.gradle

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

    Step 2: Add dependency

    dependencies {
        implementation 'com.github.HyperInspire:hyperlpr3-android-sdk:1.0.3'
    }

    Step 3: Usage Initialize the instance once (e.g., at app startup) and then call plateRecognition with a bitmap.

    // Initialization
    HyperLPR3.getInstance().init(this, new HyperLPRParameter());
    
    // exec recognition
    Plate[] plates = HyperLPR3.getInstance().plateRecognition(bitmap, HyperLPR3.CAMERA_ROTATION_0, HyperLPR3.STREAM_BGRA);
  6. Compile HyperLPR3 using Docker

    master

    You can use Docker to compile the Linux-x86 shared library. First, build the image, then use docker-compose to run the compilation.

    1. Build the image:
    docker build -t hyperlpr_build .
    1. Start compilation:
    docker-compose up build_linux_x86_shared_lib

    Output is located in build/linux.

    docker build -t hyperlpr_build .
    docker-compose up build_linux_x86_shared_lib
  7. Compile HyperLPR3 Shared Library (Android)

    master

    To compile the Android shared library, you must have the NDK installed and the $ANDROID_NDK environment variable configured. It is recommended to use NDK version 21.

    Run the build script:

    sh command/build_release_android_share.sh

    Output is located in build/release_android/ containing arm64-v8a (64-bit) and armeabi-v7a (32-bit) directories.

  8. Install HyperLPR3 via Python

    master

    Install the HyperLPR3 package using pip. This version supports Python 3 on Windows, Mac, Linux, and Raspberry Pi.

    Python Dependencies:

    • opencv-python (>3.3)
    • onnxruntime (>1.8.1)
    • fastapi (0.92.0)
    • uvicorn (0.20.0)
    • loguru (0.6.0)
    • python-multipart
    • tqdm
    • requests
    python -m pip install hyperlpr3
  9. Build the Linux x86 shared library using Docker Compose

    master
    You can use the provided Docker Compose configuration to build the Linux x86 shared library. This service mounts the current directory to /work inside the container and executes the build script command/build_release_linux_share.sh.
  10. Quick Test with CLI

    master

    Use the lpr3 command-line interface to test license plate recognition on images via URL or local file path. Use the -det flag to specify detection level (e.g., high).

    # image url
    lpr3 sample -src https://koss.iyong.com/swift/v1/iyong_public/iyong_2596631159095872/image/20190221/1550713902741045679.jpg
    
    # image path
    lpr3 sample -src images/test_img.jpg -det high