README.md 2.94 KB
Newer Older
1
# PaddleOCR车牌识别
shizhm's avatar
shizhm committed
2

3
4
## 模型介绍

Your Name's avatar
Your Name committed
5
车牌识别(Vehicle License Plate Recognition,VLPR) 是计算机视频图像识别技术在车辆牌照识别中的一种应用。车牌识别技术要求能够将运动中的汽车牌照从复杂背景中提取并识别出来,在高速公路车辆管理,停车场管理和城市交通中得到广泛应用。PaddleOCR车牌识别包括本文检测和文本识别两部分内容,其中使用DBnet作为文本检测模型,SVTR作为文本识别模型。车牌识别过程:输入->图像预处理->文字检测->文本识别->输出。
6
7
8

## 模型结构

Your Name's avatar
Your Name committed
9
DBnet是一种基于分割的文本检测方法,相比传统分割方法需要设定固定阈值,该模型将二值化操作插入到分割网络中进行联合优化,通过网络学习可以自适应的预测图像中每一个像素点的阈值,能够在像素水平很好的检测自然场景下不同形状的文字。SVTR是一种端到端的文本识别模型,通过单个视觉模型就可以一站式解决特征提取和文本转录两个任务,同时也保证了更快的推理速度。百度PaddleOCR开源项目提供了车牌识别的预训练模型,本示例使用PaddleOCR提供的蓝绿黄牌识别模型进行推理。
10

Your Name's avatar
Your Name committed
11
## 构建安装
12

Your Name's avatar
Your Name committed
13
在光源可拉取推理的docker镜像,PaddleOCR工程推荐的镜像如下:
14

Your Name's avatar
Your Name committed
15
16
17
```python
docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:ort1.14.0_migraphx3.0.0-dtk22.10.1
```
18

Your Name's avatar
Your Name committed
19
20
21
22
23
### 安装Opencv依赖

```python
cd <path_to_migraphx_samples>
sh ./3rdParty/InstallOpenCVDependences.sh
24
```
Your Name's avatar
Your Name committed
25
26
27
28
29
30
31
32
33
34
35
36
37

### 修改CMakeLists.txt

- 如果使用ubuntu系统,需要修改CMakeLists.txt中依赖库路径:
  将"${CMAKE_CURRENT_SOURCE_DIR}/depend/lib64/"修改为"${CMAKE_CURRENT_SOURCE_DIR}/depend/lib/"

- **MIGraphX2.3.0及以上版本需要c++17**


### 安装OpenCV并构建工程

```
rbuild build -d depend
38
39
```

Your Name's avatar
Your Name committed
40
41
42
43
44
### 设置环境变量

将依赖库依赖加入环境变量LD_LIBRARY_PATH,在~/.bashrc中添加如下语句:

**Centos**:
45
46

```
Your Name's avatar
Your Name committed
47
48
49
50
51
52
53
export LD_LIBRARY_PATH=<path_to_migraphx_samples>/depend/lib64/:$LD_LIBRARY_PATH
```

**Ubuntu**:

```
export LD_LIBRARY_PATH=<path_to_migraphx_samples>/depend/lib/:$LD_LIBRARY_PATH
54
55
```

Your Name's avatar
Your Name committed
56
然后执行:
57

Your Name's avatar
Your Name committed
58
59
60
61
62
```
source ~/.bashrc
```

## 推理
63

Your Name's avatar
Your Name committed
64
65
66
### C++版本推理

成功编译PaddleOCR车牌识别工程后,在build目录下输入如下命令运行该示例:
67
68

```
Your Name's avatar
Your Name committed
69
# 开启环境变量
70
71
72
export MIGRAPHX_DYNAMIC_SHAPE=1

# 运行示例
Your Name's avatar
Your Name committed
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
./MIGraphX 0
```

PaddleOCR车牌识别结果为:

```
[皖AD19906, 0.999067]
```

### python版本推理

PaddleOCR工程同时提供了python推理示例,可使用如下命令运行:

```
# 进入python示例目录
cd ./Python

# 安装依赖
pip install -r requirements.txt

# 运行程序
94
95
96
python PaddleOCR_infer_migraphx.py
```

Your Name's avatar
Your Name committed
97
PaddleOCR车牌识别结果为:
98
99

```
Your Name's avatar
Your Name committed
100
[[('皖AD19906', 0.99)]]
101
102
103
104
105
106
107
108
109
```

## 历史版本

​		https://developer.hpccube.com/codes/modelzoo/paddleocr_migraphx

## 参考

​		https://github.com/PaddlePaddle/PaddleOCR