feat(tcaptcha): 完成腾讯天御点选纯协议全自动化客户端与雨云业务适配器

This commit is contained in:
yml2213
2026-09-11 23:36:23 +08:00
parent 8df4493994
commit 5220c67a99
6 changed files with 889 additions and 15 deletions
+15 -3
View File
@@ -9,12 +9,19 @@ import numpy as np
from PIL import Image
def slice_prompt_image(prompt_img_path: str | Path, padding: int = 2) -> List[Tuple[Image.Image, Tuple[int, int, int, int]]]:
import io
def slice_prompt_image(prompt_img: str | Path | bytes | Image.Image, padding: int = 2) -> List[Tuple[Image.Image, Tuple[int, int, int, int]]]:
"""
自动识别并切割提示图中的 3 个字符/图标
返回: [(PIL_Image, (x1, y1, x2, y2)), ...]
"""
img = Image.open(prompt_img_path).convert("L")
if isinstance(prompt_img, Image.Image):
img = prompt_img.convert("L")
elif isinstance(prompt_img, bytes):
img = Image.open(io.BytesIO(prompt_img)).convert("L")
else:
img = Image.open(prompt_img).convert("L")
arr = np.array(img)
h, w = arr.shape
@@ -48,7 +55,12 @@ def slice_prompt_image(prompt_img_path: str | Path, padding: int = 2) -> List[Tu
segments = [(i * step + 5, (i + 1) * step - 5) for i in range(3)]
# 原始彩色图用于切片
orig_img = Image.open(prompt_img_path).convert("RGBA")
if isinstance(prompt_img, Image.Image):
orig_img = prompt_img.convert("RGBA")
elif isinstance(prompt_img, bytes):
orig_img = Image.open(io.BytesIO(prompt_img)).convert("RGBA")
else:
orig_img = Image.open(prompt_img).convert("RGBA")
crops = []
for seg_start, seg_end in segments[:3]: