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

Erlang example

https://github.com/bobhyun/TS-ANPR/tree/main/examples/Erlang/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 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
    # Tip: If erlang is not found, enable EPEL or use Erlang Solutions repo:
    # https://www.erlang.org/downloads
    
    # Or using kerl (recommended)
    curl -O https://raw.githubusercontent.com/kerl/kerl/master/kerl
    chmod a+x kerl
    ./kerl build 24.3 24.3
    ./kerl install 24.3 ~/erlang/24.3
    # Activate this Erlang in current shell
    . ~/erlang/24.3/activate
    # (To deactivate later) run: deactivate
    
  2. Install rebar3

    Windows:

    Download the latest rebar3 escript from GitHub:

    # Download latest rebar3 (compatible with Erlang/OTP 28+)
    Invoke-WebRequest -Uri "https://github.com/erlang/rebar3/releases/latest/download/rebar3" -OutFile "rebar3"
       
    # Place rebar3 in your project directory or move to a directory in your PATH
    

    Note: On Windows, rebar3 must be run using escript rebar3 <command> (not just rebar3 <command>).

    Linux:

    # Ubuntu/Debian
    sudo apt-get install rebar3
       
    # Or download latest from GitHub
    wget https://github.com/erlang/rebar3/releases/latest/download/rebar3
    chmod +x rebar3
    sudo mv rebar3 /usr/local/bin/
    
  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

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

3. Build and Run

  1. Navigate to the Erlang example directory

    cd examples/Erlang/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:

    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 the Erlang application

    Windows (use escript command):

    escript rebar3 compile
    

    Linux:

    rebar3 compile
    

    This will:

    • Compile Erlang modules (anpr.erl, tsanpr.erl) to _build/default/lib/anpr/ebin/
    • Copy the NIF library from priv/ to _build/default/lib/anpr/priv/
  4. Run the application

    # Non-interactive mode
    erl -pa _build/default/lib/anpr/ebin -noshell -eval "anpr:main()" -s init stop
    
    # Interactive mode
    erl -pa _build/default/lib/anpr/ebin
    1> anpr:main().
    

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: