This application is used as reference code for developers to show how to use the C++ API and could be used to easily check the accuracy. The application accepts path to a JPEG/PNG/BMP file as input. This is not the recommended way to use the API. We recommend reading the data directly from the camera and feeding the SDK with the uncompressed YUV data without saving it to a file or converting it to RGB.
If you don't want to build this sample and is looking for a quick way to check the accuracy then, try our cloud-based solution at https://www.doubango.org/webapps/alpr/.
This sample is open source and doesn't require registration or license key.
The SDK is developed in C++11 and you'll need glibc 2.27+ on Linux and Microsoft Visual C++ 2015 Redistributable(x64) - 14.0.24123 (any later version is ok) on Windows. You most likely already have these dependencies on you machine as almost every program require it.
If you're planning to use OpenVINO, then you'll need Intel C++ Compiler Redistributable (choose newest). Please note that OpenVINO is packaged in the SDK as plugin and loaded (dlopen
) at runtime. The engine will fail to load the plugin if Intel C++ Compiler Redistributable is missing on your machine but the program will work as expected with Tensorflow as fallback. We highly recommend using OpenVINO to speedup the inference time. See benchmark numbers with/without OpenVINO at https://www.doubango.org/SDKs/anpr/docs/Benchmark.html#core-i7-windows.
To check if all dependencies are present:
- Windows x86_64: Use Dependency Walker on binaries/windows/x86_64/ultimateALPR-SDK.dll and binaries/windows/x86_64/ultimatePluginOpenVINO.dll if you're planning to use OpenVINO.
- Linux x86_64: Use
ldd <your-shared-lib>
on binaries/linux/x86_64/libultimate_alpr-sdk.so and binaries/linux/x86_64/libultimatePluginOpenVINO.so if you're planning to use OpenVINO.
- On x86-64, GPGPU acceleration is disabled by default. Check here for more information on how to enable it.
- We highly recommend enabling NVIDIA TensorRT (
--trt_enabled true
). Enabling TensorRT will disable OpenVINO. - On NVIDIA Jetson (AArch64), GPGPU acceleration is always enabled. Check here for more information.
If you don't want to build this sample by yourself then, use the pre-built C++ versions:
- Windows x86_64: recognizer.exe under binaries/windows/x86_64
- Linux x86_64: recognizer under binaries/linux/x86_64. Built on Ubuntu 18. You'll need to download libtensorflow.so as explained here.
- Linux aarch64: recognizer under binaries/linux/aarch64.
- Raspberry Pi: recognizer under binaries/raspbian/armv7l
- Android: check android folder
- NVIDIA Jetson: binaries/jetson/aarch64/recognizer or binaries/jetson_tftrt/aarch64/recognizer. You'll need to generate the optimized models as explained here.
On Windows, the easiest way to try this sample is to navigate to binaries/windows/x86_64 and run binaries/windows/x86_64/recognizer.bat. You can edit these files to use your own images and configuration options.
This sample contains a single C++ source file and is easy to build. The documentation about the C++ API is at https://www.doubango.org/SDKs/anpr/docs/cpp-api.html.
You'll need Visual Studio to build the code. The VS project is at recognizer.vcxproj. Open it.
- You will need to change the "Command Arguments" like the below image. Default value:
--image $(ProjectDir)..\..\..\assets\images\lic_us_1280x720.jpg --charset latin --assets $(ProjectDir)..\..\..\assets
- You will need to change the "Environment" variable like the below image. Default value:
PATH=$(VCRedistPaths)%PATH%;$(ProjectDir)..\..\..\binaries\windows\x86_64
You're now ready to build and run the sample.
Next command is a generic GCC command:
cd ultimateALPR-SDK/samples/c++/recognizer
g++ recognizer.cxx -O3 -I../../../c++ -L../../../binaries/<yourOS>/<yourArch> -lultimate_alpr-sdk -o recognizer
- You've to change
yourOS
andyourArch
with the correct values. For example, on Linux x86_64 they would be equal tolinux
andx86_64
respectively. - If you're cross compiling then, you'll have to change
g++
with the correct triplet. For example, on Linux host for Android ARM64 target the triplet would be equal toaarch64-linux-android-g++
.
To build the sample for Raspberry Pi you can either do it on the device itself or cross compile it on Windows, Linux or OSX machines. For more information on how to install the toolchain for cross compilation please check here.
cd ultimateALPR-SDK/samples/c++/recognizer
arm-linux-gnueabihf-g++ recognizer.cxx -O3 -I../../../c++ -L../../../binaries/raspbian/armv7l -lultimate_alpr-sdk -o recognizer
- On Windows: replace
arm-linux-gnueabihf-g++
witharm-linux-gnueabihf-g++.exe
- If you're building on the device itself: replace
arm-linux-gnueabihf-g++
withg++
to use the default GCC
After building the application you can test it on your local machine.
recognizer is a command line application with the following usage:
recognizer \
--image <path-to-image-with-to-process> \
[--assets <path-to-assets-folder>] \
[--parallel <whether-to-enable-parallel-mode:true/false>] \
[--rectify <whether-to-enable-rectification-layer:true/false>] \
[--charset <recognition-charset:latin/korean/chinese>] \
[--num_threads <number of threads:[1, inf]>] \
[--car_noplate_detect_enabled <whether-to-enable-detecting-cars-with-no-plate:true/false>] \
[--ienv_enabled <whether-to-enable-IENV:true/false>] \
[--openvino_enabled <whether-to-enable-OpenVINO:true/false>] \
[--openvino_device <openvino-device-to-use>] \
[--npu_enabled <whether-to-enable-NPU-acceleration:true/false>] \
[--trt_enabled <whether-to-enable-TensorRT-acceleration:true/false>] \
[--klass_lpci_enabled <whether-to-enable-LPCI:true/false>] \
[--klass_vcr_enabled <whether-to-enable-VCR:true/false>] \
[--klass_vmmr_enabled <whether-to-enable-VMMR:true/false>] \
[--klass_vbsr_enabled <whether-to-enable-VMMR:true/false>] \
[--tokenfile <path-to-license-token-file>] \
[--tokendata <base64-license-token-data>]
Options surrounded with [] are optional.
--image
Path to the image(JPEG/PNG/BMP) to process. You can use default image at ../../../assets/images/lic_us_1280x720.jpg.--assets
Path to the assets folder containing the configuration files and models. Default value is the current folder.--charset
Defines the recognition charset (a.k.a alphabet) value (latin, korean, chinese...). Default: latin.--num_threads
Number of threads to use. More info at https://www.doubango.org/SDKs/anpr/docs/Configuration_options.html#num-threads. Default: -1.--parallel
Whether to enabled the parallel mode. More info about the parallel mode at https://www.doubango.org/SDKs/anpr/docs/Parallel_versus_sequential_processing.html. Default: false.--rectify
Whether to enable the rectification layer. More info about the rectification layer at https://www.doubango.org/SDKs/anpr/docs/Rectification_layer.html. Always enabled on x86_64 CPUs. Default: false.--car_noplate_detect_enabled
Whether to detect and return cars with no plate. Default: false.--ienv_enabled
Whether to enable Image Enhancement for Night-Vision (IENV). More info about IENV at https://www.doubango.org/SDKs/anpr/docs/Features.html#image-enhancement-for-night-vision-ienv. Default: true for x86-64 and false for ARM.--openvino_enabled
Whether to enable OpenVINO. Tensorflow will be used when OpenVINO is disabled. Default: true.--openvino_device
Defines the OpenVINO device to use (CPU, GPU, FPGA...). More info at https://www.doubango.org/SDKs/anpr/docs/Configuration_options.html#openvino-device. Default: CPU."--npu_enabled
Whether to enable NPU acceleration (Amlogic, NXP...). More info at https://www.doubango.org/SDKs/anpr/docs/Configuration_options.html#npu-enabled. Default: true.--trt_enabled
Whether to enable TensorRT acceleration (NVIDIA GPUs). This will disable OpenVINO. More info at https://www.doubango.org/SDKs/anpr/docs/Configuration_options.html#trt-enabled. You must generate the plans as explained here before being able to use the TensorRT models. Default: false.--klass_lpci_enabled
Whether to enable License Plate Country Identification (LPCI). More info at https://www.doubango.org/SDKs/anpr/docs/Features.html#license-plate-country-identification-lpci. Default: false.--klass_vcr_enabled
Whether to enable Vehicle Color Recognition (VCR). More info at https://www.doubango.org/SDKs/anpr/docs/Features.html#vehicle-color-recognition-vcr. Default: false.--klass_vmmr_enabled
Whether to enable Vehicle Make Model Recognition (VMMR). More info at https://www.doubango.org/SDKs/anpr/docs/Features.html#vehicle-make-model-recognition-vmmr. Default: false.--klass_vbsr_enabled
Whether to enable Vehicle Body Style Recognition (VBSR). More info at https://www.doubango.org/SDKs/anpr/docs/Features.html#vehicle-body-style-recognition-vbsr. Default: false.--tokenfile
Path to the file containing the base64 license token if you have one. If not provided then, the application will act like a trial version. Default: null.--tokendata
Base64 license token if you have one. If not provided then, the application will act like a trial version. Default: null.
- For example, on Raspberry Pi you may call the recognizer application using the following command:
LD_LIBRARY_PATH=../../../binaries/raspbian/armv7l:$LD_LIBRARY_PATH ./recognizer \
--image ../../../assets/images/lic_us_1280x720.jpg \
--assets ../../../assets \
--charset latin \
--parallel false \
--rectify true
- On NVIDIA Jetson, you'll need to generate the models as explained here. Then, run:
LD_LIBRARY_PATH=../../../binaries/jetson/aarch64:$LD_LIBRARY_PATH ./recognizer \
--image ../../../assets/images/lic_us_1280x720.jpg \
--assets ../../../assets \
--charset latin \
--parallel false \
--rectify true
- On Linux x86_64, you may use the next command:
LD_LIBRARY_PATH=../../../binaries/linux/x86_64:$LD_LIBRARY_PATH ./recognizer \
--image ../../../assets/images/lic_us_1280x720.jpg \
--assets ../../../assets \
--charset latin \
--parallel false
- On Linux aarch64, you may use the next command:
LD_LIBRARY_PATH=../../../binaries/linux/aarch64:$LD_LIBRARY_PATH ./recognizer \
--image ../../../assets/images/lic_us_1280x720.jpg \
--assets ../../../assets \
--charset latin \
--parallel false
- On Windows x86_64, you may use the next command:
recognizer.exe ^
--image ../../../assets/images/lic_us_1280x720.jpg ^
--assets ../../../assets ^
--charset latin ^
--parallel false
Please note that if you're cross compiling the application then you've to make sure to copy the application and both the assets and binaries folders to the target device.