This application is used as reference code for developers to show how to use the Python bindings for 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 Visual C++ Redistributable for Visual Studio 2015 (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.
By default GPGPU acceleration is disabled. Check here for more information on how to enable it.
You must build the Python extension before trying to run this sample. More information on how to build the extension could be found here
recognizer.py
is a Python command line application with the following usage:
recognizer.py \
--image <path-to-image-with-plate-to-process> \
[--assets <path-to-assets-folder>] \
[--parallel <whether-to-enable-parallel-mode:True/False>] \
[--charset <recognition-charset:latin/korean/chinese>] \
[--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>] \
[--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-VBSR: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.--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.--charset
Defines the recognition charset (a.k.a alphabet) value (latin, korean, chinese...). Default: latin.--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.--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.
Before trying the next examples you have to navigate to the folder containing the binaries:
cd ultimateALPR-SDK/binaries/<<os>>/<<arch>>
For example:
- On Windows x86_64: ultimateALPR-SDK/binaries/windows/x86_64
- On Linux x86_64: ultimateALPR-SDK/binaries/linux/x86_64
- On Linux aarch64: ultimateALPR-SDK/binaries/linux/aarch64
- On Raspbian arm32 : ultimateALPR-SDK/binaries/raspbian/armv7l
- ... you got the idea
- On Linux and Raspberry Pi, you may use the next command:
PYTHONPATH=$PYTHONPATH:.:../../../python \
LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH \
python ../../../samples/python/recognizer/recognizer.py --image ../../../assets/images/lic_us_1280x720.jpg --assets ../../../assets
Before trying to run the program on Linux x86_64 you'll need to download libtensorflow.so as explained here.
- On Windows x86_64, you may use the next command:
setlocal
set PYTHONPATH=%PYTHONPATH%;.;../../../python
set PATH=%PATH%;%~dp0
python ../../../samples/python/recognizer/recognizer.py --image ../../../assets/images/lic_us_1280x720.jpg --assets ../../../assets
endlocal
If you want to make your life easier run python_recognizer.bat to test on Windows. You can edit the file using Notepad to change the parameters.
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.
If you get undefined symbol: PyUnicode_FromFormat
error message, then make sure you're using Python 3 and same version as the one used to buid the extension. We tested the code on version 3.6.9 (Windows 8), 3.6.8 (Ubuntu 18) and 3.7.3 (Raspbian Buster). Run python --version
to print your Python version. You may use python3
instead of python
to make sure you're using version 3.