Align task API and add FunCaptcha support

This commit is contained in:
Hua
2026-03-12 19:32:59 +08:00
parent ef9518deeb
commit bc6776979e
33 changed files with 3446 additions and 672 deletions

View File

@@ -3,7 +3,7 @@
生成滑块验证码训练数据:随机纹理/色块背景 + 方形缺口 + 阴影效果。
标签 = 缺口中心 x 坐标 (整数)
文件名格式: {gap_x}_{index:06d}.png
文件名格式: {gap_center_x}_{index:06d}.png
"""
import random
@@ -29,13 +29,14 @@ class SlideDataGenerator(BaseCaptchaGenerator):
rng = self.rng
gs = self.gap_size
# 缺口 x 范围: 留出边距
# 缺口左边界 x 范围: 留出边距,标签统一使用缺口中心 x
margin = gs + 10
gap_x = rng.randint(margin, self.width - margin)
gap_left = rng.randint(margin, self.width - margin)
gap_y = rng.randint(10, self.height - gs - 10)
gap_center_x = gap_left + gs // 2
if text is None:
text = str(gap_x)
text = str(gap_center_x)
# 1. 生成纹理背景
img = self._textured_background(rng)
@@ -46,12 +47,12 @@ class SlideDataGenerator(BaseCaptchaGenerator):
# 阴影 (稍大一圈)
overlay_draw.rectangle(
[gap_x + 2, gap_y + 2, gap_x + gs + 2, gap_y + gs + 2],
[gap_left + 2, gap_y + 2, gap_left + gs + 2, gap_y + gs + 2],
fill=(0, 0, 0, 60),
)
# 缺口本体
overlay_draw.rectangle(
[gap_x, gap_y, gap_x + gs, gap_y + gs],
[gap_left, gap_y, gap_left + gs, gap_y + gs],
fill=(80, 80, 80, 160),
outline=(60, 60, 60, 200),
width=2,