视觉引擎
警告
使用 createTask 创建任务。
此接口无需单独获取结果,将直接返回图像识别结果!
任务的 type
字段如下
VisionEngine
创建任务
使用 createTask 创建任务。
任务对象结构
请注意,此类任务在 createTask 后会直接返回任务执行结果,而不是通过 getTaskResult 异步获取。
属性 | 类型 | 必填 | 描述 |
---|---|---|---|
type | String | 必填 | VisionEngine |
module | String | 必填 | 所有支持的模型如下表所示 |
websiteURL | String | 可选 | 页面来源URL,用于提高准确性 |
image | String | 必填 | 图像的 base64 编码内容(无换行符,无 data:image/***;charset=utf-8;base64,) |
imageBackground | String | 必填 | 背景图像的 base64 编码内容(无换行符,无 data:image/***;charset=utf-8;base64,) |
question | String | 可选 | space_detection 需要 |
支持的图片类型
模块 | 验证码示例 | 图像 | 背景图像 |
---|---|---|---|
slider_1 | ![]() | ![]() | ![]() |
rotate_1 | ![]() | ![]() | ![]() |
rotate_2 | ![]() | ![]() | |
shein | ![]() | ![]() |
请求示例
// 使用 slider 模块的请求示例
POST https://api.capsolver.com/createTask
Host: api.capsolver.com
Content-Type: application/json
Payload:
{
"clientKey": "YOUR_API_KEY",
"task": {
"type": "VisionEngine",
"module": "slider_1",
"image": "/9j/4AAQSkZJRgABA......",
"imageBackground": "/9j/4AAQSkZJRgABA......",
"websiteURL": "https://xxxx.com"
}
}
// slider 模块的响应示例
{
"errorId": 0,
"errorCode": "",
"errorDescription": "",
"status": "ready",
"solution": {
"distance": 213,
},
"taskId": "..."
}
使用 SDK 请求
# pip install --upgrade capsolver
# export CAPSOLVER_API_KEY='...'
import capsolver
capsolver.api_key = "..."
solution = capsolver.solve({
"type": "VisionEngine",
"module": "slider_1",
"image": "/9j/4AAQSkZJRgABA......",
"imageBackground": "/9j/4AAQSkZJRgABA......"
})
print(solution)