A long time ago, I shared how Python code implements captcha recognition.Copy the code

We used Pillow + Pytesseract, which is free and easy to use. But its recognition accuracy is general, if you want to higher requirements of verification code recognition, beginners can only choose to use Baidu API interface.

But in fact, Baidu API interface and PyTesserAct actually need to be pre-configured, which is not very friendly for beginners.

And Baidu API must network, for some machines can not network friends, have to pass

Recently, a member of the group shared a new library, tried it and found it very practical, specially to share with you today. Finally, if your time is not very tight, and want to quickly improve, the most important thing is not afraid of hardship, I suggest you can contact Wei: 762459510, that is really good, many people progress quickly, need you not afraid of hardship oh! You can go to add a look at ~

Github address: github.com/sml2h3/dddd…

The library name is also interesting — DDdDOCr

Environmental requirements:

Python > = 3.8 Windows/Linux/Macox..Copy the code

You can run the following command to install it

pip install ddddocr
Copy the code

Parameter Description:

On the Internet to find a random verification code picture, use this library to combat.

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)

Captcha text was successfully identified!

The advantages are obvious: first of all, the code is very simple, compared to the two methods mentioned above, no additional setting of environment variables, etc., 5 lines of code can easily identify captcha images. On the other hand, we use the magic command %%time also test out, this code recognition speed is very fast. Finally, if your time is not very tight, and want to quickly improve, the most important thing is not afraid of hardship, I suggest you can contact Wei: 762459510, that is really good, many people progress quickly, need you not afraid of hardship oh! You can go to add a look at ~

Let’s continue testing with more captcha images:

I found 6 captcha pictures to test and observed the results, and found that this kind of simple captcha can be quickly recognized. But some of the results are not case-sensitive (like the sixth image).

All in all, if you need to do captcha recognition, and the precision is not too high.

So, OCR (DDDDOCR) library is a good choice