Python三方库ddddocr实现验证码识别
Python三方库ddddocr实现验证码识别
环境要求
python >= 3.8
安装三方库
pip install ddddocr -i https://pypi.tuna.tsinghua.edu.cn/simple
参数说明:
| 参数名 | 参数类型 | 默认值 | 说明 |
| use_gpu | Bool | False | 是否使用gpu进行推理,如果该值为False则device_id不生效 |
| device_id | int | 0 | cuda设备号,目前仅支持单张显卡 |
| img | bytes | 无默认值(必填项) | 图片的bytes格式 |
代码示例:
import ddddocr
ocr = ddddocr.DdddOcr()
with open('1.png', 'rb') as f:
img_bytes = f.read()
res = ocr.classification(img_bytes)
print(res)
