Python3 implements simple license plate detection

Introduction

Hi, long time no see~~~

I haven't written anything for two weeks. Start with a simple one and gradually improve the level of the article. You will have more time to start next month~~~

Use Python to implement a simple license plate detection algorithm~~~

Let's start happily~~~

Related documents

Network disk download link: https://pan.baidu.com/s/1iJmXCheJoWqpjEZdL5D3AA

Password: wjcd

development tools

Python version: 3.6.4

Related modules: cv2 module; numpy module.

Environment build

Install Python and add it to the environment variable, and pip installs the required related modules.

Principle introduction

Note that this is not license plate number recognition, but license plate detection.

Because the shape of the license plate is relatively simple, I refer to some simple traditional algorithms to achieve it without using deep learning. The effect is relatively general. Not suitable for license plate detection in complex environments.

The function interface of OpenCV directly transferred has not been implemented from 0, so the overall technical content is low.

Its process is:

Step1:

Perform some preprocessing on the image, including grayscale, Gaussian smoothing, median filtering, Sobel operator edge detection, etc.

Step2:

Use OpenCV to search the contour of the preprocessed image, and then judge whether the contour is a license plate contour according to some parameters.

For the specific implementation process, please refer to the source code in the relevant file.

demo

Just run the detect.py file in the cmd window.

Please specify the image path to be detected before use:

The effect is as follows:

Original image 1:

Test result 1:

Original image 2:

Test results:

Original image 3:

Test result 3:

That's all~

More

License plate detection and license plate recognition are actually very mature technologies.

So what I did only represents the rookie level.

I just looked at the code I tried to write for a while.

I will gradually improve my level T_T in the future, I am not used to it after not posting for a long time hhhh.

That's it~~~

Guess you like

Origin blog.csdn.net/m0_67373485/article/details/129723370