Hermes
|
02a70eec3e
|
fix(rotate): 双图旋转搜索段改成 FIFO+visited+上限,并修正 cv::rotate 枚举
Build and Push / build (push) Successful in 4m2s
1) 上一版用下标 for 模拟 Python「边遍历边追加、且会删掉更差项」的写法,
删掉下标小于 cur 的元素后 cur 又退回原位 → cur 永远推进不了,接口直接挂死
(实测 HTTP 请求 400 秒不返回,CF 侧 504)。
改成 FIFO 队列 + 已算角度集合 + 评估次数上限 600:语义等价且一定终止。
2) cv::rotate 的枚举与 np.rot90 不同:np.rot90 是逆时针(k=1 逆 90°),
cv::rotate 是 0=顺时针90 / 1=180 / 2=逆时针90,直接把 k 传进去语义就错了,
而且 k=3 是非法枚举值。改成显式映射。
3) 环带统一压到 256 以内再 matchTemplate:官方例图只有 110px,
我们的例图会到 400~600px,不压的话每次匹配几十毫秒,36 次粗搜就到分钟级。
对照基准:用纯 cv2 复刻上游 solve_double_rotate 跑同一对官方例图得到
{similarity 0.8927, inner_angle 25.5, raw_angle 51},annulus 220x220,耗时 0.31s。
|
2026-12-03 18:34:39 +08:00 |
|
Hermes
|
2225f04866
|
feat(rotate): 双图旋转改为上游的环带模板匹配算法
Build and Push / build (push) Successful in 5m59s
原来那版是「RotNet(内圈) − RotNet(外圈) 取模」,纯粹自己凑的,与上游毫无对应关系,
所以结果 344 无法解释也无法校验。
按上游 solve_double_rotate 逐行移植(pkg/opencv/opencv.cpp 新增 cv_double_rotate):
1) 内圈:rot90 四次数「整行只有纯黑/纯白」的行数 → 上下左右剪边 → 按短边取偶数直径 resize
2) 外圈:从中心沿四条射线找第一个非纯黑非纯白像素 → 外扩 resize_check_pixel → 剪边 resize
3) 两边各做圆环 mask(半径 R / 内半径 R-check_pixel)得到环带
4) 内圈环带按候选角 getRotationMatrix2D+warpAffine 旋转,与外圈环带 matchTemplate
(TM_CCOEFF_NORMED) 取最大相似度;粗搜 1..360 step 10,命中更好就追加 angle±10 细化窗口,
最多保留 5 个候选(与上游边遍历边追加的行为一致)
5) inner_angle = raw_angle * speed_ratio/(speed_ratio+1)
返回结构也对齐上游:{angle(兼容), inner_angle, raw_angle, similarity};
剪不出有效环带时返回 -2,HTTP 层映射成 400。
|
2026-12-03 18:14:42 +08:00 |
|
Hermes
|
20b79b0445
|
fix(opencv): 阴影滑块按上游列扫描重写,修 findContours 三通道崩溃
Build and Deploy / build (push) Failing after 3m22s
Build and Deploy / deploy (push) Skipped
上一版只加了尺寸校验,同尺寸输入暴露出第二个 bug:
threshold 之后仍是 CV_8UC3 就交给 findContours →
"FindContours supports only CV_8UC1 images"
现在按上游 AntiCAP solve_slider_comparison 的算法重写:
· absdiff 逐通道,任一道 > 80 记为差异像素(对齐 image.point(lambda x: 255 if x > 80 else 0))
· 三通道掩码用 cv::compare + bitwise_or 合成单通道 CV_8UC1
· 逐列扫描:差异像素 >= 5 的列 → start_x = 列号+2,start_y = 首次达标行号-5(与上游一致)
· 列扫描找不到时退回最大差异区域外接矩形(保留旧路径作为兜底)
· 尺寸不一致返回 -2,Go 侧映射成 400
|
2026-12-03 08:43:24 +08:00 |
|
Hermes
|
68f181e0ac
|
fix: 相似度改走双输出 Siamese(对齐上游 AntiCAP),阴影滑块补尺寸校验
Build and Deploy / build (push) Failing after 3m8s
Build and Deploy / deploy (push) Skipped
对照上游 https://github.com/81NewArk/AntiCAP 逐项核对后修两处:
1) 相似度(internal/captcha/handler.go + pkg/onnx)
上游是 outputs = session.run(None, feed); emb1, emb2 = outputs[0], outputs[1]
—— 模型本身分别吐出两路 embedding。
旧实现只 run 了 1 个输出(onnx.cpp 里 Run 的 output_count = 1),
再把这个张量从中间切成两半当两个 embedding,
实测四组完全不同的输入返回同一个值(0.49188173),等于接口失效。
现在新增 onnx_run_dual_input_two_outputs 取前两个输出,
两路各算 L2 距离后 1/(1+dist);单输出模型保留旧路径回退并打日志。
2) 阴影滑块(pkg/opencv + internal/handler)
上游 solve_slider_comparison 要求 target 与 background 同尺寸
(PIL ImageChops.difference 的硬前提),旧实现不校验,
尺寸不同时直接抛 OpenCV -209 尺寸不匹配,返回 500。
现在前置校验并返回 400 + 明确原因;SliderMatch 也补了「滑块不能大于背景」的校验。
预处理与旋转逻辑核对结论:preprocessSiamese(105×105 / ImageNet norm)与
preprocessRotation(正方形中心裁剪 + h/√2 + 224 / ImageNet norm)与上游一致,未改。
|
2026-12-03 08:23:51 +08:00 |
|
admin
|
8dcbfb5535
|
fix: handle YOLO11 output format [1,5,8400] with transpose for OpenCV DNN
Build and Deploy / build (push) Successful in 2m36s
Build and Deploy / deploy (push) Successful in 9s
|
2026-07-17 08:54:23 +00:00 |
|
admin
|
5c3b7ef81d
|
fix: CastTypeInfoToTensorInfo 使用 const 指针
Build and Deploy / build (push) Failing after 2m55s
Build and Deploy / deploy (push) Has been skipped
|
2026-07-16 22:37:14 +00:00 |
|
admin
|
1962f75a47
|
fix: ONNX Runtime API 兼容 - 添加 OrtEnv 环境
Build and Deploy / build (push) Failing after 2m27s
Build and Deploy / deploy (push) Has been skipped
|
2026-07-16 22:29:13 +00:00 |
|
admin
|
145e8c99ba
|
fix: 添加 ONNX Runtime 头文件路径和 fstream 头文件
Build and Deploy / build (push) Failing after 2m25s
Build and Deploy / deploy (push) Has been skipped
|
2026-07-16 22:24:13 +00:00 |
|
admin
|
015b1406e2
|
feat: 完整实现 CGO 版本 - ONNX Runtime + OpenCV DNN (YOLO)
Build and Deploy / build (push) Failing after 2m22s
Build and Deploy / deploy (push) Has been skipped
|
2026-07-16 21:27:26 +00:00 |
|
admin
|
7afefe5e9f
|
feat: 实现 ONNX Runtime CGO 绑定和 OCR/Math 推理逻辑
Build and Deploy / build (push) Failing after 2m23s
Build and Deploy / deploy (push) Has been skipped
|
2026-07-16 21:14:34 +00:00 |
|
admin
|
ffd99a25c3
|
fix: add Image struct definition in opencv.cpp
Build and Deploy / build (push) Successful in 2m4s
Build and Deploy / deploy (push) Has been skipped
|
2026-07-16 13:30:24 +00:00 |
|
admin
|
6bbec4da4a
|
fix: use pkg-config for opencv4 in CGO
Build and Deploy / build (push) Failing after 1m50s
Build and Deploy / deploy (push) Has been skipped
|
2026-07-16 13:04:31 +00:00 |
|
admin
|
4bf7f609e7
|
fix: use CPPFLAGS for OpenCV include path
Build and Deploy / build (push) Failing after 1m56s
Build and Deploy / deploy (push) Has been skipped
|
2026-07-16 12:50:39 +00:00 |
|
admin
|
2230a4404f
|
fix: add OpenCV 4 include path in CGO directives
Build and Deploy / build (push) Failing after 1m26s
Build and Deploy / deploy (push) Has been skipped
|
2026-07-16 12:33:18 +00:00 |
|
admin
|
524c404194
|
feat: initial commit - Go + CGO captcha recognition service
Build and Deploy / build-frontend (push) Failing after 2s
Build and Deploy / build-backend (push) Has been skipped
Build and Deploy / build-docker (push) Has been skipped
Build and Deploy / deploy (push) Has been skipped
Features:
- Go + CGO ONNX/OpenCV wrapper for high performance
- SQLite (default) / MySQL database support
- Optional Redis caching
- JWT authentication system
- Multiple captcha recognition APIs:
- OCR text recognition
- Slider captcha matching
- Image similarity comparison
- Rotation captcha detection
- Object detection
- React frontend with install wizard
- Docker and docker-compose support
- Gitea CI/CD pipeline
Project structure:
- cmd/server: Main entry point
- internal/: Core business logic
- pkg/onnx: ONNX Runtime CGO wrapper
- pkg/opencv: OpenCV CGO wrapper
- web/: React frontend
- deploy/: Deployment configs
- scripts/: Utility scripts
|
2026-07-16 08:56:38 +00:00 |
|