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

Gleam example

https://github.com/bobhyun/TS-ANPR/tree/main/examples/Gleam/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 Gleam (version 1.0 or later recommended)

    Windows:

    # Download from https://gleam.run/getting-started/installing/
    # Or using Scoop
    scoop install gleam
    

    Linux:

    # Download and install manually (x86_64)
    cd /tmp
    wget https://github.com/gleam-lang/gleam/releases/download/v1.14.0/gleam-v1.14.0-x86_64-unknown-linux-musl.tar.gz
    tar xzf gleam-v1.14.0-x86_64-unknown-linux-musl.tar.gz
    sudo mv gleam /usr/local/bin/
    
    # For ARM64 (aarch64)
    wget https://github.com/gleam-lang/gleam/releases/download/v1.14.0/gleam-v1.14.0-aarch64-unknown-linux-musl.tar.gz
    tar xzf gleam-v1.14.0-aarch64-unknown-linux-musl.tar.gz
    sudo mv gleam /usr/local/bin/
    
  2. Install Erlang/OTP (version 24 or later recommended)

    Windows:

    # Download from https://www.erlang.org/downloads
    # Or using Chocolatey
    choco install erlang
    

    Linux:

    # Ubuntu/Debian
    sudo apt-get update
    sudo apt-get install -y erlang
    
    # Oracle Linux / RHEL / CentOS (8/9+)
    sudo dnf install -y erlang || sudo yum install -y erlang
    
  3. Install C compiler (required for building NIF)

    Windows:

    • Install Visual Studio with C++ development tools, or
    • Install MinGW-w64: choco install mingw

    Linux:

    # Ubuntu/Debian
    sudo apt-get install build-essential
    
    # Fedora/CentOS
    sudo yum groupinstall "Development Tools"
    
  4. Verify installation

    gleam --version
    erl -version
    gcc --version  # or cl.exe on Windows with Visual Studio
    

3. Build and Run

  1. Navigate to the Gleam example directory

    cd examples/Gleam/anpr
    
  2. Build the NIF (Native Implemented Function) library

    Windows:

    Open “x64 Native Tools Command Prompt for VS” (or run vcvars64.bat), then:

    build_nif.bat
    

    This will:

    • Automatically detect your Erlang installation
    • Compile c_src/tsanpr_nif.c using MSVC
    • Create priv/tsanpr_nif.dll

    Linux:

    chmod +x build_nif.sh
    ./build_nif.sh
    # Or use make
    make priv/tsanpr_nif.so
    

    This will:

    • Compile c_src/tsanpr_nif.c using gcc
    • Create priv/tsanpr_nif.so with proper linking to libdl
  3. Build and run the Gleam application

    # Download dependencies
    gleam deps download
    
    # Build and run
    gleam run
    

    Or build separately:

    gleam build
    gleam run
    

4. Notes

5. Features

6. API Reference

tsanpr Module

The tsanpr module provides the following functions:

Initialization:

Core Functions:

Recognition Options

Output Formats

7. Troubleshooting

Library Loading Issues:

NIF Issues:

Compilation Issues:

Platform-Specific Issues: