Free C++ OCR API for Automatic License Plate Recognition
OpenALPR is a Leading Open Source C++ OCR Library that Enables Software Developers to Embed Automatic License Plate Recognition and Vehicle Recognition into Their Own C++ Apps.
What is OpenALPR?
OpenALPR is a powerful open-source Automatic License Plate Recognition (ALPR) library designed to detect and read vehicle license plates from images and videos. Built using C++ and leveraging OCR (Optical Character Recognition) through Tesseract, OpenALPR allows software developers to integrate vehicle recognition capabilities into applications for parking automation, security systems, toll booths, and smart city infrastructure. The library has included various features related to OCR operations, such as recognize license plates from images and videos, license plates recognition from live camera feeds, region-specific plate templates support, integration into custom applications, and many more.
OpenALPR is a highly flexible solution with bindings for other popular programming languages such as C#, Java, and Python, making it accessible to a wide range of developers. The library is available in both an open-source and a commercial version, with the open-source version being a popular choice for software developers and hobbyists looking to experiment with ALPR technology. The library is designed to be cross-platform and can be compiled and run on Linux, Windows, and macOS. Whether you're building a toll system, parking automation, or traffic surveillance platform, OpenALPR provides a reliable foundation for recognizing license plates with precision—all without needing cloud dependencies.
Getting Started with OpenALPR
The recommend way to install OpenALPR is using GitHub. Please use the following command for a smooth installation.
Install OpenALPR API via GitHub
git clone https://github.com/openalpr/openalpr.git
Install OpenALPR API via CMake
# Build with CMake
mkdir build
cd build
cmake ..
make
sudo make install
You can also install it manually; download the latest release files directly from GitHub repository.
Recognize License Plate from an Image via C++ API
The open source OpenALPR library has provided complete support for creating automatic license plate recognition system that uses OCR and computer vision to read vehicle registration plates from images and video streams. Software developers can use static images or real-time frames from a camera using OpenCV. The following code snippet demonstrates the basic workflow of using the OpenALPR C++ library. It initializes the library, recognizes a license plate from an image file, and then prints the results along with their confidence scores.
How to Detect License Plates from an Image using C++ API?
from openalpr import Alpr
alpr = Alpr("us", "/path/to/openalpr.conf", "/path/to/runtime_data")
if not alpr.is_loaded():
print("Error loading OpenALPR")
sys.exit(1)
results = alpr.recognize_file("/path/to/image.jpg")
i = 0
for plate in results['results']:
i += 1
print("Plate #%d" % i)
print(" %12s %12s" % ("Plate", "Confidence"))
for candidate in plate['candidates']:
prefix = "-"
if candidate['matches_template']:
prefix = "*"
print(" %s %12s%12f" % (prefix, candidate['plate'], candidate['confidence']))
# Call when completely done to release memory
alpr.unload()
Real-time Processing & Vehicle Recognition via C++
The open source OpenALPR library is optimized for performance and can process video streams in real-time, making it suitable for applications that require immediate feedback. Beyond just reading license plates, the OpenALPR library can also identify the make, model, and color of a vehicle, providing a more complete set of data for analysis.
Country-Specific Recognition Support
The OpenALPR library has included support for load and recognizing Country-Specific license plates inside C++ applications. The library has included license plates from over 60 countries, and it can even identify the issuing state for all 50 US states, as well as for Canada and Mexico.