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
5232pip 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
6067from 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
163169from captcha_recognizer.recognizer import Recognizer
@@ -209,10 +215,10 @@ distance = recognizer.identify_distance_by_screenshot(source='your_screenshot.jp
209215print (' 滑块距离' , 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
261285DeepWiki文档内可通过底部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+
280305MIT 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 =" 支付宝支付 " >
0 commit comments