Artifact! Get the verification code easily with Python!

940a698dfbf58737f3891e23614cb434.png

From: Deng and his Python

Hello everyone, today I will introduce an artifact for universal verification code recognition OCR library, project address: https://github.com/sml2h3/ddddocr. The common click-type verification code pictures in the market are shown in the following figure:

2797934fcf6d156614fa709b2686043e.png

Install

pip3 install ddddocr

OCR identification part

import ddddocr

ocr = ddddocr.DdddOcr(old=True)

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

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

ab17658bb64e1df999aafa3118e0ed47.png


target detection part

It is possible to have certain recognition capabilities for existing click-through verification code pictures or unknown verification code pictures, which are suitable for text clicks and icon clicks. To put it simply, for the click-type verification code, the text or icon on the picture can be quickly detected.

import ddddocr
import cv2

det = ddddocr.DdddOcr(det=True)

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

poses = det.detection(image)
print(poses)

im = cv2.imread("test.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)

22ce637b91d6fbd64a25f0a14f1e94e5.png

 
  
推荐阅读:
入门: 最全的零基础学Python的问题  | 零基础学了8个月的Python  | 实战项目 |学Python就是这条捷径
干货:爬取豆瓣短评,电影《后来的我们》 | 38年NBA最佳球员分析 |   从万众期待到口碑扑街!唐探3令人失望  | 笑看新倚天屠龙记 | 灯谜答题王 |用Python做个海量小姐姐素描图 |碟中谍这么火,我用机器学习做个迷你推荐系统电影
趣味:弹球游戏  | 九宫格  | 漂亮的花 | 两百行Python《天天酷跑》游戏!
AI: 会做诗的机器人 | 给图片上色 | 预测收入 | 碟中谍这么火,我用机器学习做个迷你推荐系统电影
小工具: Pdf转Word,轻松搞定表格和水印! | 一键把html网页保存为pdf!|  再见PDF提取收费! | 用90行代码打造最强PDF转换器,word、PPT、excel、markdown、html一键转换 | 制作一款钉钉低价机票提示器! |60行代码做了一个语音壁纸切换器天天看小姐姐!|

The year's hottest copy

Click to read the original text to see 200 Python cases!

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326954716&siteId=291194637