Home > Backend Development > Python Tutorial > How to identify license plate number with one line of Python code

How to identify license plate number with one line of Python code

WBOY
Release: 2023-05-10 18:04:06
forward
2024 people have browsed it

Recognize license plate

The code to recognize license plate is very simple, only 1 line of code is required, as shown below.

# pip install poocr
import poocr
# 可以填写本地图片的地址:img_path,也可以填写在线图片的地址:img_url
# 如果2个都填,则只用在线图片img_url
# configPath是配置文件的信息,可以不填
Number = poocr.ocr.LicensePlateOCR(
    img_path=r'C:\Users\程序员晚枫\temp\math_img.jpg',
    img_url=r'https://cache.yisu.com/upload/information/20230317/112/9432.jpg',
    configPath=r'D:\workplace\code\github\poocr\tests\poocr-config.toml')
print(Number)
Copy after login

This interface supports the automatic positioning and recognition of motor vehicle license plates in mainland China, and returns regional number, license plate number and license plate color information.

The returned data is as follows.

{
  ...
  "LicensePlateInfos": [
    {
      "Number": "京Q58888",
      ...
      "Color": "蓝"
    }
  ],
  "RequestId": "2be9b49d-d1ce-4344-83e8-771ea929bb97"
}
...
Copy after login

Extended functions

In addition, there are 6 interfaces related to vehicle recognition, which are:

# pip install poocr
import poocr
# 识别驾驶证
ressult = poocr.ocr.DriverLicenseOCR()
# 识别行驶证
ressult = poocr.ocr.VehicleLicenseOCR()
# 识别机动车登记证
ressult = poocr.ocr.VehicleRegCertOCR()
# 识别网约车驾驶证
ressult = poocr.ocr.RideHailingDriverLicenseOCR()
# 识别网约车运输证
ressult = poocr.ocr.RideHailingTransportLicenseOCR()
# 识别车辆VIN码
ressult = poocr.ocr.VinOCR()
Copy after login

Notes

The implementation of this function, It relies on Tencent Cloud's text recognition, so if you are a novice user, please configure a poocr-config.toml file in the same directory.

The file contents are as follows.

[tencent-ai]
TENCENTCLOUD_SECRET_ID = '你的 SecretId'     # 建议使用子账号密钥,授权遵循最小权限指引,降低使用风险。子账号密钥获取可参考:https://cloud.tencent.com/act/cps/redirect?redirect=36394&cps_key=ca76be5a2293ba3906d6d5407aea15ee
TENCENTCLOUD_SECRET_KEY = '你的 SecretKey'   # 建议使用子账号密钥,授权遵循最小权限指引,降低使用风险。子账号密钥获取可参考:https://cloud.tencent.com/act/cps/redirect?redirect=36394&cps_key=ca76be5a2293ba3906d6d5407aea15ee
Copy after login

The above is the detailed content of How to identify license plate number with one line of Python code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template