2025-05-21 11:39:56 +08:00

86 lines
2.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# <p align="center">图像界面识别-小组作业</p>
## 运行库
cv2、matplotlib、easyocr
## 实现原理
我们采用分割的方式将图片中所有玩家的ID和评分进行分割。<br>
然后我们对所有分割下来的图片进行识别,将文字提取出来。<br>
最终通过比较所有玩家的评分来找出评分最高的玩家。
## 分割
我们使用了最简单的方法进行分割。<br>
认为确认所有ID和评分的坐标位置进行分割。<br>
```c
# ID坐标
id = [
(460, 415, 800, 460),
(460, 610, 800, 655),
(550, 805, 800, 850),
(460, 995, 800, 1040),
(460, 1190, 800, 1235),
(1860, 415, 2200, 460),
(1930, 600, 2200, 665),
(1860, 805, 2200, 850),
(1930, 980, 2200, 1055),
(1860, 1190, 2200, 1235),
]
# 评分坐标
score = [
(335, 488, 465, 545),
(335, 680, 465, 740),
(335, 875, 465, 930),
(335, 1070, 465, 1125),
(335, 1260, 465, 1320),
(1710, 488, 1845, 545),
(1710, 680, 1845, 740),
(1710, 875, 1845, 930),
(1710, 1070, 1845, 1125),
(1710, 1260, 1845, 1320),
]
```
## 识别
采用[`easyocr`](https://github.com/JaidedAI/EasyOCR)来对图像进行识别。
```c
import easyocr
# 识别中文并关闭GPU完全使用CPU
reader = easyocr.Reader(['ch_sim'], gpu=False)
# 将RGB图像识别为文字
results_id.append(reader.readtext(rgb, detail=0))
```
## 比较
采用最简单的比较方式定义变量max_val = 0.0、max_idx = []和min_val = 20.0、min_idx = []。<br>
循环对所有评分变量进行对比记下最大值、最小值及其对于的ID序号。
## 结果展示
### 图像分割结果
图像ID分割效果<br>
![id](/result/id.png#pic_center)<br>
图像评分分割效果<br>
![score](/result/score.png#pic_center)<br>
图像文字识别结果
```c
玩家1 ['没人要玩对抗'] 的评分为: ['6.4']
玩家2 ['卖妲己赎貂蝉'] 的评分为: ['7.6']
玩家3 ['邓紫棋'] 的评分为: ['9.0']
玩家4 ['李白不会闪避'] 的评分为: ['5.1']
玩家5 ['纸品包装定制'] 的评分为: ['5.1']
玩家6 ['身材好长得帅'] 的评分为: ['10.8']
玩家7 ['牢王训练家'] 的评分为: ['12.7']
玩家8 ['做5 咪'] 的评分为: ['10.4']
玩家9 ['依琳 ~'] 的评分为: ['9.4']
玩家10 ['新买的泳衣'] 的评分为: ['8.7']
全场最高分: 12.7
全场最高分玩家ID:
['牢王训练家']
全场最低分: 5.1
全场最低分玩家ID:
['李白不会闪避']
['纸品包装定制']
```
## 致谢
感谢[`easyocr`](https://github.com/JaidedAI/EasyOCR)项目团队的每一个成员。
## 小组成员
张豪、孟梓涵、龚韩轩、张梦南<br>
(排名不分先后)