5
0
mirror of https://github.com/sml2h3/ddddocr.git synced 2025-05-19 02:09:34 +08:00

修复了slide_match部分在simple_target为False时异常情况,异常时自动设置simple_target为True

This commit is contained in:
sml2h3 2022-08-29 14:48:11 +08:00
parent 5013e926cc
commit 8d57008e2a
3 changed files with 41 additions and 18 deletions

View File

@ -2,16 +2,16 @@
# 带带弟弟OCR通用验证码识别SDK免费开源版
# 2022/05/27 关注我的直播间
[B站直播间-点击关注我哦~在线分享答疑](https://space.bilibili.com/313042688)
# 今天ddddocr又更新啦
## 当前版本为1.4.3
# 当前版本为1.4.7
## 1.4.3更新内容
本次升级的主要原因为,[dddd_trainer](https://github.com/sml2h3/dddd_trainer) 的开源进行适配,使[dddd_trainer](https://github.com/sml2h3/dddd_trainer) 训练出的模型可以直接无缝导入到ddddocr里面来使用
## 使用ddddocr调用[dddd_trainer](https://github.com/sml2h3/dddd_trainer) 训练后的模型
### 支持使用ddddocr调用 [dddd_trainer](https://github.com/sml2h3/dddd_trainer) 训练后的自定义模型
[dddd_trainer](https://github.com/sml2h3/dddd_trainer) 训练后会在models目录里导出charsets.json和onnx模型
@ -31,8 +31,14 @@ print(res)
# 捐赠 如果项目有帮助到您可以选择捐赠一些费用用于ddddocr的后续版本维护本项目长期维护
![Test](https://cdn.wenanzhe.com/img/zhifubao.jpg!/scale/35)
![Test](https://cdn.wenanzhe.com/img/weixin.jpg!/scale/35)
![Test](https://cdn.wenanzhe.com/img/zhifubao.jpg!/scale/30)
![Test](https://cdn.wenanzhe.com/img/weixin.jpg!/scale/30)
# 赞助合作商
| 赞助合作商 | 推荐理由 |
|------------|--------------------------------------------------------------------------------------------------|
| [YesCaptcha](https://yescaptcha.com/i/NSwk7i) | 谷歌reCaptcha验证码 / hCaptcha验证码 / funCaptcha验证码商业级识别接口 [点我](https://yescaptcha.com/i/NSwk7i) 直达VIP4 |
# 1.4.0版本更新内容

View File

@ -2,12 +2,16 @@
# 带带弟弟OCR通用验证码识别SDK免费开源版
# 今天ddddocr又更新啦
## 当前版本为1.4.3
# 当前版本为1.4.7
## 1.4.3更新内容
本次升级的主要原因为,[dddd_trainer](https://github.com/sml2h3/dddd_trainer) 的开源进行适配,使[dddd_trainer](https://github.com/sml2h3/dddd_trainer) 训练出的模型可以直接无缝导入到ddddocr里面来使用
## 使用ddddocr调用[dddd_trainer](https://github.com/sml2h3/dddd_trainer) 训练后的模型
### 支持使用ddddocr调用 [dddd_trainer](https://github.com/sml2h3/dddd_trainer) 训练后的自定义模型
[dddd_trainer](https://github.com/sml2h3/dddd_trainer) 训练后会在models目录里导出charsets.json和onnx模型
@ -27,8 +31,14 @@ print(res)
# 捐赠 如果项目有帮助到您可以选择捐赠一些费用用于ddddocr的后续版本维护本项目长期维护
![Test](https://cdn.wenanzhe.com/img/zhifubao.jpg!/scale/35)
![Test](https://cdn.wenanzhe.com/img/weixin.jpg!/scale/35)
![Test](https://cdn.wenanzhe.com/img/zhifubao.jpg!/scale/30)
![Test](https://cdn.wenanzhe.com/img/weixin.jpg!/scale/30)
# 赞助合作商
| 赞助合作商 | 推荐理由 |
|------------|--------------------------------------------------------------------------------------------------|
| [YesCaptcha](https://yescaptcha.com/i/NSwk7i) | 谷歌reCaptcha验证码 / hCaptcha验证码 / funCaptcha验证码商业级识别接口 [点我](https://yescaptcha.com/i/NSwk7i) 直达VIP4 |
# 1.4.0版本更新内容
@ -225,8 +235,7 @@ cv2.imwrite("result.jpg", im)
`Windows/Linux/Macos..`
M1X用户需要使用 [传送门](https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-MacOSX-arm64.sh
)创建python环境后即可使用
暂时不支持Macbook M1(X)M1(X)用户需要自己编译onnxruntime才可以使用
## 安装命令
@ -247,7 +256,8 @@ M1X用户需要使用 [传送门](https://github.com/conda-forge/miniforge/re
[crawlab](https://github.com/crawlab-team/crawlab)
# 交流群 (加我好友拉你进群)
![四群链接](https://cdn.wenanzhe.com/img/1d5ec7445d745a4d6790df352e1abb5.png!/scale/50)
![Test](https://cdn.wenanzhe.com/img/mmqrcode1640418911274.png!/scale/50)

View File

@ -35,6 +35,7 @@ class DdddOcr(object):
print("欢迎使用ddddocr本项目专注带动行业内卷个人博客:wenanzhe.com")
print("训练数据支持来源于:http://146.56.204.113:19199/preview")
print("爬虫框架feapder可快速一键接入快速开启爬虫之旅https://github.com/Boris-code/feapder")
print("谷歌reCaptcha验证码 / hCaptcha验证码 / funCaptcha验证码商业级识别接口https://yescaptcha.com/i/NSwk7i")
self.use_import_onnx = False
self.__word = False
self.__resize = []
@ -1692,10 +1693,16 @@ class DdddOcr(object):
end_x = x
return image.crop([starttx, startty, end_x, end_y]), starttx, startty
def slide_match(self, target_bytes: bytes = None, background_bytes: bytes = None, simple_target: bool=False):
def slide_match(self, target_bytes: bytes = None, background_bytes: bytes = None, simple_target: bool=False, flag: bool=False):
if not simple_target:
target, target_x, target_y = self.get_target(target_bytes)
target = cv2.cvtColor(np.asarray(target), cv2.IMREAD_ANYCOLOR)
try:
target, target_x, target_y = self.get_target(target_bytes)
target = cv2.cvtColor(np.asarray(target), cv2.IMREAD_ANYCOLOR)
except SystemError as e:
# SystemError: tile cannot extend outside image
if flag:
raise e
return self.slide_match(target_bytes=target_bytes, background_bytes=background_bytes, simple_target=True, flag=True)
else:
target = cv2.imdecode(np.frombuffer(target_bytes, np.uint8), cv2.IMREAD_ANYCOLOR)
target_y = 0