README.md 3.44 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

liucong's avatar
liucong committed
11
12
13
## python版本推理

下面介绍如何运行python代码示例,具体推理代码解析,在Doc/Tutorial_Python.md中有详细说明。
shizhm's avatar
shizhm committed
14
15

### 拉取镜像
16

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

Your Name's avatar
Your Name committed
19
20
21
```python
docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:ort1.14.0_migraphx3.0.0-dtk22.10.1
```
22

liucong's avatar
liucong committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
### 推理示例

python依赖安装:

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

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

依赖安装成功之后,可在当前目录执行如下指令运行程序推理:

```
# 开启环境变量
export MIGRAPHX_DYNAMIC_SHAPE=1

# 运行示例程序
python PaddleOCR_infer_migraphx.py
```

PaddleOCR车牌识别结果为:

```
皖AD19906
```

## C++版本推理

下面介绍如何运行C++代码示例,具体推理代码解析,在Doc/Tutorial_Cpp.md目录中有详细说明。

参考Python版本推理中的构建安装,在光源中拉取推理的docker镜像。

Your Name's avatar
Your Name committed
57
58
59
### 安装Opencv依赖

```python
shizhm's avatar
shizhm committed
60
cd <path_to_paddleocr_migraphx>
Your Name's avatar
Your Name committed
61
sh ./3rdParty/InstallOpenCVDependences.sh
62
```
Your Name's avatar
Your Name committed
63
64
65
66
67
68
69
70
71
72
73
74
75

### 修改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
76
77
```

Your Name's avatar
Your Name committed
78
79
80
81
82
### 设置环境变量

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

**Centos**:
83
84

```
Your Name's avatar
Your Name committed
85
86
87
88
89
90
91
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
92
93
```

Your Name's avatar
Your Name committed
94
然后执行:
95

Your Name's avatar
Your Name committed
96
97
98
99
```
source ~/.bashrc
```

liucong's avatar
liucong committed
100
### 推理示例
Your Name's avatar
Your Name committed
101

liucong's avatar
liucong committed
102
成功编译PaddleOCR车牌识别工程后,执行如下命令运行该示例:
103
104

```
liucong's avatar
liucong committed
105
106
107
108
109
110
# 进入migraphx samples工程根目录
cd <path_to_migraphx_samples> 

# 进入build目录
cd ./build/

Your Name's avatar
Your Name committed
111
# 开启环境变量
112
113
114
export MIGRAPHX_DYNAMIC_SHAPE=1

# 运行示例
shizhm's avatar
shizhm committed
115
./PaddleOCR_VLPR
Your Name's avatar
Your Name committed
116
117
118
119
120
```

PaddleOCR车牌识别结果为:

```
shizhm's avatar
shizhm committed
121
皖AD19906
Your Name's avatar
Your Name committed
122
123
```

124
125
126
127
128
129
130
## 历史版本

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

## 参考

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