ddddocr


Nameddddocr JSON
Version 1.5.6 PyPI version JSON
download
home_pagehttps://github.com/sml2h3/ddddocr
Summary带带弟弟OCR
upload_time2024-10-15 09:22:00
maintainerNone
docs_urlNone
authorsml2h3
requires_python<3.13
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            

# DdddOcr 带带弟弟OCR通用验证码离线本地识别SDK免费开源版

DdddOcr,其由 [本作者](https://github.com/sml2h3) 与 [kerlomz](https://github.com/kerlomz) 共同合作完成,通过大批量生成随机数据后进行深度网络训练,本身并非针对任何一家验证码厂商而制作,本库使用效果完全靠玄学,可能可以识别,可能不能识别。

DdddOcr、最简依赖的理念,尽量减少用户的配置和使用成本,希望给每一位测试者带来舒适的体验

项目地址: [点我传送](https://github.com/sml2h3/ddddocr) 

<!-- PROJECT SHIELDS -->

[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]

<!-- PROJECT LOGO -->
<br />

<p align="center">
  <a href="https://github.com/sml2h3/ddddocr/">
    <img src="https://cdn.wenanzhe.com/img/logo.png!/crop/700x500a400a500" alt="Logo">
  </a>
  <p align="center">
    一个容易使用的通用验证码识别python库
    <br />
    <a href="https://github.com/sml2h3/ddddocr/"><strong>探索本项目的文档 »</strong></a>
    <br />
    <br />
    ·
    <a href="https://github.com/sml2h3/ddddocr/issues">报告Bug</a>
    ·
    <a href="https://github.com/sml2h3/ddddocr/issues">提出新特性</a>
  </p>

</p>

 
## 目录

- [赞助合作商](#赞助合作商)
- [上手指南](#上手指南)
  - [环境支持](#环境支持)
  - [安装步骤](#安装步骤)
- [文件目录说明](#文件目录说明)
- [项目底层支持](#项目底层支持)
- [使用文档](#使用文档)
  - [基础ocr识别能力](#i-基础ocr识别能力)
  - [目标检测能力](#ii-目标检测能力)
  - [滑块检测](#ⅲ-滑块检测)
  - [OCR概率输出](#ⅳ-ocr概率输出)
  - [自定义OCR训练模型导入](#ⅴ-自定义ocr训练模型导入)
- [版本控制](#版本控制)
- [相关推荐文章or项目](#相关推荐文章or项目)
- [作者](#作者)
- [捐赠](#捐赠)
- [Star历史](#Star历史)



### 赞助合作商

|                                                            | 赞助合作商 | 推荐理由                                                                                             |
|------------------------------------------------------------|------------|--------------------------------------------------------------------------------------------------|
| ![YesCaptcha](https://cdn.wenanzhe.com/img/yescaptcha.png) | [YesCaptcha](https://yescaptcha.com/i/NSwk7i) | 谷歌reCaptcha验证码 / hCaptcha验证码 / funCaptcha验证码商业级识别接口 [点我](https://yescaptcha.com/i/NSwk7i) 直达VIP4 |
| ![超级鹰](https://cdn.wenanzhe.com/img/logo.gif) | [超级鹰](https://www.chaojiying.com/) | 全球领先的智能图片分类及识别商家,安全、准确、高效、稳定、开放,强大的技术及校验团队,支持大并发。7*24h作业进度管理 |
| ![Malenia](https://cdn.wenanzhe.com/img/malenia.png!/scale/50)    | [Malenia](https://malenia.iinti.cn/malenia-doc/) | Malenia企业级代理IP网关平台/代理IP分销软件 |
| 雨云VPS    | [注册首月5折](https://www.rainyun.com/ddddocr_) | 浙江节点低价大带宽,100M每月30元 |


### 上手指南

###### 环境支持



| 系统               | CPU | GPU | 最大支持py版本 | 备注                                                                 |
|------------------|-----|------|----------|--------------------------------------------------------------------|
| Windows 64位      | √   | √ | 3.12     | 部分版本windows需要安装<a href="https://www.ghxi.com/yxkhj.html">vc运行库</a> |
| Windows 32位      | ×   | × | -        |                                                                    |
| Linux 64 / ARM64 | √   | √ | 3.12     |                                                                    |
| Linux 32         | ×   | × | -        |                                                                    |
| Macos  X64       | √   | √ | 3.12     | M1/M2/M3...芯片参考<a href="https://github.com/sml2h3/ddddocr/issues/67">#67</a>         |

###### **安装步骤**

**i. 从pypi安装** 
```sh
pip install ddddocr
```

**ii. 从源码安装**
```sh
git clone https://github.com/sml2h3/ddddocr.git
cd ddddocr
python setup.py
```

**请勿直接在ddddocr项目的根目录内直接import ddddocr**,请确保你的开发项目目录名称不为ddddocr,此为基础常识。

### 文件目录说明
eg:

```
ddddocr 
├── MANIFEST.in
├── LICENSE
├── README.md
├── /ddddocr/
│  │── __init__.py            主代码库文件
│  │── common.onnx            新ocr模型
│  │── common_det.onnx        目标检测模型
│  │── common_old.onnx        老ocr模型
│  │── logo.png
│  │── README.md
│  │── requirements.txt
├── logo.png
└── setup.py

```

### 项目底层支持 

本项目基于[dddd_trainer](https://github.com/sml2h3/dddd_trainer) 训练所得,训练底层框架位pytorch,ddddocr推理底层抵赖于[onnxruntime](https://pypi.org/project/onnxruntime/),故本项目的最大兼容性与python版本支持主要取决于[onnxruntime](https://pypi.org/project/onnxruntime/)。

### 使用文档

##### i. 基础ocr识别能力

主要用于识别单行文字,即文字部分占据图片的主体部分,例如常见的英数验证码等,本项目可以对中文、英文(随机大小写or通过设置结果范围圈定大小写)、数字以及部分特殊字符。

```python
# example.py
import ddddocr

ocr = ddddocr.DdddOcr()

image = open("example.jpg", "rb").read()
result = ocr.classification(image)
print(result)
```

本库内置有两套ocr模型,默认情况下不会自动切换,需要在初始化ddddocr的时候通过参数进行切换

```python
# example.py
import ddddocr

ocr = ddddocr.DdddOcr(beta=True)  # 切换为第二套ocr模型

image = open("example.jpg", "rb").read()
result = ocr.classification(image)
print(result)
```

**提示**
对于部分透明黑色png格式图片得识别支持: `classification` 方法 使用 `png_fix` 参数,默认为False

```python
 ocr.classification(image, png_fix=True)
```

**注意**

之前发现很多人喜欢在每次ocr识别的时候都重新初始化ddddocr,即每次都执行```ocr = ddddocr.DdddOcr()```,这是错误的,通常来说只需要初始化一次即可,因为每次初始化和初始化后的第一次识别速度都非常慢


**参考例图**

包括且不限于以下图片

<img src="https://cdn.wenanzhe.com/img/20210715211733855.png" alt="captcha" width="150">
<img src="https://cdn.wenanzhe.com/img/78b7f57d-371d-4b65-afb2-d19608ae1892.png" alt="captcha" width="150">
<img src="https://cdn.wenanzhe.com/img/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20211226142305.png" alt="captcha" width="150">
<img src="https://cdn.wenanzhe.com/img/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20211226142325.png" alt="captcha" width="150">
<img src="https://cdn.wenanzhe.com/img/2AMLyA_fd83e1f1800e829033417ae6dd0e0ae0.png" alt="captcha" width="150">
<img src="https://cdn.wenanzhe.com/img/aabd_181ae81dd5526b8b89f987d1179266ce.jpg" alt="captcha" width="150">
<br />
<img src="https://cdn.wenanzhe.com/img/2bghz_b504e9f9de1ed7070102d21c6481e0cf.png" alt="captcha" width="150">
<img src="https://cdn.wenanzhe.com/img/0000_z4ecc2p65rxc610x.jpg" alt="captcha" width="150">
<img src="https://cdn.wenanzhe.com/img/2acd_0586b6b36858a4e8a9939db8a7ec07b7.jpg" alt="captcha" width="150">
<img src="https://cdn.wenanzhe.com/img/2a8r_79074e311d573d31e1630978fe04b990.jpg" alt="captcha" width="150">
<img src="https://cdn.wenanzhe.com/img/aftf_C2vHZlk8540y3qAmCM.bmp" alt="captcha" width="150">
<img src="https://cdn.wenanzhe.com/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20211226144057.png" alt="captcha" width="150">

##### ii. 目标检测能力

主要用于快速检测出图像中可能的目标主体位置,由于被检测出的目标不一定为文字,所以本功能仅提供目标的bbox位置 **(在⽬标检测⾥,我们通常使⽤bbox(bounding box,缩写是 bbox)来描述⽬标位置。bbox是⼀个矩形框,可以由矩形左上⻆的 x 和 y 轴坐标与右下⻆的 x 和 y 轴坐标确定)** 

如果使用过程中无需调用ocr功能,可以在初始化时通过传参`ocr=False`关闭ocr功能,开启目标检测需要传入参数`det=True`

```python
import ddddocr
import cv2

det = ddddocr.DdddOcr(det=True)

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

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

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

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

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

```



**参考例图**

包括且不限于以下图片

<img src="https://cdn.wenanzhe.com/img/page1_1.jpg" alt="captcha" width="200">
<img src="https://cdn.wenanzhe.com/img/page1_2.jpg" alt="captcha" width="200">
<img src="https://cdn.wenanzhe.com/img/page1_3.jpg" alt="captcha" width="200">
<img src="https://cdn.wenanzhe.com/img/page1_4.jpg" alt="captcha" width="200">
<br />
<img src="https://cdn.wenanzhe.com/img/result.jpg" alt="captcha" width="200">
<img src="https://cdn.wenanzhe.com/img/result2.jpg" alt="captcha" width="200">
<img src="https://cdn.wenanzhe.com/img/result4.jpg" alt="captcha" width="200">

##### Ⅲ. 滑块检测

本项目的滑块检测功能并非AI识别实现,均为opencv内置算法实现。可能对于截图党用户没那么友好~,如果使用过程中无需调用ocr功能或目标检测功能,可以在初始化时通过传参`ocr=False`关闭ocr功能或`det=False`来关闭目标检测功能

本功能内置两套算法实现,适用于两种不同情况,具体请参考以下说明

**a.算法1**

算法1原理是通过滑块图像的边缘在背景图中计算找到相对应的坑位,可以分别获取到滑块图和背景图,滑块图为透明背景图

滑块图

<img src="https://cdn.wenanzhe.com/img/b.png" alt="captcha" width="50">

背景图

<img src="https://cdn.wenanzhe.com/img/a.png" alt="captcha" width="350">

```python
    det = ddddocr.DdddOcr(det=False, ocr=False)
    
    with open('target.png', 'rb') as f:
        target_bytes = f.read()
    
    with open('background.png', 'rb') as f:
        background_bytes = f.read()
    
    res = det.slide_match(target_bytes, background_bytes)
    
    print(res)
  ```
  由于滑块图可能存在透明边框的问题,导致计算结果不一定准确,需要自行估算滑块图透明边框的宽度用于修正得出的bbox

  *提示:如果滑块无过多背景部分,则可以添加simple_target参数, 通常为jpg或者bmp格式的图片*

```python
    slide = ddddocr.DdddOcr(det=False, ocr=False)
    
    with open('target.jpg', 'rb') as f:
        target_bytes = f.read()
    
    with open('background.jpg', 'rb') as f:
        background_bytes = f.read()
    
    res = slide.slide_match(target_bytes, background_bytes, simple_target=True)
    
    print(res)
  ```

**a.算法2**

算法2是通过比较两张图的不同之处进行判断滑块目标坑位的位置

参考图a,带有目标坑位阴影的全图

<img src="https://cdn.wenanzhe.com/img/bg.jpg" alt="captcha" width="350">

参考图b,全图

<img src="https://cdn.wenanzhe.com/img/fullpage.jpg" alt="captcha" width="350">

```python
    slide = ddddocr.DdddOcr(det=False, ocr=False)

    with open('bg.jpg', 'rb') as f:
        target_bytes = f.read()
    
    with open('fullpage.jpg', 'rb') as f:
        background_bytes = f.read()
    
    img = cv2.imread("bg.jpg")
    
    res = slide.slide_comparison(target_bytes, background_bytes)

    print(res)
  ```

##### Ⅳ. OCR概率输出

为了提供更灵活的ocr结果控制与范围限定,项目支持对ocr结果进行范围限定。

可以通过在调用`classification`方法的时候传参`probability=True`,此时`classification`方法将返回全字符表的概率
当然也可以通过`set_ranges`方法设置输出字符范围来限定返回的结果。

Ⅰ. `set_ranges` 方法限定返回字符返回

本方法接受1个参数,如果输入为int类型为内置的字符集限制,string类型则为自定义的字符集

如果为int类型,请参考下表

| 参数值 | 意义                                |
|-----|-----------------------------------|
| 0   | 纯整数0-9                            |
| 1   | 纯小写英文a-z                          |
| 2   | 纯大写英文A-Z                          |
| 3   | 小写英文a-z + 大写英文A-Z                 |
| 4   | 小写英文a-z + 整数0-9                   |
| 5   | 大写英文A-Z + 整数0-9                   |
| 6   | 小写英文a-z + 大写英文A-Z + 整数0-9         |
| 7   | 默认字符库 - 小写英文a-z - 大写英文A-Z - 整数0-9 |

如果为string类型请传入一段不包含空格的文本,其中的每个字符均为一个待选词
如:`"0123456789+-x/=""`

```python
import ddddocr

ocr = ddddocr.DdddOcr()

image = open("test.jpg", "rb").read()
ocr.set_ranges("0123456789+-x/=")
result = ocr.classification(image, probability=True)
s = ""
for i in result['probability']:
    s += result['charsets'][i.index(max(i))]

print(s)

```

##### Ⅴ. 自定义OCR训练模型导入

本项目支持导入来自于 [dddd_trainer](https://github.com/sml2h3/dddd_trainer) 进行自定义训练后的模型,参考导入代码为

```python
import ddddocr

ocr = ddddocr.DdddOcr(det=False, ocr=False, import_onnx_path="myproject_0.984375_139_13000_2022-02-26-15-34-13.onnx", charsets_path="charsets.json")

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

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

```

### 版本控制

该项目使用Git进行版本管理。您可以在repository参看当前可用版本。

### 相关推荐文章or项目

[带带弟弟OCR,纯VBA本地获取网络验证码整体解决方案](https://club.excelhome.net/thread-1666823-1-1.html)

[ddddocr rust 版本](https://github.com/86maid/ddddocr)

[captcha-killer的修改版](https://github.com/f0ng/captcha-killer-modified)

[通过ddddocr训练字母数字验证码模型并识别部署调用](https://www.bilibili.com/video/BV1ez421C7dB)

...

欢迎更多优秀案例或教程等进行投稿,可直接新建issue标题以【投稿】开头,附上公开教程站点链接,我会选择根据文章内容选择相对不重复或者有重点内容等进行readme展示,感谢各位朋友~

### 作者

sml2h3@gamil.com
 
<img src="https://cdn.wenanzhe.com/img/mmqrcode1640418911274.png!/scale/50" alt="wechat" width="150">

 *好友数过多不一定通过,有问题可以在issue进行交流*

### 版权说明

该项目签署了MIT 授权许可,详情请参阅 [LICENSE](https://github.com/sml2h3/ddddocr/blob/master/LICENSE)

### 捐赠 (如果项目有帮助到您,可以选择捐赠一些费用用于ddddocr的后续版本维护,本项目长期维护)

<img src="https://cdn.wenanzhe.com/img/zhifubao.jpg" alt="captcha" width="150">
<img src="https://cdn.wenanzhe.com/img/weixin.jpg" alt="captcha" width="150">


<!-- links -->
[your-project-path]:sml2h3/ddddocr
[contributors-shield]: https://img.shields.io/github/contributors/sml2h3/ddddocr?style=flat-square
[contributors-url]: https://github.com/shaojintian/Best_README_template/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/sml2h3/ddddocr?style=flat-square
[forks-url]: https://github.com/shaojintian/Best_README_template/network/members
[stars-shield]: https://img.shields.io/github/stars/sml2h3/ddddocr?style=flat-square
[stars-url]: https://github.com/shaojintian/Best_README_template/stargazers
[issues-shield]: https://img.shields.io/github/issues/sml2h3/ddddocr?style=flat-square
[issues-url]: https://img.shields.io/github/issues/sml2h3/ddddocr.svg
[license-shield]: https://img.shields.io/github/license/sml2h3/ddddocr?style=flat-square
[license-url]: https://github.com/sml2h3/ddddocr/blob/master/LICENSE


### Star 历史

[![Star History Chart](https://api.star-history.com/svg?repos=sml2h3/ddddocr&type=Date)](https://star-history.com/#sml2h3/ddddocr&Date)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sml2h3/ddddocr",
    "name": "ddddocr",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.13",
    "maintainer_email": null,
    "keywords": null,
    "author": "sml2h3",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/0e/cf/1243d5f0d03763a287375366f68eadb5c14418f5b3df00c09eb971e526a7/ddddocr-1.5.6.tar.gz",
    "platform": null,
    "description": "\r\n\r\n# DdddOcr \u5e26\u5e26\u5f1f\u5f1fOCR\u901a\u7528\u9a8c\u8bc1\u7801\u79bb\u7ebf\u672c\u5730\u8bc6\u522bSDK\u514d\u8d39\u5f00\u6e90\u7248\r\n\r\nDdddOcr\uff0c\u5176\u7531 [\u672c\u4f5c\u8005](https://github.com/sml2h3) \u4e0e [kerlomz](https://github.com/kerlomz) \u5171\u540c\u5408\u4f5c\u5b8c\u6210\uff0c\u901a\u8fc7\u5927\u6279\u91cf\u751f\u6210\u968f\u673a\u6570\u636e\u540e\u8fdb\u884c\u6df1\u5ea6\u7f51\u7edc\u8bad\u7ec3\uff0c\u672c\u8eab\u5e76\u975e\u9488\u5bf9\u4efb\u4f55\u4e00\u5bb6\u9a8c\u8bc1\u7801\u5382\u5546\u800c\u5236\u4f5c\uff0c\u672c\u5e93\u4f7f\u7528\u6548\u679c\u5b8c\u5168\u9760\u7384\u5b66\uff0c\u53ef\u80fd\u53ef\u4ee5\u8bc6\u522b\uff0c\u53ef\u80fd\u4e0d\u80fd\u8bc6\u522b\u3002\r\n\r\nDdddOcr\u3001\u6700\u7b80\u4f9d\u8d56\u7684\u7406\u5ff5\uff0c\u5c3d\u91cf\u51cf\u5c11\u7528\u6237\u7684\u914d\u7f6e\u548c\u4f7f\u7528\u6210\u672c\uff0c\u5e0c\u671b\u7ed9\u6bcf\u4e00\u4f4d\u6d4b\u8bd5\u8005\u5e26\u6765\u8212\u9002\u7684\u4f53\u9a8c\r\n\r\n\u9879\u76ee\u5730\u5740\uff1a [\u70b9\u6211\u4f20\u9001](https://github.com/sml2h3/ddddocr) \r\n\r\n<!-- PROJECT SHIELDS -->\r\n\r\n[![Contributors][contributors-shield]][contributors-url]\r\n[![Forks][forks-shield]][forks-url]\r\n[![Stargazers][stars-shield]][stars-url]\r\n[![Issues][issues-shield]][issues-url]\r\n[![MIT License][license-shield]][license-url]\r\n\r\n<!-- PROJECT LOGO -->\r\n<br />\r\n\r\n<p align=\"center\">\r\n  <a href=\"https://github.com/sml2h3/ddddocr/\">\r\n    <img src=\"https://cdn.wenanzhe.com/img/logo.png!/crop/700x500a400a500\" alt=\"Logo\">\r\n  </a>\r\n  <p align=\"center\">\r\n    \u4e00\u4e2a\u5bb9\u6613\u4f7f\u7528\u7684\u901a\u7528\u9a8c\u8bc1\u7801\u8bc6\u522bpython\u5e93\r\n    <br />\r\n    <a href=\"https://github.com/sml2h3/ddddocr/\"><strong>\u63a2\u7d22\u672c\u9879\u76ee\u7684\u6587\u6863 \u00bb</strong></a>\r\n    <br />\r\n    <br />\r\n    \u00b7\r\n    <a href=\"https://github.com/sml2h3/ddddocr/issues\">\u62a5\u544aBug</a>\r\n    \u00b7\r\n    <a href=\"https://github.com/sml2h3/ddddocr/issues\">\u63d0\u51fa\u65b0\u7279\u6027</a>\r\n  </p>\r\n\r\n</p>\r\n\r\n \r\n## \u76ee\u5f55\r\n\r\n- [\u8d5e\u52a9\u5408\u4f5c\u5546](#\u8d5e\u52a9\u5408\u4f5c\u5546)\r\n- [\u4e0a\u624b\u6307\u5357](#\u4e0a\u624b\u6307\u5357)\r\n  - [\u73af\u5883\u652f\u6301](#\u73af\u5883\u652f\u6301)\r\n  - [\u5b89\u88c5\u6b65\u9aa4](#\u5b89\u88c5\u6b65\u9aa4)\r\n- [\u6587\u4ef6\u76ee\u5f55\u8bf4\u660e](#\u6587\u4ef6\u76ee\u5f55\u8bf4\u660e)\r\n- [\u9879\u76ee\u5e95\u5c42\u652f\u6301](#\u9879\u76ee\u5e95\u5c42\u652f\u6301)\r\n- [\u4f7f\u7528\u6587\u6863](#\u4f7f\u7528\u6587\u6863)\r\n  - [\u57fa\u7840ocr\u8bc6\u522b\u80fd\u529b](#i-\u57fa\u7840ocr\u8bc6\u522b\u80fd\u529b)\r\n  - [\u76ee\u6807\u68c0\u6d4b\u80fd\u529b](#ii-\u76ee\u6807\u68c0\u6d4b\u80fd\u529b)\r\n  - [\u6ed1\u5757\u68c0\u6d4b](#\u2172-\u6ed1\u5757\u68c0\u6d4b)\r\n  - [OCR\u6982\u7387\u8f93\u51fa](#\u2173-ocr\u6982\u7387\u8f93\u51fa)\r\n  - [\u81ea\u5b9a\u4e49OCR\u8bad\u7ec3\u6a21\u578b\u5bfc\u5165](#\u2174-\u81ea\u5b9a\u4e49ocr\u8bad\u7ec3\u6a21\u578b\u5bfc\u5165)\r\n- [\u7248\u672c\u63a7\u5236](#\u7248\u672c\u63a7\u5236)\r\n- [\u76f8\u5173\u63a8\u8350\u6587\u7ae0or\u9879\u76ee](#\u76f8\u5173\u63a8\u8350\u6587\u7ae0or\u9879\u76ee)\r\n- [\u4f5c\u8005](#\u4f5c\u8005)\r\n- [\u6350\u8d60](#\u6350\u8d60)\r\n- [Star\u5386\u53f2](#Star\u5386\u53f2)\r\n\r\n\r\n\r\n### \u8d5e\u52a9\u5408\u4f5c\u5546\r\n\r\n|                                                            | \u8d5e\u52a9\u5408\u4f5c\u5546 | \u63a8\u8350\u7406\u7531                                                                                             |\r\n|------------------------------------------------------------|------------|--------------------------------------------------------------------------------------------------|\r\n| ![YesCaptcha](https://cdn.wenanzhe.com/img/yescaptcha.png) | [YesCaptcha](https://yescaptcha.com/i/NSwk7i) | \u8c37\u6b4creCaptcha\u9a8c\u8bc1\u7801 / hCaptcha\u9a8c\u8bc1\u7801 / funCaptcha\u9a8c\u8bc1\u7801\u5546\u4e1a\u7ea7\u8bc6\u522b\u63a5\u53e3 [\u70b9\u6211](https://yescaptcha.com/i/NSwk7i) \u76f4\u8fbeVIP4 |\r\n| ![\u8d85\u7ea7\u9e70](https://cdn.wenanzhe.com/img/logo.gif) | [\u8d85\u7ea7\u9e70](https://www.chaojiying.com/) | \u5168\u7403\u9886\u5148\u7684\u667a\u80fd\u56fe\u7247\u5206\u7c7b\u53ca\u8bc6\u522b\u5546\u5bb6\uff0c\u5b89\u5168\u3001\u51c6\u786e\u3001\u9ad8\u6548\u3001\u7a33\u5b9a\u3001\u5f00\u653e\uff0c\u5f3a\u5927\u7684\u6280\u672f\u53ca\u6821\u9a8c\u56e2\u961f\uff0c\u652f\u6301\u5927\u5e76\u53d1\u30027*24h\u4f5c\u4e1a\u8fdb\u5ea6\u7ba1\u7406 |\r\n| ![Malenia](https://cdn.wenanzhe.com/img/malenia.png!/scale/50)    | [Malenia](https://malenia.iinti.cn/malenia-doc/) | Malenia\u4f01\u4e1a\u7ea7\u4ee3\u7406IP\u7f51\u5173\u5e73\u53f0/\u4ee3\u7406IP\u5206\u9500\u8f6f\u4ef6 |\r\n| \u96e8\u4e91VPS    | [\u6ce8\u518c\u9996\u67085\u6298](https://www.rainyun.com/ddddocr_) | \u6d59\u6c5f\u8282\u70b9\u4f4e\u4ef7\u5927\u5e26\u5bbd\uff0c100M\u6bcf\u670830\u5143 |\r\n\r\n\r\n### \u4e0a\u624b\u6307\u5357\r\n\r\n###### \u73af\u5883\u652f\u6301\r\n\r\n\r\n\r\n| \u7cfb\u7edf               | CPU | GPU | \u6700\u5927\u652f\u6301py\u7248\u672c | \u5907\u6ce8                                                                 |\r\n|------------------|-----|------|----------|--------------------------------------------------------------------|\r\n| Windows 64\u4f4d      | \u221a   | \u221a | 3.12     | \u90e8\u5206\u7248\u672cwindows\u9700\u8981\u5b89\u88c5<a href=\"https://www.ghxi.com/yxkhj.html\">vc\u8fd0\u884c\u5e93</a> |\r\n| Windows 32\u4f4d      | \u00d7   | \u00d7 | -        |                                                                    |\r\n| Linux 64 / ARM64 | \u221a   | \u221a | 3.12     |                                                                    |\r\n| Linux 32         | \u00d7   | \u00d7 | -        |                                                                    |\r\n| Macos  X64       | \u221a   | \u221a | 3.12     | M1/M2/M3...\u82af\u7247\u53c2\u8003<a href=\"https://github.com/sml2h3/ddddocr/issues/67\">#67</a>         |\r\n\r\n###### **\u5b89\u88c5\u6b65\u9aa4**\r\n\r\n**i. \u4ecepypi\u5b89\u88c5** \r\n```sh\r\npip install ddddocr\r\n```\r\n\r\n**ii. \u4ece\u6e90\u7801\u5b89\u88c5**\r\n```sh\r\ngit clone https://github.com/sml2h3/ddddocr.git\r\ncd ddddocr\r\npython setup.py\r\n```\r\n\r\n**\u8bf7\u52ff\u76f4\u63a5\u5728ddddocr\u9879\u76ee\u7684\u6839\u76ee\u5f55\u5185\u76f4\u63a5import ddddocr**\uff0c\u8bf7\u786e\u4fdd\u4f60\u7684\u5f00\u53d1\u9879\u76ee\u76ee\u5f55\u540d\u79f0\u4e0d\u4e3addddocr\uff0c\u6b64\u4e3a\u57fa\u7840\u5e38\u8bc6\u3002\r\n\r\n### \u6587\u4ef6\u76ee\u5f55\u8bf4\u660e\r\neg:\r\n\r\n```\r\nddddocr \r\n\u251c\u2500\u2500 MANIFEST.in\r\n\u251c\u2500\u2500 LICENSE\r\n\u251c\u2500\u2500 README.md\r\n\u251c\u2500\u2500 /ddddocr/\r\n\u2502  \u2502\u2500\u2500 __init__.py            \u4e3b\u4ee3\u7801\u5e93\u6587\u4ef6\r\n\u2502  \u2502\u2500\u2500 common.onnx            \u65b0ocr\u6a21\u578b\r\n\u2502  \u2502\u2500\u2500 common_det.onnx        \u76ee\u6807\u68c0\u6d4b\u6a21\u578b\r\n\u2502  \u2502\u2500\u2500 common_old.onnx        \u8001ocr\u6a21\u578b\r\n\u2502  \u2502\u2500\u2500 logo.png\r\n\u2502  \u2502\u2500\u2500 README.md\r\n\u2502  \u2502\u2500\u2500 requirements.txt\r\n\u251c\u2500\u2500 logo.png\r\n\u2514\u2500\u2500 setup.py\r\n\r\n```\r\n\r\n### \u9879\u76ee\u5e95\u5c42\u652f\u6301 \r\n\r\n\u672c\u9879\u76ee\u57fa\u4e8e[dddd_trainer](https://github.com/sml2h3/dddd_trainer) \u8bad\u7ec3\u6240\u5f97\uff0c\u8bad\u7ec3\u5e95\u5c42\u6846\u67b6\u4f4dpytorch\uff0cddddocr\u63a8\u7406\u5e95\u5c42\u62b5\u8d56\u4e8e[onnxruntime](https://pypi.org/project/onnxruntime/)\uff0c\u6545\u672c\u9879\u76ee\u7684\u6700\u5927\u517c\u5bb9\u6027\u4e0epython\u7248\u672c\u652f\u6301\u4e3b\u8981\u53d6\u51b3\u4e8e[onnxruntime](https://pypi.org/project/onnxruntime/)\u3002\r\n\r\n### \u4f7f\u7528\u6587\u6863\r\n\r\n##### i. \u57fa\u7840ocr\u8bc6\u522b\u80fd\u529b\r\n\r\n\u4e3b\u8981\u7528\u4e8e\u8bc6\u522b\u5355\u884c\u6587\u5b57\uff0c\u5373\u6587\u5b57\u90e8\u5206\u5360\u636e\u56fe\u7247\u7684\u4e3b\u4f53\u90e8\u5206\uff0c\u4f8b\u5982\u5e38\u89c1\u7684\u82f1\u6570\u9a8c\u8bc1\u7801\u7b49\uff0c\u672c\u9879\u76ee\u53ef\u4ee5\u5bf9\u4e2d\u6587\u3001\u82f1\u6587\uff08\u968f\u673a\u5927\u5c0f\u5199or\u901a\u8fc7\u8bbe\u7f6e\u7ed3\u679c\u8303\u56f4\u5708\u5b9a\u5927\u5c0f\u5199\uff09\u3001\u6570\u5b57\u4ee5\u53ca\u90e8\u5206\u7279\u6b8a\u5b57\u7b26\u3002\r\n\r\n```python\r\n# example.py\r\nimport ddddocr\r\n\r\nocr = ddddocr.DdddOcr()\r\n\r\nimage = open(\"example.jpg\", \"rb\").read()\r\nresult = ocr.classification(image)\r\nprint(result)\r\n```\r\n\r\n\u672c\u5e93\u5185\u7f6e\u6709\u4e24\u5957ocr\u6a21\u578b\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4e0d\u4f1a\u81ea\u52a8\u5207\u6362\uff0c\u9700\u8981\u5728\u521d\u59cb\u5316ddddocr\u7684\u65f6\u5019\u901a\u8fc7\u53c2\u6570\u8fdb\u884c\u5207\u6362\r\n\r\n```python\r\n# example.py\r\nimport ddddocr\r\n\r\nocr = ddddocr.DdddOcr(beta=True)  # \u5207\u6362\u4e3a\u7b2c\u4e8c\u5957ocr\u6a21\u578b\r\n\r\nimage = open(\"example.jpg\", \"rb\").read()\r\nresult = ocr.classification(image)\r\nprint(result)\r\n```\r\n\r\n**\u63d0\u793a**\r\n\u5bf9\u4e8e\u90e8\u5206\u900f\u660e\u9ed1\u8272png\u683c\u5f0f\u56fe\u7247\u5f97\u8bc6\u522b\u652f\u6301: `classification` \u65b9\u6cd5 \u4f7f\u7528 `png_fix` \u53c2\u6570\uff0c\u9ed8\u8ba4\u4e3aFalse\r\n\r\n```python\r\n ocr.classification(image, png_fix=True)\r\n```\r\n\r\n**\u6ce8\u610f**\r\n\r\n\u4e4b\u524d\u53d1\u73b0\u5f88\u591a\u4eba\u559c\u6b22\u5728\u6bcf\u6b21ocr\u8bc6\u522b\u7684\u65f6\u5019\u90fd\u91cd\u65b0\u521d\u59cb\u5316ddddocr\uff0c\u5373\u6bcf\u6b21\u90fd\u6267\u884c```ocr = ddddocr.DdddOcr()```\uff0c\u8fd9\u662f\u9519\u8bef\u7684\uff0c\u901a\u5e38\u6765\u8bf4\u53ea\u9700\u8981\u521d\u59cb\u5316\u4e00\u6b21\u5373\u53ef\uff0c\u56e0\u4e3a\u6bcf\u6b21\u521d\u59cb\u5316\u548c\u521d\u59cb\u5316\u540e\u7684\u7b2c\u4e00\u6b21\u8bc6\u522b\u901f\u5ea6\u90fd\u975e\u5e38\u6162\r\n\r\n\r\n**\u53c2\u8003\u4f8b\u56fe**\r\n\r\n\u5305\u62ec\u4e14\u4e0d\u9650\u4e8e\u4ee5\u4e0b\u56fe\u7247\r\n\r\n<img src=\"https://cdn.wenanzhe.com/img/20210715211733855.png\" alt=\"captcha\" width=\"150\">\r\n<img src=\"https://cdn.wenanzhe.com/img/78b7f57d-371d-4b65-afb2-d19608ae1892.png\" alt=\"captcha\" width=\"150\">\r\n<img src=\"https://cdn.wenanzhe.com/img/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20211226142305.png\" alt=\"captcha\" width=\"150\">\r\n<img src=\"https://cdn.wenanzhe.com/img/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20211226142325.png\" alt=\"captcha\" width=\"150\">\r\n<img src=\"https://cdn.wenanzhe.com/img/2AMLyA_fd83e1f1800e829033417ae6dd0e0ae0.png\" alt=\"captcha\" width=\"150\">\r\n<img src=\"https://cdn.wenanzhe.com/img/aabd_181ae81dd5526b8b89f987d1179266ce.jpg\" alt=\"captcha\" width=\"150\">\r\n<br />\r\n<img src=\"https://cdn.wenanzhe.com/img/2bghz_b504e9f9de1ed7070102d21c6481e0cf.png\" alt=\"captcha\" width=\"150\">\r\n<img src=\"https://cdn.wenanzhe.com/img/0000_z4ecc2p65rxc610x.jpg\" alt=\"captcha\" width=\"150\">\r\n<img src=\"https://cdn.wenanzhe.com/img/2acd_0586b6b36858a4e8a9939db8a7ec07b7.jpg\" alt=\"captcha\" width=\"150\">\r\n<img src=\"https://cdn.wenanzhe.com/img/2a8r_79074e311d573d31e1630978fe04b990.jpg\" alt=\"captcha\" width=\"150\">\r\n<img src=\"https://cdn.wenanzhe.com/img/aftf_C2vHZlk8540y3qAmCM.bmp\" alt=\"captcha\" width=\"150\">\r\n<img src=\"https://cdn.wenanzhe.com/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20211226144057.png\" alt=\"captcha\" width=\"150\">\r\n\r\n##### ii. \u76ee\u6807\u68c0\u6d4b\u80fd\u529b\r\n\r\n\u4e3b\u8981\u7528\u4e8e\u5feb\u901f\u68c0\u6d4b\u51fa\u56fe\u50cf\u4e2d\u53ef\u80fd\u7684\u76ee\u6807\u4e3b\u4f53\u4f4d\u7f6e\uff0c\u7531\u4e8e\u88ab\u68c0\u6d4b\u51fa\u7684\u76ee\u6807\u4e0d\u4e00\u5b9a\u4e3a\u6587\u5b57\uff0c\u6240\u4ee5\u672c\u529f\u80fd\u4ec5\u63d0\u4f9b\u76ee\u6807\u7684bbox\u4f4d\u7f6e **\uff08\u5728\u2f6c\u6807\u68c0\u6d4b\u2fa5\uff0c\u6211\u4eec\u901a\u5e38\u4f7f\u2f64bbox\uff08bounding box\uff0c\u7f29\u5199\u662f bbox\uff09\u6765\u63cf\u8ff0\u2f6c\u6807\u4f4d\u7f6e\u3002bbox\u662f\u2f00\u4e2a\u77e9\u5f62\u6846\uff0c\u53ef\u4ee5\u7531\u77e9\u5f62\u5de6\u4e0a\u2ec6\u7684 x \u548c y \u8f74\u5750\u6807\u4e0e\u53f3\u4e0b\u2ec6\u7684 x \u548c y \u8f74\u5750\u6807\u786e\u5b9a\uff09** \r\n\r\n\u5982\u679c\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u65e0\u9700\u8c03\u7528ocr\u529f\u80fd\uff0c\u53ef\u4ee5\u5728\u521d\u59cb\u5316\u65f6\u901a\u8fc7\u4f20\u53c2`ocr=False`\u5173\u95edocr\u529f\u80fd\uff0c\u5f00\u542f\u76ee\u6807\u68c0\u6d4b\u9700\u8981\u4f20\u5165\u53c2\u6570`det=True`\r\n\r\n```python\r\nimport ddddocr\r\nimport cv2\r\n\r\ndet = ddddocr.DdddOcr(det=True)\r\n\r\nwith open(\"test.jpg\", 'rb') as f:\r\n    image = f.read()\r\n\r\nbboxes = det.detection(image)\r\nprint(bboxes)\r\n\r\nim = cv2.imread(\"test.jpg\")\r\n\r\nfor bbox in bboxes:\r\n    x1, y1, x2, y2 = bbox\r\n    im = cv2.rectangle(im, (x1, y1), (x2, y2), color=(0, 0, 255), thickness=2)\r\n\r\ncv2.imwrite(\"result.jpg\", im)\r\n\r\n```\r\n\r\n\r\n\r\n**\u53c2\u8003\u4f8b\u56fe**\r\n\r\n\u5305\u62ec\u4e14\u4e0d\u9650\u4e8e\u4ee5\u4e0b\u56fe\u7247\r\n\r\n<img src=\"https://cdn.wenanzhe.com/img/page1_1.jpg\" alt=\"captcha\" width=\"200\">\r\n<img src=\"https://cdn.wenanzhe.com/img/page1_2.jpg\" alt=\"captcha\" width=\"200\">\r\n<img src=\"https://cdn.wenanzhe.com/img/page1_3.jpg\" alt=\"captcha\" width=\"200\">\r\n<img src=\"https://cdn.wenanzhe.com/img/page1_4.jpg\" alt=\"captcha\" width=\"200\">\r\n<br />\r\n<img src=\"https://cdn.wenanzhe.com/img/result.jpg\" alt=\"captcha\" width=\"200\">\r\n<img src=\"https://cdn.wenanzhe.com/img/result2.jpg\" alt=\"captcha\" width=\"200\">\r\n<img src=\"https://cdn.wenanzhe.com/img/result4.jpg\" alt=\"captcha\" width=\"200\">\r\n\r\n##### \u2162. \u6ed1\u5757\u68c0\u6d4b\r\n\r\n\u672c\u9879\u76ee\u7684\u6ed1\u5757\u68c0\u6d4b\u529f\u80fd\u5e76\u975eAI\u8bc6\u522b\u5b9e\u73b0\uff0c\u5747\u4e3aopencv\u5185\u7f6e\u7b97\u6cd5\u5b9e\u73b0\u3002\u53ef\u80fd\u5bf9\u4e8e\u622a\u56fe\u515a\u7528\u6237\u6ca1\u90a3\u4e48\u53cb\u597d~\uff0c\u5982\u679c\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u65e0\u9700\u8c03\u7528ocr\u529f\u80fd\u6216\u76ee\u6807\u68c0\u6d4b\u529f\u80fd\uff0c\u53ef\u4ee5\u5728\u521d\u59cb\u5316\u65f6\u901a\u8fc7\u4f20\u53c2`ocr=False`\u5173\u95edocr\u529f\u80fd\u6216`det=False`\u6765\u5173\u95ed\u76ee\u6807\u68c0\u6d4b\u529f\u80fd\r\n\r\n\u672c\u529f\u80fd\u5185\u7f6e\u4e24\u5957\u7b97\u6cd5\u5b9e\u73b0\uff0c\u9002\u7528\u4e8e\u4e24\u79cd\u4e0d\u540c\u60c5\u51b5\uff0c\u5177\u4f53\u8bf7\u53c2\u8003\u4ee5\u4e0b\u8bf4\u660e\r\n\r\n**a.\u7b97\u6cd51**\r\n\r\n\u7b97\u6cd51\u539f\u7406\u662f\u901a\u8fc7\u6ed1\u5757\u56fe\u50cf\u7684\u8fb9\u7f18\u5728\u80cc\u666f\u56fe\u4e2d\u8ba1\u7b97\u627e\u5230\u76f8\u5bf9\u5e94\u7684\u5751\u4f4d\uff0c\u53ef\u4ee5\u5206\u522b\u83b7\u53d6\u5230\u6ed1\u5757\u56fe\u548c\u80cc\u666f\u56fe\uff0c\u6ed1\u5757\u56fe\u4e3a\u900f\u660e\u80cc\u666f\u56fe\r\n\r\n\u6ed1\u5757\u56fe\r\n\r\n<img src=\"https://cdn.wenanzhe.com/img/b.png\" alt=\"captcha\" width=\"50\">\r\n\r\n\u80cc\u666f\u56fe\r\n\r\n<img src=\"https://cdn.wenanzhe.com/img/a.png\" alt=\"captcha\" width=\"350\">\r\n\r\n```python\r\n    det = ddddocr.DdddOcr(det=False, ocr=False)\r\n    \r\n    with open('target.png', 'rb') as f:\r\n        target_bytes = f.read()\r\n    \r\n    with open('background.png', 'rb') as f:\r\n        background_bytes = f.read()\r\n    \r\n    res = det.slide_match(target_bytes, background_bytes)\r\n    \r\n    print(res)\r\n  ```\r\n  \u7531\u4e8e\u6ed1\u5757\u56fe\u53ef\u80fd\u5b58\u5728\u900f\u660e\u8fb9\u6846\u7684\u95ee\u9898\uff0c\u5bfc\u81f4\u8ba1\u7b97\u7ed3\u679c\u4e0d\u4e00\u5b9a\u51c6\u786e\uff0c\u9700\u8981\u81ea\u884c\u4f30\u7b97\u6ed1\u5757\u56fe\u900f\u660e\u8fb9\u6846\u7684\u5bbd\u5ea6\u7528\u4e8e\u4fee\u6b63\u5f97\u51fa\u7684bbox\r\n\r\n  *\u63d0\u793a\uff1a\u5982\u679c\u6ed1\u5757\u65e0\u8fc7\u591a\u80cc\u666f\u90e8\u5206\uff0c\u5219\u53ef\u4ee5\u6dfb\u52a0simple_target\u53c2\u6570\uff0c \u901a\u5e38\u4e3ajpg\u6216\u8005bmp\u683c\u5f0f\u7684\u56fe\u7247*\r\n\r\n```python\r\n    slide = ddddocr.DdddOcr(det=False, ocr=False)\r\n    \r\n    with open('target.jpg', 'rb') as f:\r\n        target_bytes = f.read()\r\n    \r\n    with open('background.jpg', 'rb') as f:\r\n        background_bytes = f.read()\r\n    \r\n    res = slide.slide_match(target_bytes, background_bytes, simple_target=True)\r\n    \r\n    print(res)\r\n  ```\r\n\r\n**a.\u7b97\u6cd52**\r\n\r\n\u7b97\u6cd52\u662f\u901a\u8fc7\u6bd4\u8f83\u4e24\u5f20\u56fe\u7684\u4e0d\u540c\u4e4b\u5904\u8fdb\u884c\u5224\u65ad\u6ed1\u5757\u76ee\u6807\u5751\u4f4d\u7684\u4f4d\u7f6e\r\n\r\n\u53c2\u8003\u56fea\uff0c\u5e26\u6709\u76ee\u6807\u5751\u4f4d\u9634\u5f71\u7684\u5168\u56fe\r\n\r\n<img src=\"https://cdn.wenanzhe.com/img/bg.jpg\" alt=\"captcha\" width=\"350\">\r\n\r\n\u53c2\u8003\u56feb\uff0c\u5168\u56fe\r\n\r\n<img src=\"https://cdn.wenanzhe.com/img/fullpage.jpg\" alt=\"captcha\" width=\"350\">\r\n\r\n```python\r\n    slide = ddddocr.DdddOcr(det=False, ocr=False)\r\n\r\n    with open('bg.jpg', 'rb') as f:\r\n        target_bytes = f.read()\r\n    \r\n    with open('fullpage.jpg', 'rb') as f:\r\n        background_bytes = f.read()\r\n    \r\n    img = cv2.imread(\"bg.jpg\")\r\n    \r\n    res = slide.slide_comparison(target_bytes, background_bytes)\r\n\r\n    print(res)\r\n  ```\r\n\r\n##### \u2163. OCR\u6982\u7387\u8f93\u51fa\r\n\r\n\u4e3a\u4e86\u63d0\u4f9b\u66f4\u7075\u6d3b\u7684ocr\u7ed3\u679c\u63a7\u5236\u4e0e\u8303\u56f4\u9650\u5b9a\uff0c\u9879\u76ee\u652f\u6301\u5bf9ocr\u7ed3\u679c\u8fdb\u884c\u8303\u56f4\u9650\u5b9a\u3002\r\n\r\n\u53ef\u4ee5\u901a\u8fc7\u5728\u8c03\u7528`classification`\u65b9\u6cd5\u7684\u65f6\u5019\u4f20\u53c2`probability=True`\uff0c\u6b64\u65f6`classification`\u65b9\u6cd5\u5c06\u8fd4\u56de\u5168\u5b57\u7b26\u8868\u7684\u6982\u7387\r\n\u5f53\u7136\u4e5f\u53ef\u4ee5\u901a\u8fc7`set_ranges`\u65b9\u6cd5\u8bbe\u7f6e\u8f93\u51fa\u5b57\u7b26\u8303\u56f4\u6765\u9650\u5b9a\u8fd4\u56de\u7684\u7ed3\u679c\u3002\r\n\r\n\u2160. `set_ranges` \u65b9\u6cd5\u9650\u5b9a\u8fd4\u56de\u5b57\u7b26\u8fd4\u56de\r\n\r\n\u672c\u65b9\u6cd5\u63a5\u53d71\u4e2a\u53c2\u6570\uff0c\u5982\u679c\u8f93\u5165\u4e3aint\u7c7b\u578b\u4e3a\u5185\u7f6e\u7684\u5b57\u7b26\u96c6\u9650\u5236\uff0cstring\u7c7b\u578b\u5219\u4e3a\u81ea\u5b9a\u4e49\u7684\u5b57\u7b26\u96c6\r\n\r\n\u5982\u679c\u4e3aint\u7c7b\u578b\uff0c\u8bf7\u53c2\u8003\u4e0b\u8868\r\n\r\n| \u53c2\u6570\u503c | \u610f\u4e49                                |\r\n|-----|-----------------------------------|\r\n| 0   | \u7eaf\u6574\u65700-9                            |\r\n| 1   | \u7eaf\u5c0f\u5199\u82f1\u6587a-z                          |\r\n| 2   | \u7eaf\u5927\u5199\u82f1\u6587A-Z                          |\r\n| 3   | \u5c0f\u5199\u82f1\u6587a-z + \u5927\u5199\u82f1\u6587A-Z                 |\r\n| 4   | \u5c0f\u5199\u82f1\u6587a-z + \u6574\u65700-9                   |\r\n| 5   | \u5927\u5199\u82f1\u6587A-Z + \u6574\u65700-9                   |\r\n| 6   | \u5c0f\u5199\u82f1\u6587a-z + \u5927\u5199\u82f1\u6587A-Z + \u6574\u65700-9         |\r\n| 7   | \u9ed8\u8ba4\u5b57\u7b26\u5e93 - \u5c0f\u5199\u82f1\u6587a-z - \u5927\u5199\u82f1\u6587A-Z - \u6574\u65700-9 |\r\n\r\n\u5982\u679c\u4e3astring\u7c7b\u578b\u8bf7\u4f20\u5165\u4e00\u6bb5\u4e0d\u5305\u542b\u7a7a\u683c\u7684\u6587\u672c\uff0c\u5176\u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\u5747\u4e3a\u4e00\u4e2a\u5f85\u9009\u8bcd\r\n\u5982\uff1a`\"0123456789+-x/=\"\"`\r\n\r\n```python\r\nimport ddddocr\r\n\r\nocr = ddddocr.DdddOcr()\r\n\r\nimage = open(\"test.jpg\", \"rb\").read()\r\nocr.set_ranges(\"0123456789+-x/=\")\r\nresult = ocr.classification(image, probability=True)\r\ns = \"\"\r\nfor i in result['probability']:\r\n    s += result['charsets'][i.index(max(i))]\r\n\r\nprint(s)\r\n\r\n```\r\n\r\n##### \u2164. \u81ea\u5b9a\u4e49OCR\u8bad\u7ec3\u6a21\u578b\u5bfc\u5165\r\n\r\n\u672c\u9879\u76ee\u652f\u6301\u5bfc\u5165\u6765\u81ea\u4e8e [dddd_trainer](https://github.com/sml2h3/dddd_trainer) \u8fdb\u884c\u81ea\u5b9a\u4e49\u8bad\u7ec3\u540e\u7684\u6a21\u578b\uff0c\u53c2\u8003\u5bfc\u5165\u4ee3\u7801\u4e3a\r\n\r\n```python\r\nimport ddddocr\r\n\r\nocr = ddddocr.DdddOcr(det=False, ocr=False, import_onnx_path=\"myproject_0.984375_139_13000_2022-02-26-15-34-13.onnx\", charsets_path=\"charsets.json\")\r\n\r\nwith open('test.jpg', 'rb') as f:\r\n    image_bytes = f.read()\r\n\r\nres = ocr.classification(image_bytes)\r\nprint(res)\r\n\r\n```\r\n\r\n### \u7248\u672c\u63a7\u5236\r\n\r\n\u8be5\u9879\u76ee\u4f7f\u7528Git\u8fdb\u884c\u7248\u672c\u7ba1\u7406\u3002\u60a8\u53ef\u4ee5\u5728repository\u53c2\u770b\u5f53\u524d\u53ef\u7528\u7248\u672c\u3002\r\n\r\n### \u76f8\u5173\u63a8\u8350\u6587\u7ae0or\u9879\u76ee\r\n\r\n[\u5e26\u5e26\u5f1f\u5f1fOCR\uff0c\u7eafVBA\u672c\u5730\u83b7\u53d6\u7f51\u7edc\u9a8c\u8bc1\u7801\u6574\u4f53\u89e3\u51b3\u65b9\u6848](https://club.excelhome.net/thread-1666823-1-1.html)\r\n\r\n[ddddocr rust \u7248\u672c](https://github.com/86maid/ddddocr)\r\n\r\n[captcha-killer\u7684\u4fee\u6539\u7248](https://github.com/f0ng/captcha-killer-modified)\r\n\r\n[\u901a\u8fc7ddddocr\u8bad\u7ec3\u5b57\u6bcd\u6570\u5b57\u9a8c\u8bc1\u7801\u6a21\u578b\u5e76\u8bc6\u522b\u90e8\u7f72\u8c03\u7528](https://www.bilibili.com/video/BV1ez421C7dB)\r\n\r\n...\r\n\r\n\u6b22\u8fce\u66f4\u591a\u4f18\u79c0\u6848\u4f8b\u6216\u6559\u7a0b\u7b49\u8fdb\u884c\u6295\u7a3f\uff0c\u53ef\u76f4\u63a5\u65b0\u5efaissue\u6807\u9898\u4ee5\u3010\u6295\u7a3f\u3011\u5f00\u5934\uff0c\u9644\u4e0a\u516c\u5f00\u6559\u7a0b\u7ad9\u70b9\u94fe\u63a5\uff0c\u6211\u4f1a\u9009\u62e9\u6839\u636e\u6587\u7ae0\u5185\u5bb9\u9009\u62e9\u76f8\u5bf9\u4e0d\u91cd\u590d\u6216\u8005\u6709\u91cd\u70b9\u5185\u5bb9\u7b49\u8fdb\u884creadme\u5c55\u793a\uff0c\u611f\u8c22\u5404\u4f4d\u670b\u53cb~\r\n\r\n### \u4f5c\u8005\r\n\r\nsml2h3@gamil.com\r\n \r\n<img src=\"https://cdn.wenanzhe.com/img/mmqrcode1640418911274.png!/scale/50\" alt=\"wechat\" width=\"150\">\r\n\r\n *\u597d\u53cb\u6570\u8fc7\u591a\u4e0d\u4e00\u5b9a\u901a\u8fc7\uff0c\u6709\u95ee\u9898\u53ef\u4ee5\u5728issue\u8fdb\u884c\u4ea4\u6d41*\r\n\r\n### \u7248\u6743\u8bf4\u660e\r\n\r\n\u8be5\u9879\u76ee\u7b7e\u7f72\u4e86MIT \u6388\u6743\u8bb8\u53ef\uff0c\u8be6\u60c5\u8bf7\u53c2\u9605 [LICENSE](https://github.com/sml2h3/ddddocr/blob/master/LICENSE)\r\n\r\n### \u6350\u8d60 \uff08\u5982\u679c\u9879\u76ee\u6709\u5e2e\u52a9\u5230\u60a8\uff0c\u53ef\u4ee5\u9009\u62e9\u6350\u8d60\u4e00\u4e9b\u8d39\u7528\u7528\u4e8eddddocr\u7684\u540e\u7eed\u7248\u672c\u7ef4\u62a4\uff0c\u672c\u9879\u76ee\u957f\u671f\u7ef4\u62a4\uff09\r\n\r\n<img src=\"https://cdn.wenanzhe.com/img/zhifubao.jpg\" alt=\"captcha\" width=\"150\">\r\n<img src=\"https://cdn.wenanzhe.com/img/weixin.jpg\" alt=\"captcha\" width=\"150\">\r\n\r\n\r\n<!-- links -->\r\n[your-project-path]:sml2h3/ddddocr\r\n[contributors-shield]: https://img.shields.io/github/contributors/sml2h3/ddddocr?style=flat-square\r\n[contributors-url]: https://github.com/shaojintian/Best_README_template/graphs/contributors\r\n[forks-shield]: https://img.shields.io/github/forks/sml2h3/ddddocr?style=flat-square\r\n[forks-url]: https://github.com/shaojintian/Best_README_template/network/members\r\n[stars-shield]: https://img.shields.io/github/stars/sml2h3/ddddocr?style=flat-square\r\n[stars-url]: https://github.com/shaojintian/Best_README_template/stargazers\r\n[issues-shield]: https://img.shields.io/github/issues/sml2h3/ddddocr?style=flat-square\r\n[issues-url]: https://img.shields.io/github/issues/sml2h3/ddddocr.svg\r\n[license-shield]: https://img.shields.io/github/license/sml2h3/ddddocr?style=flat-square\r\n[license-url]: https://github.com/sml2h3/ddddocr/blob/master/LICENSE\r\n\r\n\r\n### Star \u5386\u53f2\r\n\r\n[![Star History Chart](https://api.star-history.com/svg?repos=sml2h3/ddddocr&type=Date)](https://star-history.com/#sml2h3/ddddocr&Date)\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "\u5e26\u5e26\u5f1f\u5f1fOCR",
    "version": "1.5.6",
    "project_urls": {
        "Homepage": "https://github.com/sml2h3/ddddocr"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5474418c1c0be49463799f9eeb307a8aa4013ff5fca5e0387f0ef2762fcdb4e2",
                "md5": "c70dee8b7ebb60a5203300b630e627be",
                "sha256": "f13865b00e42de5c2507c1889ba73c2bacd218a49d15b928c2a5c82667062ac5"
            },
            "downloads": -1,
            "filename": "ddddocr-1.5.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c70dee8b7ebb60a5203300b630e627be",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13",
            "size": 75868010,
            "upload_time": "2024-10-15T09:21:41",
            "upload_time_iso_8601": "2024-10-15T09:21:41.061455Z",
            "url": "https://files.pythonhosted.org/packages/54/74/418c1c0be49463799f9eeb307a8aa4013ff5fca5e0387f0ef2762fcdb4e2/ddddocr-1.5.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0ecf1243d5f0d03763a287375366f68eadb5c14418f5b3df00c09eb971e526a7",
                "md5": "31f6626159868642781089f41bc4a0db",
                "sha256": "2839a940bfabe02e3284ef3f9d2a037292aa9f641f355b43a9b70bece9e1b73d"
            },
            "downloads": -1,
            "filename": "ddddocr-1.5.6.tar.gz",
            "has_sig": false,
            "md5_digest": "31f6626159868642781089f41bc4a0db",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13",
            "size": 75825027,
            "upload_time": "2024-10-15T09:22:00",
            "upload_time_iso_8601": "2024-10-15T09:22:00.940195Z",
            "url": "https://files.pythonhosted.org/packages/0e/cf/1243d5f0d03763a287375366f68eadb5c14418f5b3df00c09eb971e526a7/ddddocr-1.5.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-15 09:22:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sml2h3",
    "github_project": "ddddocr",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ddddocr"
}
        
Elapsed time: 1.54184s