forked from chenwei-zhao/captcha-recognizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusage_example.py
More file actions
40 lines (31 loc) · 1.39 KB
/
Copy pathusage_example.py
File metadata and controls
40 lines (31 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from captcha_recognizer.recognizer import Recognizer
# 单缺口、多缺口验证码背景图识别
# source传入图片路径或图片对象
# verbose=False表示关闭冗余输出
# show_result 为True展示识别效果图 (生产环境请设置show_result=False)
recognizer = Recognizer()
box, confidence = recognizer.identify_gap(source='<image object>', verbose=False, show_result=True)
print(f'缺口坐标: {box}')
print(f'可信度: {confidence}')
"""
打印结果如下:
缺口方框坐标: [331.72052001953125, 55.96122741699219, 422.079345703125, 161.7498779296875]
可信度: 0.9513089656829834
坐标原点:图片左上角
缺口方框坐标为缺口方框左上角和右下角距离坐标原点的距离
"""
# 验证码截图识别
# source传入图片路径或图片对象
# verbose=False表示关闭冗余输出
# show_result 为True展示识别效果图 (生产环境请设置show_result=False)
recognizer = Recognizer()
box, confidence = recognizer.identify_screenshot(source='<image object>', verbose=False, show_result=True)
print(f'缺口坐标: {box}')
print(f'可信度: {confidence}')
"""
打印结果如下:
缺口坐标: [332.2833251953125, 55.69723129272461, 422.9914245605469, 162.34860229492188]
可信度: 0.9590587019920349
坐标原点:图片左上角
缺口方框坐标为缺口方框左上角和右下角距离坐标原点的距离
"""