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

Erlang サンプル

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

1. エンジンファイルのコピー

[注意] このサンプルでは、他のサンプルと共有するためにエンジンファイルを examples/bin/ディレクトリに展開します。ただし、実際のデプロイメントでは、通常、アプリケーションの実行ファイルが配置されているディレクトリにエンジンファイルをコピーします。

2. 前提条件

  1. Erlang/OTP のインストール(バージョン 24 以降推奨)

    Windows:

    # https://www.erlang.org/downloads からダウンロード
    # または 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
    # ヒント: パッケージが見つからない場合は EPEL を有効化、または Erlang Solutions リポジトリを利用:
    # https://www.erlang.org/downloads
    
    # または kerl を使用(推奨)
    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
    # 現在のシェルで有効化
    . ~/erlang/24.3/activate
    # 無効化するには: deactivate
    
  2. rebar3のインストール

    Windows:

    GitHubから最新のrebar3 escriptをダウンロード:

    # 最新のrebar3をダウンロード (Erlang/OTP 28+互換)
    Invoke-WebRequest -Uri "https://github.com/erlang/rebar3/releases/latest/download/rebar3" -OutFile "rebar3"
       
    # rebar3をプロジェクトディレクトリに配置するかPATH内のディレクトリに移動
    

    注意: Windowsではrebar3はescript rebar3 <コマンド>の形式で実行する必要があります(rebar3 <コマンド>ではありません)。

    Linux:

    # Ubuntu/Debian
    sudo apt-get install rebar3
       
    # またはGitHubから最新版をダウンロード
    wget https://github.com/erlang/rebar3/releases/latest/download/rebar3
    chmod +x rebar3
    sudo mv rebar3 /usr/local/bin/
    
  3. Cコンパイラのインストール(NIFビルドに必要)

    Windows:

    • C++開発ツールを含むVisual Studioをインストール、または
    • MinGW-w64をインストール:choco install mingw

    Linux:

    # Ubuntu/Debian
    sudo apt-get install build-essential
    
    # Fedora/CentOS
    sudo yum groupinstall "Development Tools"
    
  4. インストールの確認

    erl -version
    rebar3 version
    gcc --version  # WindowsでVisual Studioを使用する場合はcl.exe
    

3. ビルドと実行

  1. Erlangサンプルディレクトリに移動

    cd examples/Erlang/anpr
    
  2. NIF (Native Implemented Function) ライブラリのビルド

    Windows:

    「x64 Native Tools Command Prompt for VS」を開くか、vcvars64.batを実行後:

    build_nif.bat
    

    以下を実行します:

    • Erlangインストールを自動検出
    • MSVCを使用してc_src/tsanpr_nif.cをコンパイル
    • priv/tsanpr_nif.dllを生成

    Linux:

    make priv/tsanpr_nif.so
    

    以下を実行します:

    • gccを使用してc_src/tsanpr_nif.cをコンパイル
    • libdlを適切にリンクしてpriv/tsanpr_nif.soを生成
  3. Erlangアプリケーションのビルド

    Windows (escriptコマンドを使用):

    escript rebar3 compile
    

    Linux:

    rebar3 compile
    

    以下を実行します:

    • Erlangモジュール(anpr.erltsanpr.erl)を_build/default/lib/anpr/ebin/にコンパイル
    • priv/のNIFライブラリを_build/default/lib/anpr/priv/にコピー
  4. アプリケーションの実行

    # 非対話モード
    erl -pa _build/default/lib/anpr/ebin -noshell -eval "anpr:main()" -s init stop
    
    # 対話モード
    erl -pa _build/default/lib/anpr/ebin
    1> anpr:main().
    

4. 注意事項

5. 機能

6. API リファレンス

tsanpr モジュール

tsanprモジュールは以下の関数を提供します:

初期化:

コア関数:

認識オプション

出力形式

7. トラブルシューティング

ライブラリ読み込みの問題:

NIF の問題:

プラットフォーム固有の問題: