Skip to the content.
English 한국어 日本語 Tiếng Việt

Pony Example

https://github.com/bobhyun/TS-ANPR/tree/main/examples/Pony/anpr

1. Copying the Engine Files

[Note] In this example, the engine file is extracted to the examples/bin/ directory to share it with other examples. However, for actual deployment, the engine file is typically copied to the directory where the application’s executable file is located.

2. Prerequisites

  1. Install Pony compiler

    Ubuntu/Debian:

    # Using ponyup (recommended)
    curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/ponylang/ponyup/latest-release/ponyup-init.sh | sh
    source ~/.profile
    ponyup update ponyc release
    

    macOS:

    brew install ponyc
    

    Windows:

    # Using Chocolatey
    choco install ponyc
    
    # Or download from https://github.com/ponylang/ponyc/releases
    
  2. Install C compiler (GCC or Clang)

    Ubuntu/Debian:

    sudo apt-get install build-essential
    

    macOS:

    xcode-select --install
    

    Windows:

    • Install Visual Studio Build Tools or MinGW-w64
  3. Verify installation

    ponyc --version
    gcc --version
    

3. How to Run

cd examples/Pony/anpr

# Build and run
make run

# Build only
make

# Build release version
make release

# Clean build artifacts
make clean

4. Features

5. API Reference

TSANPR Class

class TSANPR
  new create(library_path: String) ?
  fun ref initialize(mode: String): String
  fun ref read_file(img_file_name: String, output_format: String, options: String): String
  fun ref read_pixels(pixels: Array[U8] val, width: U64, height: U64, stride: I64,
                     pixel_format: String, output_format: String, options: String): String

Recognition Options

Option Description
"" Single license plate recognition (default)
"vm" Recognize multiple license plates attached to vehicles
"vmb" Recognize multiple license plates (including motorcycles)
"vms" Recognize with surround detection
"dms" Detect multiple surrounding objects (vehicles)
"dmsr" Detect objects and recognize license plates
"dmsri<coords>" Recognize within Region of Interest

Output Formats

"text", "json", "yaml", "xml", "csv"

6. Implementation Notes

This example uses C wrappers to handle dynamic library loading and image processing:

Dynamic Library Loading (tsanpr_wrapper.c):

Image Processing (image_loader.c):

The Pony code calls the C wrapper functions via FFI, which in turn call the dynamically loaded TSANPR library functions.