| English | 한국어 | 日本語 | Tiếng Việt |
Fortran example
https://github.com/bobhyun/TS-ANPR/tree/main/examples/Fortran/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.
- For Windows x86 64-bit
Extract the engine file to the
examples/bin/windows-x86_64directory7z x tsanpr*-windows-x86_64.7z - For Windows x86 32-bit
Extract the engine file to the
examples/bin/windows-x86directory7z x tsanpr*-windows-x86.7z - For Linux x86 64-bit
Extract the engine file to the
examples/bin/linux-x86_64directorytar xvf tsanpr-linux-x86_64.tar.xz - For Linux arm 64-bit
Extract the engine file to the
examples/bin/linux-aarch64directorytar xvf tsanpr-linux-aarch64.tar.xz - Directory structure
examples ├── bin │ ├─── windows-x86_64 # engine directory for Windows (x86_64) │ │ ├── tsanpr.dll │ │ ├── tsanpr-2505M.eon │ │ └── tshelper.exe │ ├─── windows-x86 # engine directory for Windows (x86) │ │ ├── tsanpr.dll │ │ ├── tsanpr-2505M.eon │ │ └── tshelper.exe │ ├── linux-x86_64 # engine directory for Linux (x86_64) │ │ ├── libtsanpr.so │ │ ├── tsanpr-2505M.eon │ │ └── tshelper │ └── linux-aarch64 # engine directory for Linux (arm64) │ ├── libtsanpr.so │ ├── tsanpr-2505M.eon │ └── tshelper ├── img # image directory └── Fortran └── anpr # project directory ├── src # source directory │ ├── anpr.f90 │ └── tsanpr_module.f90 ├── build # build output directory (created by make) └── Makefile
2. Prerequisites
-
Install Fortran compiler and build tools
Ubuntu/Debian:
sudo apt-get update sudo apt-get install gfortran build-essentialCentOS/RHEL/Fedora:
# CentOS/RHEL 7 sudo yum install gcc-gfortran make # CentOS/RHEL 8+ / Fedora sudo dnf install gcc-gfortran makeWindows (MinGW/MSYS2):
# Install MSYS2 first, then: pacman -S mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-make -
Verify installation
gfortran --version make --version
3. How to Build
-
Navigate to the Fortran example directory
cd Fortran/anpr -
Build the example
make all -
Clean build artifacts (if needed)
make clean
4. How to Run
-
Run
anprexample./build/anprOr on Windows:
build/anpr.exe
5. Notes
- This Fortran implementation provides the same functionality as other language examples
- Uses modern Fortran 2008 standard with ISO C binding for interoperability
-
Dynamic library loading is handled through system-specific APIs (dlopen on Unix, LoadLibrary on Windows)
- Pixel buffer processing is simplified in this example - a full implementation would require integration with an image processing library
- Cross-platform compilation is supported through preprocessor directives
6. Features
- File-based recognition: Process image files directly
- Encoded image processing: Handle encoded image data (JPEG, PNG, etc.)
- Pixel buffer processing: Process raw pixel data (simplified implementation)
- Multiple output formats: Support for text, JSON, YAML, XML, and CSV output
- Multiple recognition modes: Single plate, multiple plates, vehicle detection, etc.
- Region of Interest (RoI): Process specific areas within images
- Multi-country support: Support for different license plate formats (KR, JP, VN, etc.)
- Cross-platform compatibility: Windows and Linux support
7. API Reference
TSANPR Module
The tsanpr_module provides the following types and procedures:
Types:
tsanpr_handle: Handle for TSANPR library instance
Initialization:
tsanpr_init(tsanpr, library_path, status): Initialize TSANPR with library pathtsanpr_cleanup(tsanpr): Clean up TSANPR resources
Core Functions:
tsanpr_initialize(tsanpr, mode, error_msg, status): Initialize the ANPR enginetsanpr_read_file(tsanpr, img_file_name, output_format, options, result, status): Process image filetsanpr_read_pixels(tsanpr, pixels, width, height, stride, pixel_format, output_format, options, result, status): Process pixel data
Recognition Options
"": Single license plate recognition (default)"vm": Recognize multiple license plates attached to vehicles"vmb": Recognize multiple license plates attached to vehicles (including motorcycles)"vms": Recognize multiple license plates attached to vehicles with surround detection"dms": Recognize multiple surrounding objects (vehicles)"dmsr": Recognize multiple surrounding objects (vehicles) and license plates"dmsri<coordinates>": Recognize within Region of Interest
Output Formats
"text": Plain text output"json": JSON format output"yaml": YAML format output"xml": XML format output"csv": CSV format output