当前位置:网站首页>5 lines of code identify various verification codes

5 lines of code identify various verification codes

2022-06-12 07:12:00 Snow falls on the devil's land

A group friend shared a new library , Try it and find it very practical , I want to share it with you today .

Github Address :https://github.com/sml2h3/ddddocr

The library name is also very interesting —— ddddocr( Homophonic band OCR)

Environmental requirements

python >= 3.8
Windows/Linux/Macox..

You can install it with the following command

pip install ddddocr

Parameter description

 picture

I randomly looked for a verification code picture on the Internet , Use this library to practice .

 picture

source : Baidu search

import ddddocr

ocr = ddddocr.DdddOcr()
with open('1.png', 'rb') as f:
    img_bytes = f.read()
res = ocr.classification(img_bytes)

print(res)

 picture

Successfully recognized the verification code text !

And the advantages are also very obvious : First of all, the code is very concise , Compare the two methods mentioned above , There is no need to set additional environment variables, etc ,5 One line of code can easily identify the verification code picture . On the other hand , We use magic commands %%time Did you test it , This code recognition speed is very fast .

Let's continue the test with more verification code pictures :

 picture

I looked for it again 6 A verification code picture to test , Observations , It is found that this kind of simple verification code can be recognized quickly . But some of the results are problematic —— Letters are not case sensitive ( For example 6 A picture ).

To make a long story short , If you need verification code identification , And the accuracy requirement is not too high .

that , Take your brother OCR(ddddocr) This library is a good choice ~

原网站

版权声明
本文为[Snow falls on the devil's land]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203010558306632.html