简体中文 | [English](https://github.com/chenwei-zhao/captcha-recognizer/blob/main/README_en.md)
# Captcha-Recognizer
Captcha-Recognizer是一个易用的通用滑块验证码识别库,通过深度学习训练通用的缺口检测模型,基于训练的结果,识别出验证码中的滑块缺口位置,并返回缺口的坐标与可信度。
# 支持的验证码类型
- 单缺口验证码背景图
- 多缺口验证码背景图
- 验证码截图(包含滑块和背景图)
# 在线演示
- [在线演示](http://47.94.198.97/)
<p>
<img
src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_example/online-demo.gif"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/online-demo.gif"
>
</p>
# 版本要求
* ``Python`` >= 3.6.0
* ``opencv-python``
* ``shapely``
* ``onnxruntime``
* Works on Linux, Windows, MacOS
# 使用方式
- Pypi
- [HTTP API](https://github.com/chenwei-zhao/captcha-api)
## Pypi
### 从 Pypi 安装
```bash
pip install captcha-recognizer
```
## HTTP API
请移步: [captcha-api](https://github.com/chenwei-zhao/captcha-api)
# 使用示例
## V2 增强版
V2增强版,增强了对多缺口复杂验证码的识别效果
V2支持以下类型验证码的识别
- 单缺口验证码背景图(不含滑块的背景图)
- 多缺口验证码截图或合成图(含滑块和背景图)
### V2 Beta 增强版使用示例
```shell
pip install captcha-recognizer --upgrade
```
```python3
# V2增强版
from captcha_recognizer.slider import SliderV2
box, confidence = SliderV2().identify(source=f'images_example/example8.png', show=True)
print(f'缺口坐标: {box}')
print('置信度', confidence)
```
## V1 版本
### 基于单缺口/多缺口验证码背景图识别滑块缺口
```Python
from captcha_recognizer.recognizer import Recognizer
# source传入图片, 支持 Union[str, Path, bytes, np.ndarray]
# is_single 默认为False表示支持多缺口背景图识别,is_single=True表示仅支持单缺口背景图识别(指定is_single为True时,对单缺口背景图识别准确度更高)
recognizer = Recognizer()
box, confidence = recognizer.identify_gap(source='your_example_image.png')
print(f'缺口坐标: {box}')
print(f'可信度: {confidence}')
"""
打印结果如下:
缺口方框坐标: [331.72052001953125, 55.96122741699219, 422.079345703125, 161.7498779296875]
可信度: 0.9513089656829834
坐标原点:图片左上角
缺口方框坐标为缺口方框左上角和右下角距离坐标原点的距离
"""
```
### 基于单缺口/多缺口验证码背景图识别滑块缺口的示例图片
包括且不限于以下类型、尺寸的滑块图片检测
<p>示例图 1</p>
<p>尺寸 552*344</p>
<img
src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_example/example1.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/example1.png"
>
<p>识别效果示例图 1</p>
<img src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_predict/predict1.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/predict1.png"
>
<p>示例图 2</p>
<p>尺寸 260*160</p>
<img src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_example/example2.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/example2.png"
>
<p>识别效果示例图 2</p>
<img src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_predict/predict2.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/predict2.png"
>
<p>示例图 3</p>
<p>尺寸 400*200</p>
<img src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_example/example3.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/example1.png"
>
<p>识别效果示例图3</p>
<img src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_predict/predict3.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/predict3.png"
>
<p>示例图 4</p>
<p>尺寸 672*390</p>
<img src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_example/example4.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/example4.png"
>
<p>识别效果示例图4</p>
<img src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_predict/predict4.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/predict4.png"
>
<p>示例图 5</p>
<p>尺寸 280*155</p>
<img src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_example/example5.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/example5.png"
>
<p>识别效果示例图 5</p>
<img src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_predict/predict5.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/predict5.png"
>
<p>示例图 6</p>
<p>尺寸 590*360</p>
<img src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_example/example6.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/example6.png"
>
<p>识别效果示例图 6</p>
<img src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_predict/predict6.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/predict6.png"
>
<p>示例图 7</p>
<p>尺寸 320*160</p>
<img src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_example/example7.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/example7.png"
>
<p>识别效果示例图 7</p>
<img src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_predict/predict7.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/predict7.png"
>
### 基于验证码截图的识别滑块缺口
```Python
from captcha_recognizer.recognizer import Recognizer
# source传入图片,支持 Union[str, Path, bytes, np.ndarray]
recognizer = Recognizer()
box, confidence = recognizer.identify_screenshot(source='your_example_image.png')
print(f'缺口坐标: {box}')
print(f'可信度: {confidence}')
"""
打印结果如下:
缺口方框坐标: [331.72052001953125, 55.96122741699219, 422.079345703125, 161.7498779296875]
可信度: 0.9513089656829834
坐标原点:图片左上角
缺口方框坐标为缺口方框左上角和右下角距离坐标原点的距离
"""
```
### 基于验证码截图的滑块识别滑块缺口示例
包括且不限于以下类型、尺寸的滑块验证码截图
<p>示例图 8</p>
<p>尺寸 305*156</p>
<img
src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_example/example8.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/example8.png"
>
<p>识别效果示例图 8</p>
<img src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_predict/predict8.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/predict8.png"
>
### 基于验证码截图识别滑块距离
```python3
from captcha_recognizer.recognizer import Recognizer
# source传入图片, 支持Union[str, Path, bytes, np.ndarray]
recognizer = Recognizer()
distance = recognizer.identify_distance_by_screenshot(source='your_screenshot.jpg')
print('滑块距离', distance)
```
# 注意事项
## 偏移量
某些种类的滑块验证码,滑块初始位置存在一定偏移,以下面图中的滑块初始位置为例:
<p>示例图 9</p>
<img
src="https://raw.githubusercontent.com/chenwei-zhao/captcha-recognizer/main/images_example/offset2.png"
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/offset2.png"
>
如示例图9中:
- 第一条黑线位置为滑块初始位置,距离图片边框有大概有8个像素的偏移量(offset为8)
- 识别结果的缺口坐标为 [x1, y1, x2, y2] 对应�
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论






























收起资源包目录













































共 37 条
- 1
资源评论


xinkai1688
- 粉丝: 416
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 如何利用大数据技术优化道路危险货物运输安全决策水平.pptx
- 基于遗传算法求解作业车间调度问题.doc
- 【世茂】重庆润一江项目D地块总承包工程施工策划.pptx
- 区域游戏教师的观察与指导教研计划[打造区域网络教研平台-推进教师专业发展].doc
- 高三生物一轮复习课件基因工程(第1课时).pptx
- 网络合作固定折扣协议.doc
- 地下室、管沟和管井施工安全技术交底.doc
- 【中天二建】83号地块二期技术策划.pdf
- 骨骼肌细胞的收缩.pdf
- 拌合站混凝土管理办法(010年).doc
- 某学校教学楼外脚手架按拆工程施工方案.doc
- 房屋建筑工程质量通病(钢筋绑扎与安装).ppt
- 山东省包装饮用水行业现状及未来发展趋势.pdf
- 煤矿大倾角输送机强力胶带更换快速施工工艺.doc
- 挣值分析法及其在项目成本管理中的应用.doc
- 装饰装修材料种类及名称汇总.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
