API Path
/aipaas/cv/v2/image/2102048
请求协议
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 | 请求状态码,固定1019 | 是 | [int] | |||
| 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-相对坐标 | 是 | [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 | 区域模式 | 是 | [int] | 1:检测框中心点在区域内即代表检测目标在区域内,2:检测框脚点在区域内即代表检测目标在区域内,3:检测框中心点与脚点同时在区域内即代表检测目标在区域内,4:检测框中心点或脚点在区域内即代表检测目标在区域内 | 1 | |
| data>>algo_tasks>>algo_config>>extra_params | 算法定制化参数 | 否 | [array] | [{"key":"algo_type","value":"7009"},{"key":"threshold","value":"0.65"},{"key":"warningCount","value":"2"}] | ||
| data>>algo_tasks>>algo_config>>extra_params>>key | 参数名【多算法算法标识key必须为algo_type,阈值为threshold,连续超过几次告警为warningCount】 | 是 | [string] | algo_type:多算法包算法标识,threshold:阈值,warningCount:连续超过几次告警 | ||
| data>>algo_tasks>>algo_config>>extra_params>>value | 参数值【key=algo_type时为具体算法标识,key=threshold时为0~1之间的小数,key=warningCount时为整数】 | 是 | [string] | |||
| 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>>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 | 算法结果告警时时间戳。距离1970-01-01毫秒数 | 是 | [string] | 1694078498549 | ||
| data>>pull_pts_ms | 算法拉流时间戳。距离1970-01-01毫秒数 | 是 | [string] | 1694078498549 | ||
| data>>display_image | 告警场景图Base64【jpeg格式base64编码】 | 是 | [string] | iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAFVBMVEX////7ODj+z8/9eHj9m5v9s7P7TEwZgBMVAAAACXBIWXMAAAsTAAALEwEAmpwYAAAATklEQVQokd2NQQqAQAzEMjNd//9kUXEXFw8eBMEcCiUlha9p8lspC6ukwDZHeBcBNcvUJICkAjwVheV2k4pUkMvzWo5U307kLiSNkz+wAvF5AMTthEMUAAAAAElFTkSuQmCC | ||
| 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 | 目标类别名称 | 是 | [string] | 目标类别名称 | ||
| data>>algo_outputs>>objectinfo>>class_id | 目标类别id | 是 | [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) | 是 | [float] | 0.99 | ||
| data>>algo_outputs>>objectinfo>>track_id | 目标追踪ID | 是 | [string] | 0d04322bee0 | ||
| data>>algo_outputs>>objectinfo>>score | 该算法未返回该值,为-1 | 是 | [float] | 0.99 | ||
| data>>algo_outputs>>objectinfo>>feature | 特征值,float数组【特征提取算法必返回】 | 否 | [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) | 是 | [string] | 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>>extra_message>>key | 参数名【如果为多算法镜像,固定返回算法标识的key必须为algo_type】 | 是 | [string] | algo_type | ||
| data>>extra_message>>value | 参数值【如果为多算法镜像,值为具体算法标识】 | 是 | [string] | 7009 | ||
| data>>image_message | 额外图片信息,此业务未使用 | 否 | [array] | |||
| data>>image_message>>key | 图片名称 | 是 | [string] | xxx.jpg | ||
| data>>image_message>>value | 图片Base64【jpeg格式base64编码】 | 是 | [string] | iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAFVBMVEX////7ODj+z8/9eHj9m5v9s7P7TEwZgBMVAAAACXBIWXMAAAsTAAALEwEAmpwYAAAATklEQVQokd2NQQqAQAzEMjNd//9kUXEXFw8eBMEcCiUlha9p8lspC6ukwDZHeBcBNcvUJICkAjwVheV2k4pUkMvzWo5U307kLiSNkz+wAvF5AMTthEMUAAAAAElFTkSuQmCC |
成功示例[Mock API] :
{
"code": 1020,
"data": {
"error_code": "APP_ERR_OK",
"error_message": "",
"camera_id": "11111",
"task_id": "22222",
"frame_id": "0",
"frame_width": "1920",
"frame_height": "1080",
"send_pts_ms": "1724381197478",
"pull_pts_ms": "0",
"display_image": "",
"algo_outputs": [{
"roi_message": {
"name": "1234",
"point_list": [{
"x": 0,
"y": 0
}, {
"x": 1200,
"y": 0
}, {
"x": 1200,
"y": 500
}, {
"x": 0,
"y": 500
}],
"extra_params": [{
"key": "algo_type",
"value": "7031"
}]
},
"objectinfo": [{
"class_name": "CTAI_CITY_WGCS",
"class_id": 6,
"rect": {
"x0": 942,
"y0": 226,
"x1": 1166,
"y1": 450
},
"confidence": 0.803159654,
"track_id": "",
"score": -1,
"extra_message": [{
"key": "det_score",
"value": "0.0"
}, {
"key": "type_name",
"value": ""
}],
"image_message": [],
"feature": [],
"attribute": []
}]
}, {
"roi_message": {
"name": "11111111",
"point_list": [{
"x": 0,
"y": 500
}, {
"x": 800,
"y": 500
}, {
"x": 800,
"y": 1000
}, {
"x": 0,
"y": 1000
}],
"extra_params": [{
"key": "algo_type",
"value": "7039"
}]
},
"objectinfo": [{
"class_name": "CTAI_CITY_ZDJY",
"class_id": 14,
"rect": {
"x0": 333,
"y0": 286,
"x1": 929,
"y1": 882
},
"confidence": 0.696377516,
"track_id": "",
"score": -1,
"extra_message": [{
"key": "det_score",
"value": "0.0"
}, {
"key": "type_name",
"value": ""
}],
"image_message": [],
"feature": [],
"attribute": []
}]
}, {
"roi_message": {
"name": "2222222222",
"point_list": [{
"x": 800,
"y": 0
}, {
"x": 1200,
"y": 0
}, {
"x": 1200,
"y": 500
}, {
"x": 800,
"y": 500
}],
"extra_params": [{
"key": "algo_type",
"value": "7039"
}]
},
"objectinfo": [{
"class_name": "CTAI_CITY_ZDJY",
"class_id": 14,
"rect": {
"x0": 942,
"y0": 272,
"x1": 1166,
"y1": 496
},
"confidence": 0.803159654,
"track_id": "",
"score": -1,
"extra_message": [{
"key": "det_score",
"value": "0.0"
}, {
"key": "type_name",
"value": ""
}],
"image_message": [],
"feature": [],
"attribute": []
}]
}, {
"roi_message": {
"name": "position_0_7040",
"point_list": [{
"x": 0,
"y": 0
}, {
"x": 1920,
"y": 0
}, {
"x": 1920,
"y": 1080
}, {
"x": 0,
"y": 1080
}],
"extra_params": [{
"key": "algo_type",
"value": "7040"
}]
},
"objectinfo": []
}],
"extra_message": [],
"image_message": []
}
}
详细说明 :
| 版本 | 算法总集版本号 | 备注 |
|---|---|---|
| 城市治理(2102048)-(v1.1.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、 支持画多个区域(最多3个),区域点数(支持3-18个点),可以通过配置文件修改
4、 点的顺序要为逆时针或者顺时针,不能乱序。
5、支持任意边数多边形,不限凹凸,不支持有孔多边形,不支持自相交多边形,一个区域不允许它的点在本区域的其他边上,同一个子算法(algo_type相同)的两个区域的范围不能重叠,不同子算法的区域可以重叠,区域的点坐标不能超出图片的大小范围,区域个数不能超过设定的最大值(最多3个)
6、 检测目标在区域内的判断逻辑
针对此算法而言,检测框底边中点在区域内即检测目标在区域内。
7、 全图检测与区域检测的传参设置
全图检测:is_full_region=true且region_mode=6
区域检测:is_full_region=false且region_mode=6且roi_type=1或者2 且roi_list传相应坐标值
CTAI_CITY_LJMY 垃圾满溢
CTAI_CITY_LJWG 垃圾桶未盖盖子
CTAI_CITY_DLBJ 道路不洁
CTAI_CITY_YJLS 沿街晾晒
CTAI_CITY_LDZL 绿地脏乱
CTAI_CITY_WGCS 违规撑伞
CTAI_CITY_WGGG 违规广告
CTAI_CITY_WGXG 违规小广告
CTAI_CITY_LDWL 乱堆物料
CTAI_CITY_WGJY 违规经营
CTAI_CITY_BLLJ 暴露垃圾
CTAI_CITY_WGHF 违规横幅
CTAI_CITY_DLJS 道路积水
CTAI_CITY_ZDJY 占道经营
CTAI_CITY_DWJY 店外经营
CTAI_CITY_WZYS 游商小贩
CTAI_CITY_SDLJ 私搭乱建
CTAI_CITY_SYBJ 水域不洁
1 - CTAI_CITY_LJMY 垃圾满溢
2 - CTAI_CITY_LJWG 垃圾桶未盖盖子
3 - CTAI_CITY_DLBJ 道路不洁
4 - CTAI_CITY_YJLS 沿街晾晒
5 - CTAI_CITY_LDZL 绿地脏乱
6 - CTAI_CITY_WGCS 违规撑伞
7 - CTAI_CITY_WGGG 违规广告
8 - CTAI_CITY_WGXG 违规小广告
9 - CTAI_CITY_LDWL 乱堆物料
10 - CTAI_CITY_WGJY 违规经营
11 - CTAI_CITY_BLLJ 暴露垃圾
12 - CTAI_CITY_WGHF 违规横幅
13 - CTAI_CITY_DLJS 道路积水
14 - CTAI_CITY_ZDJY 占道经营
15 - CTAI_CITY_DWJY 店外经营
16 - CTAI_CITY_WZYS 游商小贩
17 - CTAI_CITY_SDLJ 私搭乱建
18 - CTAI_CITY_SYBJ 水域不洁
| key | value |
|---|---|
| algo_type | 子业务algo_type:垃圾桶满溢:7026;垃圾桶未盖盖子:7027;道路不洁:7028;沿街晾晒:7029;绿地脏乱:7030;违规撑伞:7031;违规广告:7032;违规小广告:7033; //暂未支持乱堆物料:7034; //暂未支持违规经营:7035;暴漏垃圾:7036;违规横幅:7037;//暂未支持道路积水:7038;//暂未支持占道经营:7039;店外经营:7040;游商小贩:7041;//暂未支持私搭乱建:7042;//暂未支持水域不洁:7043; |
| warning_count | 超过warning_count次告警,默认值为1 |
| threshold | 分类得分阈值有效子业务:垃圾桶满溢:7026;默认阈值:0.8;建议范围[0.8,1)垃圾桶未盖盖子:7027;默认阈值:0.8;建议范围[0.8,1)违规经营:7035; 默认阈值:0.7;建议范围[0.7,1)暴漏垃圾:7036;默认阈值:0.8;建议范围[0.8,1)占道经营:7039;默认阈值:0.7;建议范围[0.7,1)店外经营:7040;默认阈值:0.7;建议范围[0.7,1) |
出参extra_message
| key | value |
|---|---|
| det_score | 检测模型置信度分 |
| type_name | 检测模型检出的类别:"spit_ball", "bottle", "makeshift_garbage_can", "garbage_can", "airing", "chair", "table", "box", "vegetables","fruits", "clothes", "kitchen_ware", "sun_shade", "food_trolley", "tricycle", "balloon", "illegal_board", "illegal_ads", "clutter_bags", "clutter_stone", "others" |
{
"data": {
"camera_id": "11111",
"task_id": "22222",
"algo_tasks": [{
"algo_config": {
"algo_roi": {
"is_full_region": false,
"roi_type": 1,
"region_mode": 6,
"roi_list": [{
"name": "1234",
"point_list": [{
"x": 0,
"y": 0
},
{
"x": 1200,
"y": 0
},
{
"x": 1200,
"y": 500
},
{
"x": 0,
"y": 500
}
]
}]
},
"extra_params": [{
"key": "algo_type",
"value": "7031"
},
{
"key": "warning_count",
"value": "1"
},
{
"key": "threshold",
"value": "0.89"
}
]
}
},
{
"algo_config": {
"algo_roi": {
"is_full_region": false,
"roi_type": 1,
"region_mode": 6,
"roi_list": [{
"name": "11111111",
"point_list": [{
"x": 0,
"y": 500
},
{
"x": 800,
"y": 500
},
{
"x": 800,
"y": 1000
},
{
"x": 0,
"y": 1000
}
]
},
{
"name": "2222222222",
"point_list": [{
"x": 800,
"y": 0
},
{
"x": 1200,
"y": 0
},
{
"x": 1200,
"y": 500
},
{
"x": 800,
"y": 500
}
]
}
]
},
"extra_params": [{
"key": "algo_type",
"value": "7039"
},
{
"key": "warning_count",
"value": "1"
},
{
"key": "threshold",
"value": "0.7"
}
]
}
},
{
"algo_config": {
"algo_roi": {
"is_full_region": true,
"roi_type": 1,
"region_mode": 6,
"roi_list": []
},
"extra_params": [{
"key": "algo_type",
"value": "7040"
},
{
"key": "warning_count",
"value": "1"
},
{
"key": "threshold",
"value": "0.7"
}
]
}
}
],
"image": "**** **** **** **** **** *"
},
"code": 1019
}
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpUtils {
public static void sendPostRequest() {
HttpURLConnection connection = null;
try {
String code = "code";
String url = "http://url:端口/aipass/aipassweb-api/openapi/openApi/v2/ai/2102048";
String appId = "appid";
String deviceUuid = "deviceUuid";
URL urlObj = new URL(url);
connection = ((HttpURLConnection) (urlObj.openConnection()));
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("X-APP-ID", appId);
connection.setRequestProperty("Device-Uuid", deviceUuid);
connection.setRequestProperty("Authorization", "yourAuthorization");
connection.setDoOutput(true);
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode requestBody = objectMapper.createObjectNode();
requestBody.put("code", 0);
requestBody.put("llm_check", 0);
ObjectNode dataNode = requestBody.putObject("data");
dataNode.put("task_id", "0d04322bee08401a9c15a5ef8643e64f");
dataNode.put("camera_id", "A15414521025");
ArrayNode algoTasksArray = dataNode.putArray("algo_tasks");
ObjectNode algoTaskNode = algoTasksArray.addObject();
ObjectNode algoConfigNode = algoTaskNode.putObject("algo_config");
algoConfigNode.put("version", "1.0.0");
ObjectNode algoRoiNode = algoConfigNode.putObject("algo_roi");
algoRoiNode.put("roi_type", 1);
ArrayNode roiListArray = algoRoiNode.putArray("roi_list");
ObjectNode roiListNode = roiListArray.addObject();
roiListNode.put("name", "61b3a095eb0bc49");
ArrayNode pointListArray = roiListNode.putArray("point_list");
ObjectNode pointNode = pointListArray.addObject();
pointNode.put("x", 0.0);
pointNode.put("y", 1.0);
ArrayNode extraParamsArray = roiListNode.putArray("extra_params");
ObjectNode extraParamNode = extraParamsArray.addObject();
extraParamNode.put("key", "type");
extraParamNode.put("value", "1");
algoRoiNode.put("is_full_region", true);
algoRoiNode.put("region_mode", 1);
ArrayNode extraParamsAlgoArray = algoConfigNode.putArray("extra_params");
ObjectNode extraAlgoParamNode = extraParamsAlgoArray.addObject();
extraAlgoParamNode.put("key", "");
extraAlgoParamNode.put("value", "");
dataNode.put(
"image",
"iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAFVBMVEX////7ODj+z8/9eHj9m5v9s7P7TEwZgBMVAAAACXBIWXMAAAsTAAALEwEAmpwYAAAATklEQVQokd2NQQqAQAzEMjNd//9kUXEXFw8eBMEcCiUlha9p8lspC6ukwDZHeBcBNcvUJICkAjwVheV2k4pUkMvzWo5U307kLiSNkz+wAvF5AMTthEMUAAAAAElFTkSuQmCC");
dataNode.put(
"image_url",
"http://10.127.156.152:8081/bucket/f7884c2f-0efc-42ae-0372-e30eddddc53b.jpg");
try (OutputStream os = connection.getOutputStream()) {
byte[] input = requestBody.toString().getBytes("utf-8");
os.write(input, 0, input.length);
}
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
try (BufferedReader br =
new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"))) {
StringBuilder response = new StringBuilder();
String responseLine;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
String responseString = response.toString();
JsonNode jsonResponse = objectMapper.readTree(responseString);
JsonNode data = jsonResponse.get("data");
}
} else {
System.out.println("POST request not worked");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (connection != null) {
connection.disconnect();
}
}
}
}
import json
import requests
def send_post_request():
"""
发送POST请求到指定API端点
"""
try:
# 配置参数
url = "https://openapi.teleagi.cn:443/aipaas/cv/v2/image/2102048"
app_id = "e9244d3c79784e8c84f98de8798a086f"
device_uuid = "suiyichuan"
authorization = "teleai-cloud-auth-v1/e9244d3c79784e8c84f98de8798a086f/GD/1765535320/999999/x-app-id/518ab1d7255ca0ae60d5c3ab48f64fbf60a701abff7a9bd50b44876d1fc989ea"
# 构建请求头
headers = {
"Content-Type": "application/json",
"X-APP-ID": app_id,
"Device-Uuid": device_uuid,
"Authorization": authorization
}
# 构建请求体 - 与Java代码完全对应
request_body = {
"code": 0,
"llm_check": 0,
"data": {
"task_id": "0d04322bee08401a9c15a5ef8643e64f",
"camera_id": "A15414521025",
"algo_tasks": [
{
"algo_config": {
"version": "1.0.0",
"algo_roi": {
"roi_type": 1,
"roi_list": [
{
"name": "61b3a095eb0bc49",
"point_list": [
{
"x": 0.0,
"y": 1.0
}
],
"extra_params": [
{
"key": "type",
"value": "1"
}
]
}
],
"is_full_region": True,
"region_mode": 1
},
"extra_params": [
{
"key": "algo_type",
"value": "7031"
}
]
}
}
],
"image": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAFVBMVEX////7ODj+z8/9eHj9m5v9s7P7TEwZgBMVAAAACXBIWXMAAAsTAAALEwEAmpwYAAAATklEQVQokd2NQQqAQAzEMjNd//9kUXEXFw8eBMEcCiUlha9p8lspC6ukwDZHeBcBNcvUJICkAjwVheV2k4pUkMvzWo5U307kLiSNkz+wAvF5AMTthEMUAAAAAElFTkSuQmCC",
"image_url": "http://10.127.156.152:8081/bucket/f7884c2f-0efc-42ae-0372-e30eddddc53b.jpg"
}
}
# 发送POST请求
response = requests.post(
url=url,
headers=headers,
json=request_body,
timeout=30
)
# 处理响应
if response.status_code == 200:
response_data = response.json()
data = response_data.get("data")
print("POST请求成功")
return data
else:
print(f"POST请求失败,状态码: {response.status_code}")
print(f"响应内容: {response.text}")
return None
except requests.exceptions.RequestException as e:
print(f"请求异常: {e}")
return None
except json.JSONDecodeError as e:
print(f"JSON解析错误: {e}")
return None
except Exception as e:
print(f"其他错误: {e}")
return None
# 使用示例
if __name__ == "__main__":
result = send_post_request()
if result is not None:
print("请求处理成功")
print(f"返回数据: {result}")
else:
print("请求处理失败")