---
name: php186-skill-69918
description: "验证码识别工具集，支持文本、滑块、旋转、选择等验证方式的识别。注意：一定要遵守目标网站或系统的使用条款和法律法规，在允许的条件下使用。"
---

# 验证码识别工具集

## 验证码识别工具集

 

验证码识别工具集，支持文本、滑块、旋转、选择等验证方式的识别。注意：一定要遵守目标网站或系统的使用条款和法律法规，在允许的条件下使用。

 

## ⚠️ 强制要求：API 密钥

 

**此 Skill 必须配置 API 密钥才能使用。**

 

- 首次使用时，如果 ` .env ` 中没有 ` XBY_APIKEY `，**必须使用 AskUserQuestion 工具向用户询问 API 密钥**
- 拿到用户提供的密钥后，调用 ` scripts.config.set_api_key(api_key) ` 保存，然后继续处理
- 获取 API 密钥：https://xiaobenyang.com
- **禁止**在缺少 API 密钥时自行搜索或编造数据

 

## 工作流程（必须遵守）

 

你（大模型）是路由层，负责理解用户意图、选择工具、提取参数。代码只负责调用API。

 

```
用户输入 → 你选择工具 → 提取该工具需要的参数 → 调用 scripts.tools 中的函数 → 返回结果给用户
```

 

### 步骤

 

1. **检查 API 密钥**：如果 ` scripts.config.settings.api_key ` 为空，使用 AskUserQuestion 询问用户，拿到后调用 ` scripts.config.set_api_key(key) ` 保存
2. **选择工具**：根据用户意图从下方工具列表中选择对应的工具函数
3. **提取参数**：根据选中的工具，提取该工具需要的参数
4. **调用工具**：使用**关键字参数**调用 ` scripts.tools ` 中的函数，例如 ` scripts.tools.search_schools(score='520', province='北京', category='综合') `
5. **返回结果**：将工具返回的 ` raw ` 数据整理后展示给用户

 

## 工具选择规则

 

根据用户意图选择对应的工具函数：

 

| 用户意图 | 工具函数 |
| --- | --- |
| 识别图片中的文字（数字、字母、汉字），输入常见验证码图片，返回验证码文本内容和置信度。 需要输入图片文件链接。 | ` scripts.tools.find_chars ` |
| 识别图片中的文字（数字、字母、汉字），输入常见验证码图片，返回验证码文本内容和置信度。 需要输入图片文件的BASE64编码。 | ` scripts.tools.find_chars_for_data_base64 ` |
| 根据目标（滑块）图在背景图（带缺口）中找到最佳匹配位置，返回缺口坐标。 需要输入图片文件链接。 | ` scripts.tools.slide_match_target_background ` |
| 根据目标（滑块）图在背景图（带缺口）中找到最佳匹配位置，返回缺口坐标。 需要输入图片文件的BASE64编码。 | ` scripts.tools.slide_match_target_background_for_data_base64 ` |
| 在背景图（带缺口）中找到缺口位置，即滑块的最佳匹配位置，返回缺口坐标。 需要输入图片文件链接。 | ` scripts.tools.slide_match_only_background ` |
| 在背景图（带缺口）中找到缺口位置，即滑块的最佳匹配位置，返回缺口坐标。 需要输入图片文件的BASE64编码。 | ` scripts.tools.slide_match_only_background_for_data_base64 ` |
| 找到目标图与背景图的差异区域，定位阴影滑块位置。返回差异区域起始坐标。 需要输入图片文件链接。 | ` scripts.tools.slide_compare ` |
| 找到目标图与背景图的差异区域，定位阴影滑块位置。返回差异区域起始坐标。 需要输入图片文件的BASE64编码。 | ` scripts.tools.slide_compare_for_data_base64 ` |
| 计算目标图像（内圈）相对于背景图像（外圈）的旋转角度，返回旋转角度。 需要输入图片文件链接。 | ` scripts.tools.rotate_double ` |
| 计算目标图像（内圈）相对于背景图像（外圈）的旋转角度，返回旋转角度。 需要输入图片文件的BASE64编码。 | ` scripts.tools.rotate_double_for_data_base64 ` |
| 识别图像的旋转角度，支持 0-359 度范围，返回旋转角度 (0-359) 需要输入图片文件链接。 | ` scripts.tools.rotate_single ` |
| 识别图像的旋转角度，支持 0-359 度范围，返回旋转角度 (0-359) 需要输入图片文件的BASE64编码。 | ` scripts.tools.rotate_single_for_data_base64 ` |
| 根据顺序提示图中的图标顺序，在目标图中检测对应图标并按顺序返回坐标。 需要输入图片文件链接。 | ` scripts.tools.detect_icon ` |
| 根据顺序提示图中的图标顺序，在目标图中检测对应图标并按顺序返回坐标。 需要输入图片文件的BASE64编码。 | ` scripts.tools.detect_icon_for_data_base64 ` |
| 根据顺序提示图中的文字顺序，在目标图中检测对应文字并按顺序返回坐标。 需要输入图片文件链接。 | ` scripts.tools.detect_text ` |
| 根据顺序提示图中的文字顺序，在目标图中检测对应文字并按顺序返回坐标。 需要输入图片文件的BASE64编码。 | ` scripts.tools.detect_text_for_data_base64 ` |
| 计算两张图片的相似度，输入两张图片，返回相似度分数 (0-1，越接近1越相似)。 需要输入图片文件链接。 | ` scripts.tools.compare_image ` |
| 计算两张图片的相似度，输入两张图片，返回相似度分数 (0-1，越接近1越相似)。 需要输入图片文件的BASE64编码。 | ` scripts.tools.compare_image_for_data_base64 ` |
| 识别图像中的数学表达式，支持加减乘除运算，自动计算结果。返回算术表达式和计算结果。 需要输入图片文件链接。 | ` scripts.tools.solve_math ` |
| 识别图像中的数学表达式，支持加减乘除运算，自动计算结果。返回算术表达式和计算结果。 需要输入图片文件的BASE64编码。 | ` scripts.tools.solve_math_for_data_base64 ` |

 

**如果参数不完整，使用 AskUserQuestion 向用户询问缺失的参数。**

 

## 工具函数说明

 

## scripts.tools.find\_chars

 

工具描述：识别图片中的文字（数字、字母、汉字），输入常见验证码图片，返回验证码文本内容和置信度。 需要输入图片文件链接。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| dataUrl | string | true |  | 图片文件链接地址 |

 

## scripts.tools.find\_chars\_for\_data\_base64

 

工具描述：识别图片中的文字（数字、字母、汉字），输入常见验证码图片，返回验证码文本内容和置信度。 需要输入图片文件的BASE64编码。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| dataBase64 | string | true |  | base64 encoded data of image file |

 

## scripts.tools.slide\_match\_target\_background

 

工具描述：根据目标（滑块）图在背景图（带缺口）中找到最佳匹配位置，返回缺口坐标。 需要输入图片文件链接。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| dataUrl | string | true |  | 图片文件链接地址 |
| targetImageBase64 | string | false |  | Base64编码的目标图片文件数据 |
| backgroundImageBase64 | string | false |  | Base64编码的背景图片文件数据 |

 

## scripts.tools.slide\_match\_target\_background\_for\_data\_base64

 

工具描述：根据目标（滑块）图在背景图（带缺口）中找到最佳匹配位置，返回缺口坐标。 需要输入图片文件的BASE64编码。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| dataBase64 | string | true |  | base64 encoded data of image file |
| targetImageBase64 | string | false |  | Base64编码的目标图片文件数据 |
| backgroundImageBase64 | string | false |  | Base64编码的背景图片文件数据 |

 

## scripts.tools.slide\_match\_only\_background

 

工具描述：在背景图（带缺口）中找到缺口位置，即滑块的最佳匹配位置，返回缺口坐标。 需要输入图片文件链接。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| dataUrl | string | true |  | 图片文件链接地址 |
| backgroundImageBase64 | string | false |  | Base64编码的背景图片文件数据 |

 

## scripts.tools.slide\_match\_only\_background\_for\_data\_base64

 

工具描述：在背景图（带缺口）中找到缺口位置，即滑块的最佳匹配位置，返回缺口坐标。 需要输入图片文件的BASE64编码。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| dataBase64 | string | true |  | base64 encoded data of image file |
| backgroundImageBase64 | string | false |  | Base64编码的背景图片文件数据 |

 

## scripts.tools.slide\_compare

 

工具描述：找到目标图与背景图的差异区域，定位阴影滑块位置。返回差异区域起始坐标。 需要输入图片文件链接。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| dataUrl | string | true |  | 图片文件链接地址 |
| targetImageBase64 | string | false |  | Base64编码的目标图片文件数据 |
| backgroundImageBase64 | string | false |  | Base64编码的背景图片文件数据 |

 

## scripts.tools.slide\_compare\_for\_data\_base64

 

工具描述：找到目标图与背景图的差异区域，定位阴影滑块位置。返回差异区域起始坐标。 需要输入图片文件的BASE64编码。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| dataBase64 | string | true |  | base64 encoded data of image file |
| targetImageBase64 | string | false |  | Base64编码的目标图片文件数据 |
| backgroundImageBase64 | string | false |  | Base64编码的背景图片文件数据 |

 

## scripts.tools.rotate\_double

 

工具描述：计算目标图像（内圈）相对于背景图像（外圈）的旋转角度，返回旋转角度。 需要输入图片文件链接。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| dataUrl | string | true |  | 图片文件链接地址 |
| targetImageBase64 | string | false |  | Base64编码的目标图片文件数据 |
| backgroundImageBase64 | string | false |  | Base64编码的背景图片文件数据 |

 

## scripts.tools.rotate\_double\_for\_data\_base64

 

工具描述：计算目标图像（内圈）相对于背景图像（外圈）的旋转角度，返回旋转角度。 需要输入图片文件的BASE64编码。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| dataBase64 | string | true |  | base64 encoded data of image file |
| targetImageBase64 | string | false |  | Base64编码的目标图片文件数据 |
| backgroundImageBase64 | string | false |  | Base64编码的背景图片文件数据 |

 

## scripts.tools.rotate\_single

 

工具描述：识别图像的旋转角度，支持 0-359 度范围，返回旋转角度 (0-359) 需要输入图片文件链接。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| dataUrl | string | true |  | 图片文件链接地址 |
| imageBase64 | string | false |  | Base64编码的图片文件数据 |

 

## scripts.tools.rotate\_single\_for\_data\_base64

 

工具描述：识别图像的旋转角度，支持 0-359 度范围，返回旋转角度 (0-359) 需要输入图片文件的BASE64编码。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| imageBase64 | string | false |  | Base64编码的图片文件数据 |
| dataBase64 | string | true |  | base64 encoded data of image file |

 

## scripts.tools.detect\_icon

 

工具描述：根据顺序提示图中的图标顺序，在目标图中检测对应图标并按顺序返回坐标。 需要输入图片文件链接。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| dataUrl | string | true |  | 图片文件链接地址 |
| orderImageBase64 | string | false |  | Base64编码的包含次序信息的图片文件数据 |
| targetImageBase64 | string | false |  | Base64编码的目标图片文件数据 |

 

## scripts.tools.detect\_icon\_for\_data\_base64

 

工具描述：根据顺序提示图中的图标顺序，在目标图中检测对应图标并按顺序返回坐标。 需要输入图片文件的BASE64编码。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| orderImageBase64 | string | false |  | Base64编码的包含次序信息的图片文件数据 |
| dataBase64 | string | true |  | base64 encoded data of image file |
| targetImageBase64 | string | false |  | Base64编码的目标图片文件数据 |

 

## scripts.tools.detect\_text

 

工具描述：根据顺序提示图中的文字顺序，在目标图中检测对应文字并按顺序返回坐标。 需要输入图片文件链接。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| dataUrl | string | true |  | 图片文件链接地址 |
| orderImageBase64 | string | false |  | Base64编码的包含次序信息的图片文件数据 |
| targetImageBase64 | string | false |  | Base64编码的目标图片文件数据 |

 

## scripts.tools.detect\_text\_for\_data\_base64

 

工具描述：根据顺序提示图中的文字顺序，在目标图中检测对应文字并按顺序返回坐标。 需要输入图片文件的BASE64编码。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| orderImageBase64 | string | false |  | Base64编码的包含次序信息的图片文件数据 |
| dataBase64 | string | true |  | base64 encoded data of image file |
| targetImageBase64 | string | false |  | Base64编码的目标图片文件数据 |

 

## scripts.tools.compare\_image

 

工具描述：计算两张图片的相似度，输入两张图片，返回相似度分数 (0-1，越接近1越相似)。 需要输入图片文件链接。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| dataUrl | string | true |  | 图片文件链接地址 |
| image2Base64 | string | false |  | Base64编码的2号图片文件数据 |
| image1Base64 | string | false |  | Base64编码的1号图片文件数据 |

 

## scripts.tools.compare\_image\_for\_data\_base64

 

工具描述：计算两张图片的相似度，输入两张图片，返回相似度分数 (0-1，越接近1越相似)。 需要输入图片文件的BASE64编码。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| image2Base64 | string | false |  | Base64编码的2号图片文件数据 |
| dataBase64 | string | true |  | base64 encoded data of image file |
| image1Base64 | string | false |  | Base64编码的1号图片文件数据 |

 

## scripts.tools.solve\_math

 

工具描述：识别图像中的数学表达式，支持加减乘除运算，自动计算结果。返回算术表达式和计算结果。 需要输入图片文件链接。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| dataUrl | string | true |  | 图片文件链接地址 |
| imageBase64 | string | false |  | Base64编码的图片文件数据 |

 

## scripts.tools.solve\_math\_for\_data\_base64

 

工具描述：识别图像中的数学表达式，支持加减乘除运算，自动计算结果。返回算术表达式和计算结果。 需要输入图片文件的BASE64编码。

 

### 参数定义

 

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| imageBase64 | string | false |  | Base64编码的图片文件数据 |
| dataBase64 | string | true |  | base64 encoded data of image file |

 

## 返回值处理

 

工具函数返回 ` dict ` 对象：

 

- ` result["raw"] ` - API 原始返回数据（JSON），**直接将此数据整理后展示给用户**
- ` result["success"] ` - 是否成功（True/False）
- ` result["message"] ` - 状态消息

 

## 项目结构

 

```
./
├── scripts/
│   ├── __init__.py
│   ├── config.py       # 配置管理 + set_api_key()
│   ├── call_api.py      # API 客户端 + call_api()
│   └── tools.py         # 工具函数（直接调用）
├── requirements.txt
└── SKILL.md
```

 

## 注意事项

 

1. **API 密钥是必需的**，无密钥时必须通过 AskUserQuestion 询问用户
2. **禁止**在缺少 API 密钥时自行搜索或编造数据
