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

shizhm's avatar
shizhm committed
11
12
13
## C++版本推理

### 拉取镜像
14

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

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

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

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

### 修改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
40
41
```

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

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

**Centos**:
47
48

```
Your Name's avatar
Your Name committed
49
50
51
52
53
54
55
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
56
57
```

Your Name's avatar
Your Name committed
58
然后执行:
59

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

shizhm's avatar
shizhm committed
64
### 运行示例
Your Name's avatar
Your Name committed
65
66

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

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

# 运行示例
shizhm's avatar
shizhm committed
73
./PaddleOCR_VLPR
Your Name's avatar
Your Name committed
74
75
76
77
78
```

PaddleOCR车牌识别结果为:

```
shizhm's avatar
shizhm committed
79
皖AD19906
Your Name's avatar
Your Name committed
80
81
```

shizhm's avatar
shizhm committed
82
83
84
85
86
## python版本推理

PaddleOCR工程同时提供了python推理示例。

### 环境配置
Your Name's avatar
Your Name committed
87

shizhm's avatar
shizhm committed
88
python推理示例推荐使用C++版本示例同一镜像,python依赖安装:
Your Name's avatar
Your Name committed
89
90
91
92
93
94
95

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

# 安装依赖
pip install -r requirements.txt
shizhm's avatar
shizhm committed
96
97
98
```

### 运行示例
Your Name's avatar
Your Name committed
99

shizhm's avatar
shizhm committed
100
101
102
环境配置成功之后,可在当前目录执行如下指令运行程序推理:

```
103
104
105
python PaddleOCR_infer_migraphx.py
```

Your Name's avatar
Your Name committed
106
PaddleOCR车牌识别结果为:
107
108

```
shizhm's avatar
shizhm committed
109
皖AD19906
110
111
112
113
114
115
116
117
118
```

## 历史版本

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

## 参考

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