License plate recognition has a wide range of applications in the highway, such as our common electronic toll collection (ETC) system and the detection of traffic violation vehicles, in addition to residential or underground garage access control will also be used, basically all the need for vehicle identity detection will be used.

Vehicle License Plate Recognition system is an application of computer video image Recognition technology in Vehicle License Plate Recognition. Usually, a License Plate Recognition system mainly includes the following four parts:

Vehicle image acquisition license plate location license plate character segmentation license plate character recognition let’s look at the description of license plate recognition technology in encyclopedia:

License plate recognition technology requirements to be able to exercise the car license plate extraction and recognition from the complex background, through the license plate extraction, image preprocessing, feature extraction, license plate character recognition technology, such as identification of vehicle number, color and other information, the technical level of the latest the rate can reach 99.7% for the letters and Numbers, Chinese character recognition rate can reach 99%. Whether you are a Python professional or a hobby, remember that project development experience is always core. If you are short of new project practice or don’t have an intensive Python tutorial, go to the Python tutorial. Skirt: seven clothes clothes 977 bar and five (number homonym) conversion can be found, there are many new tutorial projects, but also can communicate with the old driver for advice!

Here we do not do too complex vehicle dynamic recognition, only to demonstrate the recognition of license plate information from the image, the realization of license plate recognition function is roughly divided into two ways, one is to write their own code, the other is to achieve with the help of a third party API interface.

If we want to manually code license plate recognition in Python, we can use some Python libraries, such as: OpenCV, TensorFlow, etc., each function point needs to be coded by ourselves, so it will be relatively complicated. On the other hand, if we want to ensure the accuracy of recognition, we may need to do a lot of experiments, that is to say, it will take more time.

Third-party interface Now there are some third-party platform to realize the function of the license plate recognition, and they provide the API interface, you just need to invoke the interface they provide, we implement this way is relatively simple, and often interface provider provides the interface functions also basic can guarantee the accuracy, the reason is very simple, If the interface function is too bad, one is to face yourself, and there is basically no one to use it, which will lose the value provided by the interface. In addition, the third-party interface may charge a certain fee. Therefore, if we implement it concretely in reality, we should consider it comprehensively.

Concrete implementation integrated the above situation, we here using third-party interface to realize the function of the license plate recognition, interfaces provided by the cloud provider we choose baidu, baidu cloud interface provides the free quota, is simply how many times a day can free use, what if more than the number of times you need to pay money, documents address is: Cloud.baidu.com/doc/OCR/ind… , let’s look at the implementation process.

SDK Installation Baidu Cloud SDK provides support for multiple languages, such as: Python, Java, C++, IOS, Android, etc., here we install the Python version of the SDK, easy to install, using PIP install bidu-aip command, SDK support Python version is: 2.7+ and 3.x, SDK directory structure is as follows:

├ ─ ─ the README. Md ├ ─ ─ aip / / SDK directory │ ├ ─ ─ init. Py / / derived class │ ├ ─ ─ base. Py / / aip base class │ ├ ─ ─ HTTP. Py / / HTTP request │ └ ─ ─ OCR. Py / / OCR ├ ─ sci-imp // setuptools setup // setuptools setup // setupTools setup // SetupTools setup // SetupTools setup // SetupTools setup // SetupTools setup // SetupTools setup // Login.bce.baidu.com/?redirect=h… After login, we move the mouse to the position of the login profile picture, and then click user center in the pop-up menu, as shown below:

If it is the first time to enter, check the corresponding information, as shown below:

When the information is checked, click the Save button.

Then move the mouse pointer to the position of symbol in the left bar, and then select ARTIFICIAL intelligence and text recognition in turn, as shown in the picture below:

Click to enter the following image:

Click Create app to enter the image below:

All we need to do here is fill in the app name and the app description below, and then click Create now.

After creating the app, we return to the app list as shown below:

Here we need three values: AppID, API Key, and Secret Key.

Specific implementation of the application created, we can call the interface to achieve license plate recognition function.

AipOcr is a Python SDK client for OCR. AipOcr provides a series of interactive methods for developers using OCR. The code implementation is relatively simple, as shown below:

from aip import AipOcr

Own APPID AK SK

APP_ID = ‘自己的 App ID’ API_KEY = ‘自己的 Api Key’ SECRET_KEY = ‘自己的 Secret Key’

Client = AipOcr(APP_ID, API_KEY, SECRET_KEY) in the above code, the constants APP_ID, API_KEY, and SECRET_KEY are the constants we need when viewing the list of applications. These values are all strings. Identifies users and authenticates access signatures.

If we need to configure the network request parameters of AipOcr, we can call the interface to set the parameters after constructing AipOcr. Currently, two parameters are supported, look at the code implementation:

Timeout period for establishing a connection, in milliseconds

client.setConnectionTimeoutInMillis(5000)

The timeout for data transfer over an open connection, in milliseconds

Client. SetSocketTimeoutInMillis interface (5000) as a whole by license plate recognition is relatively simple, in the following the graph is:

The implementation code is as follows:

from aip import AipOcr

APP_ID = ‘自己的 App ID’ API_KEY = ‘自己的 Api Key’ SECRET_KEY = ‘自己的 Secret Key’

Create a client object

client = AipOcr(APP_ID, API_KEY, SECRET_KEY)

Timeout period for establishing a connection, in milliseconds

client.setConnectionTimeoutInMillis(5000)

The timeout for data transfer over an open connection, in milliseconds

client.setSocketTimeoutInMillis(5000)

Read the pictures

def get_file_content(filePath): with open(filePath, ‘rb’) as fp: return fp.read()

Image = get_file_content(‘car.jpeg’) res = client.licenseplate (image) print(‘ licensePlate: ‘+ res [‘ words_result] [‘ number’]) print (+ res’ license plate color: ‘[‘ words_result] [‘ color’]) results:

LicensePlate (image, options) licensePlate(image, options) licensePlate(image, options)

The implementation code is as follows:

from aip import AipOcr

APP_ID = ‘自己的 App ID’ API_KEY = ‘自己的 Api Key’ SECRET_KEY = ‘自己的 Secret Key’

Create a client object

client = AipOcr(APP_ID, API_KEY, SECRET_KEY)

Timeout period for establishing a connection, in milliseconds

client.setConnectionTimeoutInMillis(5000)

The timeout for data transfer over an open connection, in milliseconds

client.setSocketTimeoutInMillis(5000)

Read the pictures

def get_file_content(filePath): with open(filePath, ‘rb’) as fp: return fp.read()

image = get_file_content(‘cars.png’) options = {}

The multi_detect parameter defaults to false

options[‘multi_detect’] = ‘true’ res = client.licensePlate(image, options) for wr in res[‘words_result’]: Print (‘ id: ‘+ wr[‘number’]) print(‘ id:’ + wr[‘color’])

License plate number: Beijing N6HZ61 License plate color: Blue License plate number: NS1A26 In this paper, we first introduced the license plate recognition, and then realized the recognition function of single and multiple license plates by using baidu cloud interface. Through this paper, we can have some understanding of the related concepts and concrete realization of license plate recognition. As a final reminder, whether you’re a Python career or a hobby, remember that project development experience is always core. If you’re short of new project practice or don’t have an intensive Python tutorial, go to the Python tutorial. Skirt: seven clothes clothes 977 bar and five (number homonym) conversion can be found, there are many new tutorial projects, but also can communicate with the old driver for advice! The text and pictures of this article come from the network plus their own ideas, only for learning, exchange, do not have any commercial use, copyright belongs to the original author, if you have any questions, please contact us to deal with.