Skip to content

Commit 6ecf4b0

Browse files
committed
V2 Enhanced Model
1 parent 926a53f commit 6ecf4b0

9 files changed

Lines changed: 856 additions & 57 deletions

File tree

HISTORY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11

22
# 版本历史
3+
0.9.0-Beta (2025-08-06)
4+
* 新增V2增强版模型 (V2 Enhanced Model)
5+
36
0.8.0 (2025-07-16)
47
* 依赖最小化 (Dependency Minimization)
58
* 将ultralytics库替换为cv2

README.md

Lines changed: 65 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,67 @@
11
简体中文 | [English](https://github.com/chenwei-zhao/captcha-recognizer/blob/main/README_en.md)
22

33
# Captcha-Recognizer
4-
Captcha-Recognizer是一个易用的通用滑块验证码识别库,通过深度学习训练通用的缺口检测模型,基于训练的结果,识别出验证码中的滑块缺口位置,并返回缺口的坐标与可信度。
54

5+
Captcha-Recognizer是一个易用的通用滑块验证码识别库,通过深度学习训练通用的缺口检测模型,基于训练的结果,识别出验证码中的滑块缺口位置,并返回缺口的坐标与可信度。
66

77
# 支持的验证码类型
8+
89
- 单缺口验证码背景图
910
- 多缺口验证码背景图
1011
- 验证码截图(包含滑块和背景图)
1112

12-
1313
# 版本要求
1414

15-
* ``Python`` >= 3.6.0
15+
* ``Python`` >= 3.6.0
1616
* ``opencv-python``
17-
18-
## opencv-python与numpy的兼容性
19-
兼容版本1:
20-
```
21-
opencv-python==4.12.0.88
22-
numpy==2.2.6
23-
```
24-
25-
兼容版本2:
26-
```markdown
27-
opencv-python==4.8.0.74
28-
numpy==1.23.0
29-
```
30-
31-
更多兼容的版本请自行尝试
32-
17+
* ``shapely``
18+
* ``onnxruntime``
3319

3420
* Works on Linux, Windows, MacOS
3521

36-
3722
# 使用方式
3823

39-
- [HTTP API](https://github.com/chenwei-zhao/captcha-api)
4024
- Pypi
41-
42-
## HTTP API
43-
44-
文档请移步: [captcha-api](https://github.com/chenwei-zhao/captcha-api)
25+
- [HTTP API](https://github.com/chenwei-zhao/captcha-api)
4526

4627
## Pypi
4728

4829
### 从 Pypi 安装
4930

50-
5131
```bash
5232
pip install captcha-recognizer
5333
```
5434

35+
## HTTP API
36+
37+
请移步: [captcha-api](https://github.com/chenwei-zhao/captcha-api)
38+
39+
# 使用示例
40+
41+
## V2 增强版
42+
43+
V2增强版,增强了对多缺口复杂验证码的识别效果
5544

45+
V2支持以下类型验证码的识别
46+
47+
- 单缺口验证码背景图(不含滑块的背景图)
48+
- 多缺口验证码截图或合成图(含滑块和背景图)
49+
50+
### V2 增强版使用示例
51+
52+
```python3
53+
# V2增强版
54+
from captcha_recognizer.slider import SliderV2
55+
56+
box, confidence = SliderV2().identify(source=f'images_example/example8.png', show=True)
57+
print(f'缺口坐标: {box}')
58+
print('置信度', confidence)
59+
```
60+
61+
## V1 版本
5662

5763
### 基于单缺口/多缺口验证码背景图识别滑块缺口
64+
5865
```Python
5966

6067
from captcha_recognizer.recognizer import Recognizer
@@ -155,9 +162,8 @@ print(f'可信度: {confidence}')
155162
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/predict7.png"
156163
>
157164
158-
159-
160165
### 基于验证码截图的识别滑块缺口
166+
161167
```Python
162168

163169
from captcha_recognizer.recognizer import Recognizer
@@ -209,10 +215,10 @@ distance = recognizer.identify_distance_by_screenshot(source='your_screenshot.jp
209215
print('滑块距离', distance)
210216
```
211217

212-
213-
214218
# 注意事项
219+
215220
## 偏移量
221+
216222
某些种类的滑块验证码,滑块初始位置存在一定偏移,以下面图中的滑块初始位置为例:
217223

218224
<p>示例图 9</p>
@@ -224,13 +230,15 @@ print('滑块距离', distance)
224230

225231

226232
如示例图9中:
233+
227234
- 第一条黑线位置为滑块初始位置,距离图片边框有大概有8个像素的偏移量(offset为8)
228235
- 识别结果的缺口坐标为 [x1, y1, x2, y2] 对应缺口的左上角和右下角坐标(坐标原点为图片左上角)
229236
- 第二条黑线的X轴坐标值对应缺口识别结果左上角的X轴坐标值,此处值为154(x1为154)
230237
- 因此实际滑块的距离为 x1-offset (154-8=146)
231238
- 也就是说,实际的滑块距离为缺口的x1值减去滑块距离图片边框的偏移量(offset)
232239

233240
## 图片缩放
241+
234242
某些验证码,前端渲染时会对图片进行缩放,因此实际的滑块距离也要按照图片缩放比例进行计算。
235243

236244
<p>示例图 10</p>
@@ -239,44 +247,61 @@ print('滑块距离', distance)
239247
alt="https://captcha-slider.oss-cn-beijing.aliyuncs.com/slider/rendered_size.png"
240248
>
241249
242-
243250
## 图片识别耗时
251+
244252
- 首次识别图片耗时较长(2s左右);
245253
- 后续单张图片的识别在60ms(60毫秒)左右;
246254
- 因为首次识别图片时需要将模型从磁盘加载到内存中,并进行一系列的初始化工作,如权重加载、内存分配等。这个过程相对耗时;
247255
- 一旦模型加载完成并初始化好,后续的图片预测就可以直接利用已经加载好的模型和分配好的资源,从而避免了重复加载和初始化的开销。
248256

249-
250-
251257
# 安装过程中遇到问题
258+
252259
- Error loading “xxx\Lib\site-packages\torch\lib\fbgemm.dll” or one of its dependencies.
253-
- 参考 [Issues 2](https://github.com/chenwei-zhao/captcha-recognizer/issues/2)
260+
- 参考 [Issues 2](https://github.com/chenwei-zhao/captcha-recognizer/issues/2)
254261
- Model Unsupported model IR version: 9, max supported IR version: 8
255262
- 参考 [Issues 1](https://github.com/chenwei-zhao/captcha-recognizer/issues/1)
256-
263+
264+
- opencv-python与numpy的兼容性问题
265+
兼容版本1:
266+
267+
```
268+
opencv-python==4.12.0.88
269+
numpy==2.2.6
270+
```
271+
272+
兼容版本2:
273+
274+
```markdown
275+
opencv-python==4.8.0.74
276+
numpy==1.23.0
277+
```
278+
279+
更多兼容的版本请自行尝试
257280

258281
# 了解更多
282+
259283
[点击此处进入DeepWiki文档](https://deepwiki.com/chenwei-zhao/captcha-recognizer)
260284

261285
DeepWiki文档内可通过底部AI对话框进行交流,自由了解本项目。
262286

263-
264287
# 项目维护
265288

266-
- 如果你对本项目感兴趣,欢迎star
289+
- 如果你对本项目感兴趣,欢迎Star
267290
- 项目长期维护。
268291
- 如果你遇到本项目不能识别的滑块验证码,欢迎提[issue](https://github.com/chenwei-zhao/captcha-recognizer/issues)
269292
- 有任何问题,欢迎提[issue](https://github.com/chenwei-zhao/captcha-recognizer/issues)
270293

271294
# 更多联系方式
295+
272296
- Gmail: chenwei.zhaozhao@gmail.com
273297
- 163/网易: chenwei_nature@163.com
274298

275-
276299
# 免责声明
300+
277301
本项目不针对任何一家验证码厂商,项目所有内容仅供学习交流使用,不用于其他任何目的,严禁用于非法用途。
278302

279303
# 许可证
304+
280305
MIT license
281306

282307
# 感谢你的支持
@@ -286,18 +311,18 @@ MIT license
286311
[![Stargazers repo roster for @chenwei-zhao/captcha-recognizer](https://reporoster.com/stars/dark/chenwei-zhao/captcha-recognizer)](https://github.com/chenwei-zhao/captcha-recognizer/stargazers)
287312

288313
## Forkers
289-
[![Forkers repo roster for @chenwei-zhao/captcha-recognizer](https://reporoster.com/forks/dark/chenwei-zhao/captcha-recognizer)](https://github.com/chenwei-zhao/captcha-recognizer/network/members)
290314

315+
[![Forkers repo roster for @chenwei-zhao/captcha-recognizer](https://reporoster.com/forks/dark/chenwei-zhao/captcha-recognizer)](https://github.com/chenwei-zhao/captcha-recognizer/network/members)
291316

292317
## Star History
293318

294319
[![Star History Chart](https://api.star-history.com/svg?repos=chenwei-zhao/captcha-recognizer&type=Date)](https://star-history.com/#chenwei-zhao/captcha-recognizer&Date)
295320

296321
## 捐赠
322+
297323
- 感谢支持开源项目
298324
- 如果项目有帮助到您,可以选择捐赠一些费用,帮助项目持续更新。
299325

300-
301326
<img src="https://captcha-slider.oss-cn-beijing.aliyuncs.com/payment/wechat.jpg" width="168" alt="微信支付">
302327

303328
<img src="https://captcha-slider.oss-cn-beijing.aliyuncs.com/payment/alipay.jpg" width="168" alt="支付宝支付">

README_en.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,10 @@ MIT license
1616

1717
* ``Python`` >= 3.6.0
1818
* ``opencv-python``
19+
* ``shapely``
20+
* ``onnxruntime``
1921

20-
## Version about opencv-python and numpy
21-
22-
Version 1:
23-
24-
opencv-python==4.12.0.88
25-
numpy==2.2.6
26-
27-
Version 2:
28-
opencv-python==4.6.0.66
29-
numpy==1.24.4
30-
31-
* Works on Linux, Windows, macOS
22+
* Works on Linux, Windows, MacOS
3223

3324

3425
# Usage
@@ -72,7 +63,7 @@ The notch box coordinate is the distance between the top left corner and the bot
7263
from captcha_recognizer.recognizer import Recognizer
7364
recognizer = Recognizer()
7465

75-
box, confidence = recognizer.identify_screenshot(source='<image obj>', verbose=False, show_result=True)
66+
box, confidence = recognizer.identify_screenshot(source='<image obj>')
7667

7768
print(f'Gap coordinate: {box}')
7869
print(f'Confidence: {confidence}')
@@ -169,6 +160,17 @@ Includes, but is not limited to, the following types
169160
- Model Unsupported model IR version: 9, max supported IR version: 8
170161
- See [Issues 1](https://github.com/chenwei-zhao/captcha-recognizer/issues/1)
171162

163+
- Version about opencv-python and numpy
164+
165+
Version 1:
166+
167+
opencv-python==4.12.0.88
168+
numpy==2.2.6
169+
170+
Version 2:
171+
opencv-python==4.6.0.66
172+
numpy==1.24.4
173+
172174
# Email
173175
- Gmail: chenwei.zhaozhao@gmail.com
174176
- 163: chenwei_nature@163.com
11 MB
Binary file not shown.

0 commit comments

Comments
 (0)