API Path
/aipaas/cv/v2/image/2102032
请求协议
HTTPS
请求方法
POST
请求头部 :
| 头部标签 | 必填 | 说明 | 类型 | 数据字典 | 限制 | 头部内容 | 示例 |
|---|---|---|---|---|---|---|---|
| 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 | 请求状态码,固定1019 | 是 | [int] | 1019 | ||
| data | 算法参数 | 是 | [object] | |||
| data>>task_id | 算法任务id | 是 | [string] | 0d04322bee08401a9c15a5ef8643e64f | ||
| data>>camera_id | 设备编码 | 是 | [string] | A15414521025 | ||
| data>>algo_tasks | 算法参数数组 | 是 | [array] | |||
| 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>>roi_type | roi坐标类型,1-绝对坐标,2-相对坐标【is_full_region为true时为非必填】 | 是 | [int] | 1:绝对坐标,2:相对坐标 | 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>>algo_roi>>roi_list>>extra_params | 区域扩展参数 | 否 | [array] | |||
| data>>algo_tasks>>algo_config>>algo_roi>>roi_list>>extra_params>>key | 参数名 | 是 | [string] | type | ||
| data>>algo_tasks>>algo_config>>algo_roi>>roi_list>>extra_params>>value | 参数值 | 是 | [string] | 1 | ||
| data>>algo_tasks>>algo_config>>algo_roi>>is_full_region | 是否全景图,true-是,false-否,本算法只支持全图 | 是 | [boolean] | true:是,false:否 | true | |
| data>>algo_tasks>>algo_config>>algo_roi>>region_mode | 区域模式,1 中心点在区域内 其他报错 | 是 | [int] | 1:检测框中心点在区域内即代表检测目标在区域内,2:检测框脚点在区域内即代表检测目标在区域内,3:检测框中心点与脚点同时在区域内即代表检测目标在区域内,4:检测框中心点或脚点在区域内即代表检测目标在区域内 | 1 | |
| data>>image | 图片Base64(jpeg格式base64编码)【和image二选一,优先使用image字段】 | 否 | [string] | iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAFVBMVEX////7ODj+z8/9eHj9m5v9s7P7TEwZgBMVAAAACXBIWXMAAAsTAAALEwEAmpwYAAAATklEQVQokd2NQQqAQAzEMjNd//9kUXEXFw8eBMEcCiUlha9p8lspC6ukwDZHeBcBNcvUJICkAjwVheV2k4pUkMvzWo5U307kLiSNkz+wAvF5AMTthEMUAAAAAElFTkSuQmCC | ||
| data>>image_url | 图片地址【和image二选一,优先使用image字段】 | 否 | [string] | http://10.127.156.152:8081/bucket/f7884c2f-0efc-42ae-0372-e30eddddc53b.jpg |
响应内容 :
返回结果
> 成功 (200)
> Json
> Object
| 参数名 | 说明 | 必填 | 类型 | 数据字典 | 限制 | 示例 |
|---|---|---|---|---|---|---|
| code | 算法类型,固定1020 | 是 | [int] | 1020 | ||
| data | 算法调用结果 | 是 | [object] | |||
| data>>error_code | 错误码,值为APP_ERR_OK则为成功 | 是 | [string] | APP_ERR_OK | ||
| data>>display_image | 图片jpeg编码,图片流为空 | 是 | [string] | |||
| 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>>pull_pts_ms | 拉流的时间戳;图片流为无效值,不用取值 | 是 | [string] | |||
| data>>send_pts_ms | 告警推送时的时间戳;图片流为无效值,不用取值 | 是 | [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 | 创建任务时传入的参数名【是否告警参数名固定为alarm】 | 是 | [string] | alarm | ||
| data>>algo_outputs>>roi_message>>extra_params>>value | 创建任务时传入的参数值【是否告警固定为1或者0】 | 是 | [string] | 1 | ||
| data>>algo_outputs>>objectinfo | 检测到的目标对象数组 | 是 | [array] | |||
| data>>algo_outputs>>objectinfo>>class_name | 目标类别名称;class_name的命名统一采用小写+下划线方式填写(即蛇形)0-face 脸 1-person 人体 2-vehicle 车辆 3-nonvehicle 非机动车 | 是 | [string] | 目标类别名称 | ||
| data>>algo_outputs>>objectinfo>>class_id | 当前目标类别id;,无效值-1; 0-face 脸 1-person 人体 2-vehicle 车辆 3-nonvehicle 非机动车 | 是 | [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 | 目标置信度(0~1),未知为-1 | 是 | [float] | 0.99 | ||
| data>>algo_outputs>>objectinfo>>track_id | 目标追踪ID | 是 | [string] | 0d04322bee0 | ||
| data>>algo_outputs>>objectinfo>>score | 目标得分(0~1),未知为-1 | 是 | [float] | 0.99 | ||
| data>>algo_outputs>>objectinfo>>feature | 特征值,float数组【特征提取算法必返回】 | 否 | [array] | [0.0620517209172249, 0.0471773408353329] | ||
| data>>algo_outputs>>objectinfo>>attribute | 属性值数组此业务会传出key为ride_type和helmet_type信息;仅目标类别为1 - motor_helmet时, 该字段有效。 ride_type为车类型:10101:骑摩托车 helmet_type为帽子类型: 10202:未戴头盔 score:分类得分 | 否 | [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>>algo_outputs>>objectinfo>>extra_message | 目标额外信息,具体信息参考详细说明 | 否 | [array] | |||
| data>>algo_outputs>>objectinfo>>extra_message>>key | 参数名 | 是 | [string] | type | ||
| data>>algo_outputs>>objectinfo>>extra_message>>value | 参数值 | 是 | [string] | 1 | ||
| 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>>extra_message | 目标图片信息,图片流为空 | 否 | [array] | |||
| data>>image_message | 目标图片信息,图片流为空 | 否 | [array] |
成功示例[Mock API] :
{
"code": 1020,
"data": {
"error_code": "APP_ERR_OK",
"error_message": "",
"camera_id": "1",
"task_id": "task_1",
"frame_id": "0",
"frame_width": "1920",
"frame_height": "1080",
"send_pts_ms": "1726016467385",
"pull_pts_ms": "0",
"display_image": "",
"algo_outputs": [{
"roi_message": {
"name": "position_0",
"point_list": [{
"x": 0,
"y": 0
},
{
"x": 1920,
"y": 0
},
{
"x": 1920,
"y": 1080
},
{
"x": 0,
"y": 1080
}
],
"extra_params": []
},
"objectinfo": [{
"class_name": "nonvehicle",
"rect": {
"x0": 1314,
"y0": 608,
"x1": 1706,
"y1": 939
},
"track_id": "",
"extra_message": [{
"key": "person_number"
"value": "3"
},
{
"key": "children_list"
"value": "[100,101,102]"
}
],
"image_message": [],
"feature": [],
"attribute": [
{
"key": "nonvehicle_type",
"value": "1",
"score": 0.93467617
}
],
"class_id": 1,
"confidence": 0.857421875,
"score": -1
},
{
"class_name": "nonvehicle",
"rect": {
"x0": 754,
"y0": 591,
"x1": 1129,
"y1": 922
},
"track_id": "",
"extra_message": [{
"key": "person_number"
"value": "3"
},
{
"key": "childdren_list"
"value": "[100,101,102]"
}
],
"image_message": [],
"feature": [],
"attribute": [
{
"key": "nonvehicle_type",
"value": "1",
"score": 0.939533174
}
],
"class_id": 1,
"confidence": 0.836914062,
"score": -1
},,
{
"class_name": "face",
"rect": {
"x0": 754,
"y0": 591,
"x1": 1129,
"y1": 922
},
"track_id": "100",
"extra_message": [],
"image_message": [],
"feature": [],
"attribute": [
],
"class_id": 0,
"confidence": 0.836914062,
"score": -1
}
]
}],
"extra_message": [],
"image_message": []
}
}
详细说明 :
| 版本 | 算法总集版本号 | 备注 |
|---|---|---|
| 非机动车超载(2102032)-(v1.0.1.0_v2.3.0) | 初始版本 |
1.服务接口调用时需要严格遵循服务鉴权规则,新老调用鉴权方式亦存在差异。
新调用鉴权规则请参见:开发指南 - 内网签名认证方式。
2.服务调用头信息
调用时header头信息X-APP-ID,Device-Uuid,Authorization必传
区域条件:
1、 支持绝对坐标区域, roi_type为1。取值范围 x [0, frame_width], y [0, frame_height]
2、 支持归一化后的按比例要求区域,roi_type为2。取值范围 x,y分别为 [0,1]
3、 支持画多个区域(最多个数见pipeline_config.json配置),区域点数(支持点数见见pipeline_config.json配置)
4、 点的顺序要为逆时针或者顺时针,不能乱序。
5、支持任意边数多边形,不限凹凸,不支持有孔多边形,不支持自相交多边形,一个区域不允许它的点在本区域的其他边上,两个区域的范围不能重叠,区域的点坐标不能超出图片的大小范围,区域个数不能超过设定的最大值(最多5个)
6、 检测目标在区域内的判断逻辑
针对此算法而言,检测框中心点在区域内即检测目标在区域内。
7、 全图检测与区域检测的传参设置
全图检测:is_full_region=true
区域检测:is_full_region=false且roi_list传相应坐标值
8、出参extra_params对应key及value:
| key | value | type | 示例 |
|---|---|---|---|
| person_number | 超载人数 | string | "3" |
| childdren_list | 超载人数的数组 | string | "[100,101,102]" |
| plate_number | 车牌号 | string | "["川.E82164","京1232"]" |
| plate_bbox | 车牌框 | string | "["{"x0": 12,"y0": 34,"x1": 56,"y1": 78}","{"x0": 120,"y0": 304,"x1": 156,"y1": 718}"]" |
9、出参attribute对应key及value值:
请求示例:
{
"code": 1019,
"data": {
"camera_id": "1",
"task_id": "task_1",
"algo_tasks": [{
"algo_config": {
"version": "algo_version",
"algo_roi": {
"is_full_region": true,
"region_mode": 1,
"roi_type": 1,
"roi_list": []
},
"extra_params": []
}
}],
"image": ""
}
}
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpUtils {
public static String post() {
HttpURLConnection conn = null;
OutputStream os = null;
BufferedReader reader = null;
try {
// 创建连接
String url = "http://your-url:port/aipaas/cv/v2/image/2102032";
conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("X-APP-ID", "appid");
conn.setRequestProperty("Device-Uuid", "deviceUuid");
conn.setRequestProperty("Authorization", "yourAuthorization");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);
// 生成参数
ObjectMapper mapper = new ObjectMapper();
ObjectNode request = mapper.createObjectNode();
request.put("code", 1019);
ObjectNode data = mapper.createObjectNode();
data.put("camera_id", "1");
data.put("task_id", "task_1");
data.put("image", "");
ArrayNode tasks = mapper.createArrayNode();
ObjectNode task = mapper.createObjectNode();
ObjectNode config = mapper.createObjectNode();
config.put("version", "algo_version");
ObjectNode roi = mapper.createObjectNode();
roi.put("is_full_region", true);
roi.put("region_mode", 1);
roi.put("roi_type", 1);
roi.putArray("roi_list");
config.set("algo_roi", roi);
config.putArray("extra_params");
task.set("algo_config", config);
tasks.add(task);
data.set("algo_tasks", tasks);
request.set("data", data);
// 发送数据
String body = mapper.writeValueAsString(request);
os = conn.getOutputStream();
os.write(body.getBytes());
// 读取响应
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder response = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
response.append(line);
}
return response.toString();
} catch (Exception e) {
return "{\"error\":\"" + e.getMessage() + "\"}";
} finally {
try {
if (reader != null) reader.close();
if (os != null) os.close();
if (conn != null) conn.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
System.out.println(post());
}
}
import json
import requests
def post():
"""
发送POST请求到图像处理接口
"""
try:
# 配置参数
url = "http://your-url:port/aipaas/cv/v2/image/2102032"
headers = {
"X-APP-ID": "appid",
"Device-Uuid": "deviceUuid",
"Authorization": "yourAuthorization",
"Content-Type": "application/json"
}
# 构建请求体
request_body = {
"code": 1019,
"data": {
"camera_id": "1",
"task_id": "task_1",
"image": "",
"algo_tasks": [
{
"algo_config": {
"version": "algo_version",
"algo_roi": {
"is_full_region": True,
"region_mode": 1,
"roi_type": 1,
"roi_list": []
},
"extra_params": []
}
}
]
}
}
# 发送POST请求
response = requests.post(
url=url,
headers=headers,
json=request_body,
timeout=30
)
# 返回响应
return response.text
except Exception as e:
return json.dumps({"error": str(e)})
# 使用示例
if __name__ == "__main__":
result = post()
print(result)