README.md 3.6 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
## python版本推理

shizhm's avatar
shizhm committed
13
下面介绍如何运行Python代码示例,Python示例的详细说明见Doc目录下的Tutorial_Python.md。
shizhm's avatar
shizhm committed
14

shizhm's avatar
shizhm committed
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

shizhm's avatar
shizhm committed
23
### 设置Python环境变量
liucong's avatar
liucong committed
24

shizhm's avatar
shizhm committed
25
26
27
28
29
```
export PYTHONPATH=/opt/dtk/lib:$PYTHONPATH
```

### 安装依赖
liucong's avatar
liucong committed
30
31
32

```
# 进入python示例目录
shizhm's avatar
shizhm committed
33
cd <path_to_paddleocr_migraphx>/Python
liucong's avatar
liucong committed
34
35
36
37
38

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

shizhm's avatar
shizhm committed
39
40
### 运行示例

liucong's avatar
liucong committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
依赖安装成功之后,可在当前目录执行如下指令运行程序推理:

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

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

PaddleOCR车牌识别结果为:

```
皖AD19906
```

## C++版本推理

shizhm's avatar
shizhm committed
59
60
61
下面介绍如何运行C++代码示例,C++示例的详细说明见Doc目录下的Tutorial_Cpp.md。

### 下载镜像
liucong's avatar
liucong committed
62

shizhm's avatar
shizhm committed
63
64
65
66
67
在光源中下载MIGraphX镜像: 

```
docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:ort1.14.0_migraphx3.0.0-dtk22.10.1
```
liucong's avatar
liucong committed
68

Your Name's avatar
Your Name committed
69
70
71
### 安装Opencv依赖

```python
shizhm's avatar
shizhm committed
72
cd <path_to_paddleocr_migraphx>
Your Name's avatar
Your Name committed
73
sh ./3rdParty/InstallOpenCVDependences.sh
74
```
Your Name's avatar
Your Name committed
75
76
77
78
79
80
81
82
83
84
85
86
87

### 修改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
88
89
```

Your Name's avatar
Your Name committed
90
91
92
93
94
### 设置环境变量

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

**Centos**:
95
96

```
shizhm's avatar
shizhm committed
97
export LD_LIBRARY_PATH=<path_to_paddleocr_migraphx>/depend/lib64/:$LD_LIBRARY_PATH
Your Name's avatar
Your Name committed
98
99
100
101
102
```

**Ubuntu**:

```
shizhm's avatar
shizhm committed
103
export LD_LIBRARY_PATH=<path_to_paddleocr_migraphx>/depend/lib/:$LD_LIBRARY_PATH
104
105
```

Your Name's avatar
Your Name committed
106
然后执行:
107

Your Name's avatar
Your Name committed
108
109
110
111
```
source ~/.bashrc
```

shizhm's avatar
shizhm committed
112
### 运行示例
Your Name's avatar
Your Name committed
113

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

```
liucong's avatar
liucong committed
117
# 进入migraphx samples工程根目录
shizhm's avatar
shizhm committed
118
cd <path_to_paddleocr_migraphx> 
liucong's avatar
liucong committed
119
120
121
122

# 进入build目录
cd ./build/

Your Name's avatar
Your Name committed
123
# 开启环境变量
124
125
126
export MIGRAPHX_DYNAMIC_SHAPE=1

# 运行示例
shizhm's avatar
shizhm committed
127
./PaddleOCR_VLPR
Your Name's avatar
Your Name committed
128
129
130
131
132
```

PaddleOCR车牌识别结果为:

```
shizhm's avatar
shizhm committed
133
皖AD19906
Your Name's avatar
Your Name committed
134
135
```

136
137
138
139
140
141
142
## 历史版本

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

## 参考

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