first commit

This commit is contained in:
douboer
2025-10-25 15:53:29 +08:00
commit 7a4f659dda
321 changed files with 4588 additions and 0 deletions

54
.gitignore vendored Normal file
View File

@@ -0,0 +1,54 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
dist
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# mockm
httpData
public/upload/**
!public/upload/*.gitkeep
.history
# Package manager lock file
package-lock.json
yarn.lock
# pnpm-lock.yaml
auto-imports.d.ts
components.d.ts
.wxt
.output
web-ext.config.ts
.wrangler
# vite-plugin-pwa dev output
dev-dist

95
README.md Normal file
View File

@@ -0,0 +1,95 @@
# 豆瓣滑块验证码检测器
基于 sharp 图像处理库实现的滑块验证码缺口精确识别工具。
## 功能特性
- ✅ 自动检测图片中的滑块缺口位置
- ✅ 支持多滑块检测(一张图片中检测多个滑块)
- ✅ 使用多阈值策略提高检测准确率
- ✅ 自动在图片上绘制蓝色边框标注检测结果
- ✅ 支持人工标注对比验证
## 安装依赖
```bash
npm install
```
## 使用方法
### 运行检测
```bash
npm run detect
```
该命令会:
1. 验证算法准确性(使用 `images/douban-target` 中的红框标注图片)
2. 处理 `images/douban` 目录中的所有图片
3. 将检测结果(带蓝色边框)输出到 `images/output` 目录
### 目录结构
```
images/
├── douban/ # 豆瓣滑块真实截图(待检测)
├── douban-target/ # 红框标注图片(用于验证算法准确性)
├── slider/ # 滑块形状模板图片
├── target/ # 滑块标注图片
└── output/ # 检测结果输出目录(蓝色框标注)
```
## 检测算法
### 核心思路
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 个滑块)
## 开发
### 编译
```bash
npm run build
```
### 调试
查看未检测到的图片特征:
```bash
npx ts-node --transpile-only src/debug-threshold.ts
```
分析红框标注信息:
```bash
npx ts-node --transpile-only src/analyze.ts
```
## 技术栈
- TypeScript
- Sharp (图像处理)
- Node.js
## 优化方向
1. 提高对低对比度图片的检测能力
2. 优化形态学操作参数
3. 增加边缘检测辅助判断
4. 支持更多滑块形状变体

128
ground-truth.json Normal file
View File

@@ -0,0 +1,128 @@
{
"滑块-1.png": [
{
"x": 123,
"y": 439,
"width": 90,
"height": 92
},
{
"x": 546,
"y": 439,
"width": 90,
"height": 92
}
],
"滑块-2.png": [
{
"x": 454,
"y": 244,
"width": 90,
"height": 92
},
{
"x": 125,
"y": 245,
"width": 89,
"height": 91
}
],
"滑块-3.png": [
{
"x": 576,
"y": 237,
"width": 87,
"height": 88
},
{
"x": 122,
"y": 238,
"width": 86,
"height": 87
}
],
"滑块-4.png": [
{
"x": 488,
"y": 329,
"width": 91,
"height": 91
},
{
"x": 120,
"y": 330,
"width": 90,
"height": 90
}
],
"滑块-5.png": [
{
"x": 404,
"y": 443,
"width": 91,
"height": 89
},
{
"x": 119,
"y": 444,
"width": 90,
"height": 88
}
],
"滑块-6.png": [
{
"x": 574,
"y": 318,
"width": 92,
"height": 92
},
{
"x": 116,
"y": 319,
"width": 91,
"height": 91
}
],
"滑块-7.png": [
{
"x": 349,
"y": 177,
"width": 101,
"height": 166
},
{
"x": 119,
"y": 255,
"width": 88,
"height": 88
}
],
"滑块-8.png": [
{
"x": 434,
"y": 243,
"width": 93,
"height": 93
},
{
"x": 120,
"y": 244,
"width": 92,
"height": 92
}
],
"滑块.png": [
{
"x": 375,
"y": 407,
"width": 88,
"height": 89
},
{
"x": 131,
"y": 408,
"width": 87,
"height": 88
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

BIN
images/douban/滑块-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 KiB

BIN
images/douban/滑块-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 KiB

BIN
images/douban/滑块-3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 KiB

BIN
images/douban/滑块-4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

BIN
images/douban/滑块-5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 KiB

BIN
images/douban/滑块-6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 KiB

BIN
images/douban/滑块-7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

BIN
images/douban/滑块-8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 KiB

BIN
images/douban/滑块.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 674 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 656 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 694 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

BIN
images/output-cv/滑块.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 519 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 KiB

BIN
images/output/滑块-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 519 KiB

BIN
images/output/滑块-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 KiB

BIN
images/output/滑块-3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 KiB

BIN
images/output/滑块-4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

BIN
images/output/滑块-5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 KiB

BIN
images/output/滑块-6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 KiB

BIN
images/output/滑块-7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 KiB

BIN
images/output/滑块-8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 KiB

BIN
images/output/滑块.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

BIN
images/slider/421slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
images/slider/422slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
images/slider/423slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
images/slider/424slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
images/slider/425slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
images/slider/426slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
images/slider/427slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
images/slider/428slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
images/slider/429slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
images/slider/430slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
images/slider/431slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
images/slider/432slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
images/slider/433slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
images/slider/434slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
images/slider/435slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
images/slider/436slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
images/slider/437slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
images/slider/438slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
images/slider/439slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
images/slider/440slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
images/slider/441slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
images/slider/442slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
images/slider/443slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
images/slider/444slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
images/slider/445slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
images/slider/446slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
images/slider/447slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
images/slider/448slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
images/slider/449slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
images/slider/450slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
images/slider/451slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
images/slider/452slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
images/slider/453slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
images/slider/454slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
images/slider/455slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
images/slider/456slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
images/slider/457slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
images/slider/458slider.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

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