update at 2025-10-25 19:23:02

This commit is contained in:
douboer
2025-10-25 19:23:02 +08:00
parent 7a4f659dda
commit ced4fd4bac
146 changed files with 1709 additions and 4030 deletions

View File

@@ -1,4 +1,4 @@
# 豆瓣滑块验证码检测器
# 豆瓣滑块验证码检测器v1.0.0
基于 sharp 图像处理库实现的滑块验证码缺口精确识别工具。
@@ -6,9 +6,9 @@
- ✅ 自动检测图片中的滑块缺口位置
- ✅ 支持多滑块检测(一张图片中检测多个滑块)
-使用多阈值策略提高检测准确率
-多策略候选区域搜索与自适应评分体系
- ✅ 自动在图片上绘制蓝色边框标注检测结果
- ✅ 支持人工标注对比验证
- ✅ 支持基于 ground-truth 的准确率评估
## 安装依赖
@@ -18,7 +18,7 @@ npm install
## 使用方法
### 运行检测
### 运行检测(默认数据集)
```bash
npm run detect
@@ -29,6 +29,14 @@ npm run detect
2. 处理 `images/douban` 目录中的所有图片
3. 将检测结果(带蓝色边框)输出到 `images/output` 目录
### 自定义目录
```bash
npm run detect -- --pic-dir=images/custom
```
> `--pic-dir` 为 `README` 所在目录的相对路径,检测结果仍然输出到 `images/output`。
### 目录结构
```
@@ -44,22 +52,11 @@ images/
### 核心思路
1. **暗色区域检测**:滑块缺口通常为暗色(阴影)区
2. **多阈值策略**:使用 75、90、105 三个亮度阈值进行检测,提高鲁棒性
3. **形态学处理**:使用闭运算(先膨胀后腐蚀)去除噪点
4. **连通区域分析**:使用洪水填充算法查找所有暗色连通区域
5. **特征筛选**
- 尺寸范围50-95 像素(宽度和高度)
- 宽高比0.8-1.25(接近正方形)
- 位置图片中部区域15%-75%高度)
- 密度:像素填充率 > 55%
### 检测结果
当前性能(在 9 张测试图片上):
- **验证准确率**55.6%5/9
- **检测完成率**66.7%6/9
- 支持多滑块检测(滑块-1.png 检测到 2 个滑块)
1. **多阈值暗/亮检测**:从增强对比度后的图像中提取亮/暗连通
2. **Sobel 边缘候选**:基于边缘图的形态学操作补充候选框
3. **颜色量化与 LAB 色差扫描**:强化低对比度场景下的候选覆盖
4. **候选融合**:利用 IoU 去重并按颜色一致性、内部边缘密度、梯度平滑度打分
5. **自学习滑块扩展**:在首个高置信度框的基础上,使用模板匹配寻找第二个滑块
## 开发
@@ -71,15 +68,13 @@ npm run build
### 调试
查看未检测到的图片特征
```bash
npx ts-node --transpile-only src/debug-threshold.ts
```
核心逻辑已经拆分为模块化的检测管线
分析红框标注信息:
```bash
npx ts-node --transpile-only src/analyze.ts
```
- `src/detection/candidate-search.ts`:多策略候选区域查找与评分
- `src/utils/image.ts`:图像形态学、边缘工具函数
- `src/detector.ts`:检测器主体、框体精炼与多滑块协同策略
- `src/cli.ts`:命令行入口,负责加载 ground-truth 与批量处理
- `src/validator.ts`IoU/容差匹配与统计分析
## 技术栈
@@ -87,6 +82,10 @@ npx ts-node --transpile-only src/analyze.ts
- Sharp (图像处理)
- Node.js
## 版本历史
- v1.0.0引入模块化检测管线、CLI 工具、ground-truth 验证与多策略候选融合。
## 优化方向
1. 提高对低对比度图片的检测能力

View File

@@ -14,115 +14,381 @@
}
],
"滑块-2.png": [
{
"x": 454,
"y": 244,
"width": 90,
"height": 92
},
{
"x": 125,
"y": 245,
"width": 89,
"height": 91
},
{
"x": 454,
"y": 244,
"width": 90,
"height": 92
}
],
"滑块-3.png": [
{
"x": 576,
"y": 237,
"width": 87,
"height": 88
},
{
"x": 122,
"y": 238,
"width": 86,
"height": 87
},
{
"x": 576,
"y": 237,
"width": 87,
"height": 88
}
],
"滑块-4.png": [
{
"x": 488,
"y": 329,
"width": 91,
"height": 91
},
{
"x": 120,
"y": 330,
"width": 90,
"height": 90
},
{
"x": 488,
"y": 329,
"width": 91,
"height": 91
}
],
"滑块-5.png": [
{
"x": 404,
"y": 443,
"width": 91,
"height": 89
},
{
"x": 119,
"y": 444,
"width": 90,
"height": 88
},
{
"x": 404,
"y": 443,
"width": 91,
"height": 89
}
],
"滑块-6.png": [
{
"x": 574,
"y": 318,
"width": 92,
"height": 92
},
{
"x": 116,
"y": 319,
"width": 91,
"height": 91
},
{
"x": 574,
"y": 318,
"width": 92,
"height": 92
}
],
"滑块-7.png": [
{
"x": 349,
"y": 177,
"width": 101,
"height": 166
},
{
"x": 119,
"y": 255,
"width": 88,
"height": 88
},
{
"x": 349,
"y": 177,
"width": 101,
"height": 166
}
],
"滑块-8.png": [
{
"x": 434,
"y": 243,
"width": 93,
"height": 93
},
{
"x": 120,
"y": 244,
"width": 92,
"height": 92
},
{
"x": 434,
"y": 243,
"width": 93,
"height": 93
}
],
"滑块.png": [
{
"x": 375,
"y": 407,
"width": 88,
"height": 89
},
{
"x": 131,
"y": 408,
"width": 87,
"height": 88
},
{
"x": 375,
"y": 407,
"width": 88,
"height": 89
}
],
"iShot_2025-10-25_16.53.21.png": [
{
"x": 119,
"y": 344,
"width": 91,
"height": 92
},
{
"x": 575,
"y": 342,
"width": 93,
"height": 94
}
],
"iShot_2025-10-25_16.53.40.png": [
{
"x": 108,
"y": 353,
"width": 94,
"height": 91
},
{
"x": 365,
"y": 353,
"width": 95,
"height": 92
}
],
"iShot_2025-10-25_16.53.48.png": [
{
"x": 122,
"y": 256,
"width": 90,
"height": 89
},
{
"x": 379,
"y": 256,
"width": 91,
"height": 90
}
],
"iShot_2025-10-25_16.53.57.png": [
{
"x": 110,
"y": 282,
"width": 90,
"height": 88
},
{
"x": 380,
"y": 282,
"width": 90,
"height": 89
}
],
"iShot_2025-10-25_16.54.08.png": [
{
"x": 119,
"y": 306,
"width": 93,
"height": 93
},
{
"x": 386,
"y": 306,
"width": 93,
"height": 94
}
],
"iShot_2025-10-25_16.54.15.png": [
{
"x": 118,
"y": 360,
"width": 90,
"height": 88
},
{
"x": 386,
"y": 363,
"width": 91,
"height": 89
}
],
"iShot_2025-10-25_16.54.25.png": [
{
"x": 121,
"y": 420,
"width": 88,
"height": 87
},
{
"x": 313,
"y": 420,
"width": 90,
"height": 88
}
],
"iShot_2025-10-25_16.54.32.png": [
{
"x": 113,
"y": 292,
"width": 88,
"height": 88
},
{
"x": 346,
"y": 292,
"width": 88,
"height": 88
}
],
"iShot_2025-10-25_16.54.41.png": [
{
"x": 118,
"y": 388,
"width": 88,
"height": 88
},
{
"x": 541,
"y": 388,
"width": 89,
"height": 89
}
],
"iShot_2025-10-25_16.54.54.png": [
{
"x": 98,
"y": 334,
"width": 90,
"height": 88
},
{
"x": 310,
"y": 334,
"width": 92,
"height": 89
}
],
"iShot_2025-10-25_16.55.02.png": [
{
"x": 119,
"y": 349,
"width": 90,
"height": 88
},
{
"x": 401,
"y": 349,
"width": 92,
"height": 89
}
],
"iShot_2025-10-25_16.55.09.png": [
{
"x": 100,
"y": 351,
"width": 90,
"height": 88
},
{
"x": 382,
"y": 351,
"width": 92,
"height": 89
}
],
"iShot_2025-10-25_16.55.14.png": [
{
"x": 119,
"y": 365,
"width": 90,
"height": 88
},
{
"x": 400,
"y": 365,
"width": 91,
"height": 89
}
],
"iShot_2025-10-25_16.55.21.png": [
{
"x": 110,
"y": 220,
"width": 92,
"height": 89
},
{
"x": 519,
"y": 220,
"width": 90,
"height": 88
}
],
"iShot_2025-10-25_16.55.29.png": [
{
"x": 114,
"y": 309,
"width": 90,
"height": 88
},
{
"x": 544,
"y": 309,
"width": 90,
"height": 89
}
],
"iShot_2025-10-25_16.55.37.png": [
{
"x": 107,
"y": 427,
"width": 87,
"height": 88
},
{
"x": 542,
"y": 427,
"width": 88,
"height": 89
}
],
"iShot_2025-10-25_16.55.46.png": [
{
"x": 117,
"y": 227,
"width": 88,
"height": 89
},
{
"x": 550,
"y": 227,
"width": 89,
"height": 90
}
],
"iShot_2025-10-25_16.55.52.png": [
{
"x": 112,
"y": 314,
"width": 89,
"height": 91
},
{
"x": 409,
"y": 314,
"width": 90,
"height": 92
}
],
"iShot_2025-10-25_16.56.01.png": [
{
"x": 119,
"y": 347,
"width": 90,
"height": 88
},
{
"x": 393,
"y": 350,
"width": 90,
"height": 89
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 409 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 522 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 519 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 679 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 599 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 658 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 698 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 687 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 KiB

Some files were not shown because too many files have changed in this diff Show More