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

C++ Example

https://github.com/bobhyun/TS-ANPR/tree/main/examples/C%2B%2B/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. How to Build and Run

  1. Windows 64bit (MSVC, x64 Native Tools Command Prompt)

    mkdir build\windows-x86_64
    cd build\windows-x86_64
    
    # Install vcpkg
    git clone https://github.com/microsoft/vcpkg.git
    cd vcpkg
    bootstrap-vcpkg.bat
    
    # Install opencv
    vcpkg install opencv:x64-windows
    cd ..
    
    cmake ../.. -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake
    cmake --build . --config Debug   # Debug build
    cmake --build . --config Release # Release build
    cd ..\..
    
    # Run this if non-ASCII characters appear garbled on Windows.
    chcp 65001
    
    # Run
    bin\windows-x86_64\Debug\anpr.exe
    bin\windows-x86_64\Release\anpr.exe
    
  2. Windows 32bit (MSVC, x86 Native Tools Command Prompt)

    mkdir build\windows-x86
    cd build\windows-x86
    
    # Install vcpkg
    git clone https://github.com/microsoft/vcpkg.git
    cd vcpkg
    bootstrap-vcpkg.bat
    
    # Install opencv
    vcpkg install opencv:x86-windows
    cd ..
    
    cmake ../.. -G "Visual Studio 17 2022" -A Win32  -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake
    cmake --build . --config Debug   # Debug build
    cmake --build . --config Release # Release build
    cd ..\..
    
    # Run this if non-ASCII characters appear garbled on Windows.
    chcp 65001
    
    # Run
    bin\windows-x86\Debug\anpr.exe
    bin\windows-x86\Release\anpr.exe
    
  3. Windows MinGW64 (MSYS2)

    # install dependency
    pacman -Syu
    pacman -S mingw-w64-x86_64-opencv
    
    mkdir -p build/mingw-x86_64
    cd build/mingw-x86_64
    
    # build
    cmake ../.. -G "MinGW Makefiles"
    mingw32-make
    
  4. Windows MinGW32 (MSYS2)

    # install dependency
    pacman -Syu
    pacman -S mingw-w64-i686-opencv
    
    mkdir -p build/mingw-x86
    cd build/mingw-x86
    
    # build
    cmake ../.. -G "MinGW Makefiles"
    mingw32-make
    
  5. Linux x86_64

    # install dependency
    # Debian / Ubuntu Linux
    sudo apt install libopencv-dev
    
    # Oracle Linux / RedHat (RHEL) / CentOS
    sudo yum install epel-release
    
    mkdir -p build/linux-x86_64
    cd build/linux-x86_64
    
    # Debug build
    cmake ../.. -DCMAKE_BUILD_TYPE=Debug
    make
    
    # Release build
    cmake ../.. -DCMAKE_BUILD_TYPE=Release
    make
    
  6. Linux aarch64 (ARM64)

    # install dependency
    # Debian / Ubuntu Linux
    sudo apt install libopencv-dev
    # Oracle Linux / RedHat (RHEL) / CentOS
    sudo yum install epel-release
    
    mkdir -p build/linux-aarch64
    cd build/linux-aarch64
    
    # Debug build
    cmake ../.. -DCMAKE_BUILD_TYPE=Debug
    make
    
    # Release build
    cmake ../.. -DCMAKE_BUILD_TYPE=Release
    make
    

3. How to Run

# Windows MSVC 64-bit
bin\windows-x86_64\Debug\anpr.exe
bin\windows-x86_64\Release\anpr.exe

# Windows MSVC 32-bit
bin\windows-x86\Debug\anpr.exe
bin\windows-x86\Release\anpr.exe

# Windows MinGW64
bin/mingw-x86_64/anpr

# Windows MinGW32
bin/mingw-x86/anpr

# Linux x86_64
bin/linux-x86_64/anpr

# Linux aarch64
bin/linux-aarch64/anpr