gitmyhub

ddddocr

Python ★ 14k updated 3mo ago

带带弟弟 通用验证码识别OCR pypi版

A Python library with a pre-trained model for reading text from captcha images and detecting objects or slider positions, installable with one pip command and usable without any model training.

Pythonsetup: easycomplexity 2/5

DdddOcr is a Python library for recognizing captcha images without needing to set up or train models yourself. Captchas are the distorted-text or puzzle images that websites use to check whether a visitor is human. This library provides a pre-trained model you can call with a few lines of code to read the text out of a captcha image or to locate objects within one.

The library offers three main capabilities. The first is basic text recognition: given a captcha image as bytes, it returns the characters it detected, which can include Chinese, English, numbers, and some special symbols. The second capability is object detection, which finds where things are in an image and returns bounding box coordinates rather than reading text. This is useful for captchas where you need to identify which area of an image contains a particular element. The third capability is slider detection, which figures out where a sliding-puzzle piece should be placed, using image processing algorithms rather than AI.

The models were trained on a large set of randomly generated images rather than on data from any specific captcha provider. This makes the library general-purpose, but the README is honest that recognition may or may not succeed depending on the captcha style, since no general model can cover every case perfectly.

Installation is a single pip command. The library runs locally without sending images to any external service, and it supports running on both CPU and GPU. Supported platforms include Windows 64-bit, Linux 64-bit and ARM64, and macOS. You initialize it once and reuse the same object for multiple recognitions, since each initialization loads the model and takes extra time.

For users who need to handle captcha types the default model cannot read, the library supports loading a custom model trained with a companion project called dddd_trainer. The README is written primarily in Chinese.

Where it fits