ai_project_v1/md/接口.md
2026-01-05 16:29:39 +08:00

351 lines
7.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 算法与后台解耦规则
# 1、方法
postgres 的ai_model_list 表id字段声明为6位长度数字
1、第1位表示算法类别1xxxxx 表明为目标识别、2xxxxx标明为语义分割、3xxxxx表示变化监测
2、最后两位表示二次计算100001 表示做目标识别、100002表示做目标识别且做人员计数
# 接口名:视频流识别
接收前端的视频流、模型、识别类型算法做计算并且将计算结果存储到minio消息通过mqtt发送
## 1、请求
接口 /ai/stream/back_detect
方法 post
headers X-API-Token:5e8899fe-dc74-4280-8169-2f4d185f3afa
body
```
{
"task_id": "1234567890", #任务id
"sn":"", #无人机sn
"content_body": {
"source_url": "rtmp://192.168.0.142:1935/live/123456", #无人机视频流url
"confidence":0.4, #置信度
"model_func_id":[100001,100002] #方法id
}
}
```
## 2、响应
算法的响应分为两个部分
1、rest响应表明收到请求
2、mqtt消息持续输出计算结果
### 1、rest
```
{
"status": "success",
"task_id": "1234567890",
"message": "Detection started successfully"
}
```
### 2、mqtt
ip 112.44.103.230 端口 1883
topic thing/product/ai/events
```
{
"task_id": "1234567890",
"minio": {
"minio_path": "ai_result/20250702/1751425303860-output-1751425303800959985.jpg",
"file_type": "pic"
},
"box_detail": {
"result_100001": {
"func_id_10001": 100001,
"type_name": "行人",
"cls_count": 1,
"box_count": [
[
{
"track_id": 22099,
"confidence": 0.34013107419013977,
"cls_id": 0,
"type_name": "行人",
"box": [
15.935794830322266,
694.75390625,
33.22901916503906,
713.1658935546875
]
}
]
]
}
},
"uav_location": {
"data": {
"attitude_head": 60,
"gimbal_pitch": 60,
"gimbal_roll": 60,
"gimbal_yaw": 60,
"height": 10,
"latitude": 10,
"longitude": 10,
"speed_x": 10,
"speed_y": 10,
"speed_z": 10
},
"timestamp": 1751425301213249700
}
}
```
# 接口名:图片识别
接收前端的图片算法做计算并且将计算结果存储到minio消息通过mqtt发送
## 1、请求
接口 /ai/pic/back_detect_pic
方法 post
headers X-API-Token:5e8899fe-dc74-4280-8169-2f4d185f3afa
body
```
{
"task_id": "0001111",
"content_body": {
"s3_id":1, #根据id适配minio相关存储参数
"s3_url":[
"test/frame_0000.jpg","test/frame_0001.jpg","test/frame_0002.jpg" # minio文件地址
],
"confidence":0.4, #算法置信度
"model_func_id":[10001,10002] #方法id
}
}
```
## 2、响应
算法的响应分为两个部分
1、rest响应表明收到请求
2、mqtt消息持续输出计算结果
### 1、rest
```
{
"status": "success",
"task_id": "0001111",
"message": "Detection started successfully"
}
```
### 2、mqtt
ip 112.44.103.230 端口 1883
topic thing/product/ai/events
```
{
"task_id": "0001111", #任务id
"minio": {
"minio_path": "ai_result/20250627/1751006943659-frame_0001.jpg", # minio 存储路径
"file_type": "pic"
},
"box_detail": {
"model_id": 10001,
"box_count": [
{
"type": 3, # 类型
"type_name": "车辆", #类型名称
"count": 71 #数量
},
{
"type": 0,
"type_name": "车辆",
"count": 7
}
]
}
}
```
# 接口名:地类分割
接收前端的图片算法做计算并且将计算结果存储到minio消息通过mqtt发送
## 1、请求
接口 /ai/pic/back_detect_pic
方法 post
headers X-API-Token:5e8899fe-dc74-4280-8169-2f4d185f3afa
body
```
{
"task_id": "7a5c83e0-fe0d-47bf-a8e1-9bd663508783",
"content_body": {
"s3_id":1,#根据id适配minio相关存储参数
"s3_url":[
"test/patch_0011.png", # minio文件地址
"test/patch_0012.png"
],
"model_func_id":[20000,20001] #方法id
}
}
```
## 2、响应
算法的响应分为两个部分
1、rest响应表明收到请求
2、mqtt消息持续输出计算结果
### 1、rest
```
{
"status": "success",
"task_id": "0001111",
"message": "Detection started successfully"
}
```
### 2、mqtt
ip 112.44.103.230 端口 1883
topic thing/product/ai/events
```
{
"task_id": "7a5c83e0-fe0d-47bf-a8e1-9bd663508783",
"minio": [
{
"minio_path_before": "ai_result/20250710/1752128232469-patch_0011.png", # 需要分割的图片
"minio_path_after": "ai_result/20250710/1752128234222-patch_0011.png", #分割之后的图片
"minio_path_boundary": "ai_result/20250710/1752128234264-patch_0011.pngfinal_vis.png", # 分割的边界图片
"minio_path_json": "ai_result/20250710/1752128234326-patch_0011.pnginstance_results.json", #分割生成的json文件
"file_type": "pic"
},
{
"minio_path_before": "ai_result/20250710/1752128240382-patch_0012.png",
"minio_path_after": "ai_result/20250710/1752128241553-patch_0012.png",
"minio_path_boundary": "ai_result/20250710/1752128241587-patch_0012.pngfinal_vis.png",
"minio_path_json": "ai_result/20250710/1752128241631-patch_0012.pnginstance_results.json",
"file_type": "pic"
}
]
}
```
# 接口名:地类变化监测
接收前端的图片对一期、二期的图像做变化监测并且将计算结果存储到minio消息通过mqtt发送
## 1、请求
接口 /ai/pic/back_detect_pic
方法 post
headers X-API-Token:5e8899fe-dc74-4280-8169-2f4d185f3afa
body
```
{
"task_id": "9fa19ec3-d982-4897-af6c-2c78f786c760",
"content_body": {
"s3_id":1,
"s3_url":{
"early":"/test/1-00205.png", # 一期图像minio文件地址
"later":"/test/2-00205.png" # 二期图像minio文件地址
},
"model_func_id":[30000,30001]
}
}
```
## 2、响应
算法的响应分为两个部分
1、rest响应表明收到请求
2、mqtt消息持续输出计算结果
### 1、rest
```
{
"status": "success",
"task_id": "0001111",
"message": "Detection started successfully"
}
```
### 2、mqtt
ip 112.44.103.230 端口 1883
topic thing/product/ai/events
```
{
"task_id": "9fa19ec3-d982-4897-af6c-2c78f786c760",
"minio": {
"minio_path_1": "ai_result/20250627/1751007686483-1-00205.png", # 一期影像minio地址
"minio_path_2": "ai_result/20250627/1751007686541-2-00205.png", # 二期影像minio地址
"minio_path_result": "ai_result/20250627/1751007686.458642-result-2-00205.png", #识别结果minio地址
"file_type": "pic"
}
}
```