This commit is contained in:
cdllp2 2022-09-21 11:38:07 +08:00
commit 16cf5e9b53

View File

@ -10,7 +10,7 @@ OCR的核心技术包含两方面一是目标检测模型检测图片中的
第一类验证码最简单,它们没有复杂的背景图片,所以目标检测模型可以省略,直接将图片送入文字识别模型即可。
![image](https://user-images.githubusercontent.com/20157705/191401415-90e25e7e-07c6-49b2-9dae-57a476357c84.png)
<img src="https://user-images.githubusercontent.com/20157705/191401415-90e25e7e-07c6-49b2-9dae-57a476357c84.png" width="50%" height="50%">
识别代码如下:
@ -33,7 +33,8 @@ print(res)
第二类验证码有复杂的背景,需要先用目标检测模型框出文字,在进行识别
![image](https://user-images.githubusercontent.com/20157705/191401494-aa46d882-6be9-4499-b95b-667c7ce92385.png)
<img src="https://user-images.githubusercontent.com/20157705/191401494-aa46d882-6be9-4499-b95b-667c7ce92385.png" width="30%" height="30%">
代码如下:
@ -63,13 +64,18 @@ cv2.imwrite("result.jpg", im)
输出结果如下:
![image](https://user-images.githubusercontent.com/20157705/191401572-43eb066c-e1cb-451b-8656-260df3a7b0e3.png)
<img src="https://user-images.githubusercontent.com/20157705/191401572-43eb066c-e1cb-451b-8656-260df3a7b0e3.png" width="30%" height="30%">
<img src="https://user-images.githubusercontent.com/20157705/191405904-82c00b1e-9e70-433f-bbc0-ca8bb48d7bf1.png" width="30%" height="30%">
可以看到文字部分已经被框出来了,如果我们在上述代码直接将`im[y1:y2, x1:x2]`送入文字识别模型,就可以识别出对应的文本内容了。
`ddddocr`还能识别下面这种带滑块的验证码
![image](https://user-images.githubusercontent.com/20157705/191401644-10dd8c3a-5475-40fe-ab5c-87137b1ffcf7.png)
<img src="https://user-images.githubusercontent.com/20157705/191401644-10dd8c3a-5475-40fe-ab5c-87137b1ffcf7.png" width="30%" height="30%">
这种虽然不属于OCR的业务范畴但作为一个通用的验证码识别工具作者还是支持了必须给作者点个赞。