栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

傻瓜式 Python OCR 识别库 — ddddocr

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

傻瓜式 Python OCR 识别库 — ddddocr

爬虫时,你是否碰到过这种验证码比较的头疼

依赖库的安装

pip install ddddocr

带带弟弟 OCR 可以识别三种验证码,小编就用这三种来实验一下。

    滑块验证码

import ddddocr

det = ddddocr.DdddOcr(det=False, ocr=False)

with open('hycdn.png', 'rb') as f:
        target_bytes = f.read()
    
with open('background.jpg', 'rb') as f:
    background_bytes = f.read()

res = det.slide_match(target_bytes, background_bytes, simple_target=True)

print(res)


识别结果:
{'target_y': 0, 'target': [486, 126, 622, 262]}

    点选类验证码
det = ddddocr.DdddOcr(det=True)

    with open("eb.jpg", 'rb') as f:
        image = f.read()

    poses = det.detection(image)

    im = cv2.imread("eb.jpg")

    for box in poses:
        x1, y1, x2, y2 = box
        im = cv2.rectangle(im, (x1, y1), (x2, y2), color=(0, 0, 255), thickness=2)

    cv2.imwrite("result.jpg", im)

    字母数字验证码
ocr = ddddocr.DdddOcr(old=True)

with open("z1.jpg", 'rb') as f:
    image = f.read()

res = ocr.classification(image)
print(res)

# 识别结果
3n3d
8342

ddddocr 让验证码变得如此简单与易用,,让不会用 opencv, pytorch, tensorflow 的小伙伴也能快速的破解网站的登录验证码。小伙伴们如果有其他好的 ocr 识别也可以在留言中分享出来。

不要干坏事哦

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/753669.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号