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

V Example

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

    Windows:

    # Using Scoop
    scoop install vlang
    
    # Or download pre-built binary from:
    # https://github.com/vlang/v/releases
    

    Linux:

    # Clone and build from source
    git clone https://github.com/vlang/v
    cd v
    make
    sudo ./v symlink
    
  2. Verify installation

    v version
    

3. How to Run

cd examples/V/anpr

# Run the ANPR example
v run .

Alternative methods:

# Compile and run separately
v .
./anpr        # Linux
anpr.exe      # Windows

# Compile with optimizations
v -prod .

4. Features

5. API Reference

TSANPR Module

The tsanpr module provides the following:

// Create TSANPR instance
pub fn new(library_path string) !TSANPR

// TSANPR methods
pub fn (mut t TSANPR) destroy()
pub fn (t &TSANPR) initialize(mode string) string
pub fn (t &TSANPR) read_file(img_file_name string, output_format string, options string) string
pub fn (t &TSANPR) read_pixels(pixels []u8, width u64, height u64, stride i64, pixel_format string, output_format string, options string) string

Recognition Options

Option Description
"" Single license plate recognition (default)
"vm" Recognize multiple license plates attached to vehicles
"vmb" Recognize multiple license plates (including motorcycles)
"vms" Recognize with surround detection
"dms" Detect multiple surrounding objects (vehicles)
"dmsr" Detect objects and recognize license plates
"dmsri<coords>" Recognize within Region of Interest

Output Formats

"text", "json", "yaml", "xml", "csv"

6. Implementation Notes

This example uses V’s dl module for dynamic library loading:

Dynamic Library Loading:

V Integration:

Pixel Buffer Processing: The readPixelBuffer function uses V’s built-in stbi module (stb_image wrapper) for image decoding. It loads the image, extracts raw RGB pixel data, and passes it to anpr_read_pixels() with the appropriate pixel format.

7. Troubleshooting

Compilation Issues:

Library Loading Issues:

Runtime Issues: