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

MATLAB/Octave example

https://github.com/bobhyun/TS-ANPR/tree/main/examples/MATLAB/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

Option A: MATLAB (Commercial)

  1. Install MATLAB (R2018b or later recommended)

    Windows:

    • Download and install MATLAB from https://www.mathworks.com/downloads/
    • Requires a valid license

    Linux:

    • Download and install MATLAB from https://www.mathworks.com/downloads/
    • Requires a valid license
  2. Configure C Compiler
    mex -setup
    
  3. Verify installation
    version
    mex -setup
    

Option B: GNU Octave (Free, Open Source)

GNU Octave is a free alternative to MATLAB with mostly compatible syntax.

Windows:

# Using winget
winget install GNU.Octave

# Or download from https://octave.org/download

Linux (Ubuntu/Debian):

sudo apt-get update
sudo apt-get install -y octave octave-image liboctave-dev

Linux (Fedora/RHEL):

sudo dnf install -y octave octave-image octave-devel

Verify installation:

octave --version

3. How to Build MEX

The MEX file is automatically built on first run. To build manually:

With MATLAB

cd examples/MATLAB/anpr/src/mex
build_mex

With GNU Octave

cd examples/MATLAB/anpr/src/mex
octave --eval "build_mex"

4. How to Run

With MATLAB

  1. Navigate to the source directory
    cd examples/MATLAB/anpr/src
    
  2. Start MATLAB and run the example
    % Run the main ANPR example
    anpr
    

With GNU Octave

Windows:

cd examples\MATLAB\anpr\src
octave --eval "anpr"

Linux:

cd examples/MATLAB/anpr/src
octave --eval "anpr"

Or run interactively:

octave
cd examples/MATLAB/anpr/src
anpr

5. Interactive Usage

% Add paths
addpath('mex');

% Initialize TSANPR
engine_path = '../../../bin/windows-x86_64/tsanpr.dll';  % Windows
% engine_path = '../../../bin/linux-x86_64/libtsanpr.so';  % Linux

tsanpr = TSANPR(engine_path);

% Initialize engine
error_msg = tsanpr.anpr_initialize('text;country=KR');
if ~isempty(error_msg)
    fprintf('Error: %s\n', error_msg);
end

% Process an image
result = tsanpr.anpr_read_file('../../../img/KR/licensePlate.jpg', 'json', '');
fprintf('Result: %s\n', result);

6. Notes

7. Features

8. API Reference

TSANPR Class

Constructor:

Core Methods:

Static Methods:

Recognition Options

Output Formats

9. Troubleshooting

MEX Build Issues:

Library Loading Issues:

Platform-Specific Issues: