python车牌识别系统开源代码_基于YoLo2的开源车牌检测和识别

ALPR in Unscontrained Scenarios

Introduction

This repository contains the author's implementation of ECCV 2018 paper "License Plate Detection and Recognition in Unconstrained Scenarios".

If you use results produced by our code in any publication, please cite our paper:

@INPROCEEDINGS{silva2018a,

author={S. M. Silva and C. R. Jung},

booktitle={2018 European Conference on Computer Vision (ECCV)},

title={License Plate Detection and Recognition in Unconstrained Scenarios},

year={2018},

pages={580-596},

doi={10.1007/978-3-030-01258-8_36},

month={Sep},}

Requirements

In order to easily run the code, you must have installed the Keras framework with TensorFlow backend. The Darknet framework is self-contained in the "darknet" folder and must be compiled before running the tests. To build Darknet just type "make" in "darknet" folder:

$ cd darknet && make

The current version was tested in an Ubuntu 16.04 machine, with Keras 2.2.4, TensorFlow 1.5.0, OpenCV 2.4.9, NumPy 1.14 and Python 2.7.

Download Models

After building the Darknet framework, you must execute the "get-networks.sh" script. This will download all the trained models:

$ bash get-networks.sh

Running a simple test

Use the script "run.sh" to run our ALPR approach. It requires 3 arguments:

Input directory (-i): should contain at least 1 image in JPG or PNG format;

Output directory (-o): during the recognition process, many temporary files will be generated inside this directory and erased in the end. The remaining files will be related to the automatic annotated image;

CSV file (-c): specify an output CSV file.

$ bash get-networks.sh && bash run.sh -i samples/test -o /tmp/output -c /tmp/output/results.csv

Training the LP detector

To train the LP detector network from scratch, or fine-tuning it for new samples, you can use the train-detector.py script. In folder samples/train-detector there are 3 annotated samples which are used just for demonstration purposes. To correctly reproduce our experiments, this folder must be filled with all the annotations provided in the training set, and their respective images transferred from the original datasets.

The following command can be used to train the network from scratch considering the data inside the train-detector folder:

$ mkdir models

$ python create-model.py eccv models/eccv-model-scracth

$ python train-detector.py --model models/eccv-model-scracth --name my-trained-model --train-dir samples/train-detector --output-dir models/my-trained-model/ -op Adam -lr .001 -its 300000 -bs 64

For fine-tunning, use your model with --model option.

A word on GPU and CPU

We know that not everyone has an NVIDIA card available, and sometimes it is cumbersome to properly configure CUDA. Thus, we opted to set the Darknet makefile to use CPU as default instead of GPU to favor an easy execution for most people instead of a fast performance. Therefore, the vehicle detection and OCR will be pretty slow. If you want to accelerate them, please edit the Darknet makefile variables to use GPU.

Python实现车牌识别通常涉及到计算机视觉技术,特别是图像处理和机器学习算法。一种常见的方法是结合OpenCV库和深度学习模型,如YOLO(You Only Look Once)、SSD(Single Shot MultiBox Detector)或更先进的Mask R-CNN。 以下是一个简单的步骤概述: 1. **数据预处理**:收集包含车牌的图片,并对它们进行归一化、大小调整等预处理操作。 2. **安装依赖库**:你需要`opencv-python`, `tensorflow` 或 `pytorch`等深度学习框架,以及用于加载预训练模型的`keras`, ` Detectron2`等。 3. **模型选择**:选择适合车牌识别的预训练模型,例如基于TensorFlow的`tf.keras.models.load_model()` 或 PyTorch的`torch.hub.load()`。 4. **模型预测**:将图像输入到模型中,模型会返回一组包含车牌位置和可能性的结果。 5. **结果解析**:从模型输出中挑选出最有可能是车牌的部分,并进行后处理,比如非极大值抑制(NMS),确定最终的车牌区域。 6. **字符分割与识别**:对车牌区域提取字符,这一步可以采用OCR(Optical Character Recognition)技术,使用如`tesseract`这样的开源工具。 下面是一个简化的代码片段示例,注意这只是一个基本框架,实际应用需要更详细的配置和优化: ```python import cv2 from keras.models import load_model # 加载模型 model = load_model('path_to_your_trained_model.h5') # 预测函数 def detect_plate(image_path): img = cv2.imread(image_path) # 对图像进行预处理 processed_img = preprocess_image(img) # 进行预测 predictions = model.predict(processed_img) # 解析和识别车牌 plate_text = recognize_chars(predictions) return plate_text # ... 其他辅助函数 ... # 使用例子 plate_text = detect_plate('image_with_license_plate.jpg') print(f"Detected license plate: {plate_text}") ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值