API Path
/aipaas/cv/v2/image/8000110023
请求协议
HTTPS
请求头部 :
| 头部标签 | 必填 | 说明 | 类型 | 数据字典 | 限制 | 头部内容 | 示例 |
|---|---|---|---|---|---|---|---|
| Content-Type | 是 | application/json | [string] | application/json | application/json | ||
| X-APP-ID | 是 | 买家中心-已购能力-【X-APP-ID】 | [string] | ||||
| Device-Uuid | 是 | 设备管理-设备uuid | [string] | ||||
| Authorization | 是 | 新鉴权调用时必传 | [string] |
请求参数 Json
Object
| 参数名 | 说明 | 必填 | 类型 | 数据字典 | 限制 | 示例 |
|---|---|---|---|---|---|---|
| code | 请求状态码,固定1025 | 是 | [int] | 1019 | ||
| data | 算法参数 | 是 | [object] | |||
| data>>task_id | 算法任务id | 是 | [string] | 0d04322bee08401a9c15a5ef8643e64f | ||
| data>>camera_id | 设备编码 | 是 | [string] | A15414521025 | ||
| data>>algo_tasks | 任务列表,当前能力长度必须为2,输入2张图片,第1个参数中的图片作为基准图,第二个作为现场图 | 是 | [array] | |||
| data>>algo_tasks>>image | 图片Base64(jpeg格式base64编码)【和image二选一,优先使用image字段】 | 否 | [string] | iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAFVBMVEX////7ODj+z8/9eHj9m5v9s7P7TEwZgBMVAAAACXBIWXMAAAsTAAALEwEAmpwYAAAATklEQVQokd2NQQqAQAzEMjNd//9kUXEXFw8eBMEcCiUlha9p8lspC6ukwDZHeBcBNcvUJICkAjwVheV2k4pUkMvzWo5U307kLiSNkz+wAvF5AMTthEMUAAAAAElFTkSuQmCC | ||
| data>>algo_tasks>>image_url | 图片地址【和image二选一,优先使用image字段】 | 否 | [string] | |||
| data>>algo_tasks>>algo_config | 任务参数 | 是 | [object] | |||
| data>>algo_tasks>>algo_config>>version | 参数版本号,本业务不使用 | 否 | [string] | 1.0.0 | ||
| data>>algo_tasks>>algo_config>>algo_roi | roi区域配置【如果算法不支持roi,忽略此参数解析】 | 是 | [object] | |||
| data>>algo_tasks>>algo_config>>algo_roi>>is_full_region | 是否全景图,true-是,false-否。要求bool 输入"0"时可自动转为false 输入"1"时可自动转为true,其他情况可能有未知错误 | 是 | [boolean] | true:是,false:否 | true | |
| data>>algo_tasks>>algo_config>>algo_roi>>roi_type | roi坐标类型,1-绝对坐标,2-相对坐标【is_full_region为true时为非必填】。要求int 输入为正确数字对应的string时可自动转为int,其他情况可能有未知错误 | 否 | [int] | 1:绝对坐标,2:相对坐标 | 1 | |
| data>>algo_tasks>>algo_config>>algo_roi>>region_mode | 区域模式,1 中心点在区域内 其他报错,该字段V1.0.0版本后不再使用,填1。要求int 输入为正确数字对应的string时可自动转为int,其他情况可能有未知错误 | 是 | [int] | 1:检测框中心点在区域内即代表检测目标在区域内,2:检测框脚点在区域内即代表检测目标在区域内,3:检测框中心点与脚点同时在区域内即代表检测目标在区域内,4:检测框中心点或脚点在区域内即代表检测目标在区域内 | 1 | |
| data>>algo_tasks>>algo_config>>algo_roi>>roi_list | 设定区域列表【is_full_region为false时为必填】 | 否 | [array] | |||
| data>>algo_tasks>>algo_config>>algo_roi>>roi_list>>name | 区域id,需全局唯一 | 是 | [string] | 61b3a095eb0bc49 | ||
| data>>algo_tasks>>algo_config>>algo_roi>>roi_list>>point_list | 区域坐标点集【由算法内部判断,画线至少需要2个点,画多边形区域至少需要3个点】 | 是 | [array] | |||
| data>>algo_tasks>>algo_config>>algo_roi>>roi_list>>point_list>>x | X轴坐标 | 是 | [float] | 0.0 | ||
| data>>algo_tasks>>algo_config>>algo_roi>>roi_list>>point_list>>y | Y轴坐标 | 是 | [float] | 1.0 | ||
| data>>algo_tasks>>algo_config>>extra_params | 额外参数,见详细说明。只有第一张图片的extra_params信息回被解析,第二张图不做解析 可以不填,不填按1v1处理 | 否 | [array] | |||
| data>>algo_tasks>>algo_config>>extra_params>>key | 参数名 | 是 | [string] | |||
| data>>algo_tasks>>algo_config>>extra_params>>value | 参数值 | 是 | [string] |
响应内容 :
返回结果
> 成功 (200)
> Json
> Object
| 参数名 | 说明 | 必填 | 类型 | 数据字典 | 限制 | 示例 |
|---|---|---|---|---|---|---|
| code | 算法类型,固定1026 | 是 | [int] | 1020 | ||
| data | 算法调用结果 | 是 | [object] | |||
| data>>error_code | 错误码,值为APP_ERR_OK则为成功 | 是 | [string] | APP_ERR_OK | ||
| data>>error_message | 错误描述 | 是 | [string] | 正常状态 | ||
| data>>camera_id | 创建任务时传入的设备编码 | 是 | [string] | A15414521025 | ||
| data>>task_id | 创建任务时传入的算法任务id | 是 | [string] | 0d04322bee08401a9c15a5ef8643e64f | ||
| data>>frame_id | 视频帧id | 是 | [string] | 0d04322bee08401a9c15a5ef8sldufj8 | ||
| data>>frame_width | 图片宽度 | 是 | [string] | 1920 | ||
| data>>frame_height | 图片高度 | 是 | [string] | 1080 | ||
| data>>send_pts_ms | 告警推送时的时间戳;图片流为无效值,不用取值 | 是 | [string] | |||
| data>>pull_pts_ms | 拉流的时间戳;图片流为无效值,不用取值 | 是 | [string] | |||
| data>>display_image | 图片jpeg编码,图片流为空 | 是 | [string] | |||
| data>>algo_outputs | 算法处理结果数组 | 是 | [array] | |||
| data>>algo_outputs>>roi_message | 设定区域信息 | 否 | [object] | |||
| data>>algo_outputs>>roi_message>>name | 创建任务时传入的区域id | 是 | [string] | 61b3a095eb0bc49 | ||
| data>>algo_outputs>>roi_message>>point_list | 创建任务时传入的区域坐标点集 | 是 | [array] | |||
| data>>algo_outputs>>roi_message>>point_list>>x | 创建任务时传入的X轴坐标 | 是 | [float] | 0.0 | ||
| data>>algo_outputs>>roi_message>>point_list>>y | 创建任务时传入的Y轴坐标 | 是 | [float] | 1.0 | ||
| data>>algo_outputs>>roi_message>>extra_params | 创建任务时传入的区域其他参数,此业务未使用 | 否 | [array] | |||
| data>>algo_outputs>>roi_message>>extra_params>>key | 创建任务时传入的参数名 | 是 | [string] | alarm | ||
| data>>algo_outputs>>roi_message>>extra_params>>value | 创建任务时传入的参数值 | 是 | [string] | 1 | ||
| data>>algo_outputs>>objectinfo | 检测到的目标对象数组 | 是 | [array] | |||
| data>>algo_outputs>>objectinfo>>class_name | 目标类别名称;face | 是 | [string] | 目标类别名称 | ||
| data>>algo_outputs>>objectinfo>>class_id | 当前目标类别id; 0:face | 是 | [int] | 1 | ||
| data>>algo_outputs>>objectinfo>>rect | 对象位置坐标 | 是 | [object] | |||
| data>>algo_outputs>>objectinfo>>rect>>x0 | 左上X轴坐标 | 是 | [float] | 0.0 | ||
| data>>algo_outputs>>objectinfo>>rect>>y0 | 左上Y轴坐标 | 是 | [float] | 0.0 | ||
| data>>algo_outputs>>objectinfo>>rect>>x1 | 右下X轴坐标 | 是 | [float] | 100.0 | ||
| data>>algo_outputs>>objectinfo>>rect>>y1 | 右下Y轴坐标 | 是 | [float] | 100.0 | ||
| data>>algo_outputs>>objectinfo>>confidence | 人脸质量得分取值[-1,1]。-1:非人脸 0:较差不可用;>0:可用 | 是 | [float] | 0.99 | ||
| data>>algo_outputs>>objectinfo>>track_id | 此业务中当做人脸id编号,从0开始,表示在当前图片中人脸框的编号 | 否 | [string] | 0d04322bee0 | ||
| data>>algo_outputs>>objectinfo>>score | 目标得分,此业务未使用,值为-1 | 否 | [float] | 0.99 | ||
| data>>algo_outputs>>objectinfo>>extra_message | 目标额外信息,此业务未使用 | 否 | [array] | |||
| data>>algo_outputs>>objectinfo>>extra_message>>key | 参数名 | 是 | [string] | |||
| data>>algo_outputs>>objectinfo>>extra_message>>value | 参数值 | 是 | [string] | |||
| data>>algo_outputs>>objectinfo>>image_message | 目标图片信息,此业务未使用 | 否 | [array] | |||
| data>>algo_outputs>>objectinfo>>image_message>>key | 图片名称 | 是 | [string] | xxx.jpg | ||
| data>>algo_outputs>>objectinfo>>image_message>>value | 图片Base64【jpeg格式base64编码】 | 是 | [string] | iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAFVBMVEX////7ODj+z8/9eHj9m5v9s7P7TEwZgBMVAAAACXBIWXMAAAsTAAALEwEAmpwYAAAATklEQVQokd2NQQqAQAzEMjNd//9kUXEXFw8eBMEcCiUlha9p8lspC6ukwDZHeBcBNcvUJICkAjwVheV2k4pUkMvzWo5U307kLiSNkz+wAvF5AMTthEMUAAAAAElFTkSuQmCC | ||
| data>>algo_outputs>>objectinfo>>feature | 特征值,此业务未使用 | 否 | [array] | [0.0620517209172249, 0.0471773408353329] | ||
| data>>algo_outputs>>objectinfo>>attribute | 属性值,此业务未使用 | 否 | [array] | |||
| data>>algo_outputs>>objectinfo>>attribute>>key | 属性名称 | 是 | [string] | sex | ||
| data>>algo_outputs>>objectinfo>>attribute>>value | 属性值 | 是 | [string] | 1 | ||
| data>>algo_outputs>>objectinfo>>attribute>>score | 属性置信度(0~1),未知为-1 | 是 | [float] | 0.99 | ||
| data>>extra_message | 额外信息,见详细信息 | 否 | [array] | |||
| data>>extra_message>>key | 参数名 | 是 | [string] | |||
| data>>extra_message>>value | 参数值 | 是 | [string] | |||
| data>>image_message | 图片流值为空 | 否 | [array] |
成功示例[Mock API] :
{
"code": 1026,
"data": {
"algo_outputs": [{
"objectinfo": [{
"attribute": [],
"big_model_flag": 0,
"class_id": 0,
"class_name": "face",
"confidence": 0.94054526100000002,
"extra_message": [],
"feature": [],
"image_message": [],
"rect": {
"x0": 268.50213600000001,
"x1": 779.48230000000001,
"y0": 514.792236,
"y1": 1032.24585
},
"score": -1,
"track_id": "0"
}],
"roi_message": {
"extra_params": [],
"name": "position_1",
"point_list": [{
"x": 0,
"y": 0
},
{
"x": 0,
"y": 2165
},
{
"x": 1000,
"y": 2165
},
{
"x": 1000,
"y": 0
}
]
}
},
{
"objectinfo": [{
"attribute": [],
"big_model_flag": 0,
"class_id": 0,
"class_name": "face",
"confidence": 0.94813060800000004,
"extra_message": [],
"feature": [],
"image_message": [],
"rect": {
"x0": 220.53645299999999,
"x1": 350.82486,
"y0": 445.15588400000001,
"y1": 578.16955599999994
},
"score": -1,
"track_id": "0"
}],
"roi_message": {
"extra_params": [],
"name": "",
"point_list": [{
"x": 0,
"y": 0
},
{
"x": 0,
"y": 1288
},
{
"x": 800,
"y": 1288
},
{
"x": 800,
"y": 0
}
]
}
}
],
"camera_id": "1",
"display_image": "",
"error_code": "APP_ERR_OK",
"error_message": "",
"extra_message": [{
"key": "score_matrix",
"value": "[{\"track_id1\":\"0\",\"track_id2\":\"0\",\"score\":55.95397186279297}]"
}],
"frame_height": "1288",
"frame_id": "0",
"frame_width": "800",
"image_message": [],
"pull_pts_ms": "0",
"send_pts_ms": "1754468548730",
"task_id": "task_1"
}
}
详细说明 :
| 版本 | 算法总集版本号 | 备注 |
|---|---|---|
| 人脸比对(8000110023) | 初始版本 |
1.服务接口调用时需要严格遵循服务鉴权规则,新老调用鉴权方式亦存在差异。
新调用鉴权规则请参见:开发指南 - 内网签名认证方式。
2.服务调用头信息
新的鉴权方式:调用时header头信息X-APP-ID,Device-Uuid,Authorization必传,
旧的鉴权方式:调用时header头信息X-APP-ID,X-APP-KEY,Order-Num,Device-Uuid必填
3.1
人脸用10.0.1版本
只支持全图。
3.2、入参中extra_message对应key及value表(选填):
| extra_message | Array | 备注 | |
|---|---|---|---|
| "key":"task_type“ | string | 固定值:只能填task_type | |
| value": "1" | string | 固定值:只能填1、2或31:人脸1v1(每张图片都只有1个人脸),只能用类似大头照的图片才能检测到人脸2:人脸1vN(第一张图片保留1个人脸需要用类似大头照的图片,第二张图片保留所有人脸,可以用大图)3:人脸MvN(两张图片均保留所有人脸,两张图片都可以用大图) |
3.3、出参中extra_message对应key及value表
| extra_message | Array | 备注 | |
|---|---|---|---|
| "key":"score_matrix“ | string | 固定值"score_matrix" | |
| value":"[{"track_id1":"0","track_id2":"1","score":75}]" | string | JSON格式的list转成的字符串,数据格式如下:{ "track_id1":"0", "track_id2":"1", "score":75}表示:第一张图片中的第0个人脸与第二张图片中的第1个人脸的相似度得分为75 |
3.4、请求示例
请求示例:
{
"code": 1025,
"data": {
"camera_id": "1",
"task_id": "task_1",
"algo_tasks": [{
"image": "/9xxx...",
"algo_config": {
"version": "algo_version",
"algo_roi": {
"is_full_region": true,
"roi_type": 1,
"region_mode": 1,
"roi_list": []
},
"extra_params": [{
"key": "task_type",
"value": "1"
}]
}
},
{
"image": "/9xxx...",
"algo_config": {
"version": "algo_version",
"algo_roi": {
"is_full_region": true,
"roi_type": 1,
"region_mode": 1,
"roi_list": []
},
"extra_params": [
]
}
}
]
}
}
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 人脸比对 使用 Hutool HttpUtil 的简化版本
*/
public class SimpleHutoolExample {
public static void main(String[] args){
//请求该请求地址和
String str = sendSimplePost("http://127.0.0.0.1:8080", "1","1","1");
System.out.println("请求结果为:"+str);
}
public static String sendSimplePost(String baseUrl, String appId, String deviceUuid, String authorization) {
try {
String url = baseUrl + "/aipaas/cv/v2/image/8000110023";
// 构建请求参数(使用 Map 和 List)
Map requestMap = new HashMap();
requestMap.put("code", 1025);
Map dataMap = new HashMap();
dataMap.put("camera_id", "1");
dataMap.put("task_id", "task_1");
// 构建 algo_tasks
List algoTasks = new ArrayList();
// 第一个任务
Map task1 = new HashMap();
task1.put("image", "/9xxx...");
Map config1 = new HashMap();
config1.put("version", "algo_version");
Map roi1 = new HashMap();
roi1.put("is_full_region", true);
roi1.put("roi_type", 1);
roi1.put("region_mode", 1);
roi1.put("roi_list", new ArrayList());
List extraParams1 = new ArrayList();
Map extra1 = new HashMap();
extra1.put("key", "task_type");
extra1.put("value", "1");
extraParams1.add(extra1);
config1.put("algo_roi", roi1);
config1.put("extra_params", extraParams1);
task1.put("algo_config", config1);
algoTasks.add(task1);
// 第二个任务
Map task2 = new HashMap();
task2.put("image", "/9xxx...");
Map config2 = new HashMap();
config2.put("version", "algo_version");
Map roi2 = new HashMap();
roi2.put("is_full_region", true);
roi2.put("roi_type", 1);
roi2.put("region_mode", 1);
roi2.put("roi_list", new ArrayList());
config2.put("algo_roi", roi2);
config2.put("extra_params", new ArrayList());
task2.put("algo_config", config2);
algoTasks.add(task2);
dataMap.put("algo_tasks", algoTasks);
requestMap.put("data", dataMap);
String requestBody = JSONUtil.toJsonStr(requestMap);
// 设置请求头
Map headers = new HashMap();
headers.put("X-APP-ID", appId);
headers.put("Device-Uuid", deviceUuid);
headers.put("Authorization", authorization);
System.out.println("发送请求到: " + url);
System.out.println("请求参数: " + requestBody);
// 使用 HttpUtil 发送 POST 请求
String response = HttpUtil.createPost(url)
.addHeaders(headers)
.body(requestBody)
.timeout(30000)
.execute()
.body();
return response;
} catch (Exception e) {
e.printStackTrace();
return "{\"error\": \"请求失败: " + e.getMessage() + "\"}";
}
}
}
import json
import requests
def send_post_request(base_url, app_id, device_uuid, auth):
try:
# 构建完整请求URL
url = f"{base_url}/aipaas/cv/v2/image/8000110023"
# 构建请求数据(注意:image字段需替换为真实的Base64编码图片)
request_data = {
"code": 1025,
"data": {
"camera_id": "1",
"task_id": "task_1",
"algo_tasks": [
{
"image": "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAKAAoDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAv/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAABgj/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwD0K//Z",
# 示例Base64图片(可替换为真实值)
"algo_config": {
"version": "algo_version",
"algo_roi": {
"is_full_region": True,
"roi_type": 1,
"region_mode": 1,
"roi_list": []
},
"extra_params": [
{
"key": "task_type",
"value": "1"
}
]
}
},
{
"image": "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAKAAoDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAv/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAABgj/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwD0K//Z",
# 示例Base64图片(可替换为真实值)
"algo_config": {
"version": "algo_version",
"algo_roi": {
"is_full_region": True,
"roi_type": 1,
"region_mode": 1,
"roi_list": []
},
"extra_params": []
}
}
]
}
}
# 设置请求头
headers = {
"X-APP-ID": app_id,
"Device-Uuid": device_uuid,
"Authorization": auth,
"Content-Type": "application/json"
}
# 打印请求信息(调试用)
print(f"===== 请求信息 =====")
print(f"请求URL: {url}")
print(f"请求头: {json.dumps(headers, indent=2)}")
print(f"请求体: {json.dumps(request_data, indent=2, ensure_ascii=False)}")
# 发送POST请求
response = requests.post(
url=url,
json=request_data,
headers=headers,
timeout=30,
verify=False # 若不需要验证SSL证书,设为False
)
# 解析响应结果
print(f"\n===== 响应信息 =====")
print(f"响应状态码: {response.status_code}")
print(f"响应头: {json.dumps(dict(response.headers), indent=2)}")
# 尝试解析JSON响应,若解析失败则返回原始文本
try:
response_json = response.json()
response_text = json.dumps(response_json, indent=2, ensure_ascii=False)
except json.JSONDecodeError:
response_text = response.text
print(f"响应体: {response_text}")
return response_text
except requests.exceptions.Timeout:
error_msg = '{"error": "请求超时", "code": 408}'
print(f"\n请求失败: {error_msg}")
return error_msg
except requests.exceptions.ConnectionError:
error_msg = '{"error": "连接错误(请检查URL/网络)", "code": 503}'
print(f"\n请求失败: {error_msg}")
return error_msg
except requests.exceptions.SSLError:
error_msg = '{"error": "SSL证书验证失败", "code": 525}'
print(f"\n请求失败: {error_msg}")
return error_msg
except Exception as e:
error_msg = f'{{"error": "请求失败: {str(e)}", "code": 500}}'
print(f"\n请求失败: {error_msg}")
return error_msg
# 主函数:配置参数并调用请求函数
if __name__ == "__main__":
# ===================== 配置区(请根据实际情况修改)=====================
BASE_URL = "https://openapi.teleagi.cn:443" # 替换为真实基础URL
APP_ID = "e9244d3c79784e8c84f98de8798a086f" # 替换为真实APP ID
DEVICE_UUID = "device_1234567890" # 替换为真实设备UUID
AUTH_TOKEN = "teleai-cloud-auth-v1/e9244d3c79784e8c84f98de8798a086f/GD/1765423384/999999/x-app-id/046313b191986ba445225fc9cab6a027d3d8f4e83d21dc7380feffffe3fdfbcc" # 替换为真实授权令牌
# =====================================================================
# 调用请求函数
result = send_post_request(
base_url=BASE_URL,
app_id=APP_ID,
device_uuid=DEVICE_UUID,
auth=AUTH_TOKEN
)
# 最终结果输出
print(f"\n===== 最终结果 =====")
print(result)