AI_python_yoooger/ai2/api_inf.md
2025-07-23 11:53:56 +08:00

2.3 KiB
Raw Blame History

AI 推理 API 接口说明

🔹 1. 启动检测任务 /ai/stream/detect

  • 方法POST
  • 是否需要 Body

请求参数JSON Body

{
  "user_id": "user_12345",
  "source_url": "rtsp://192.168.10.5/live/stream1",
  "push_url": "rtmp://192.168.10.5/live/output1",
  "model_path": "best.pt",
  "detect_classes": ["person", "car", "bicycle"],
  "confidence": 0.6
}
字段名 类型 是否必填 说明
user_id string 用户 ID必须存在于数据库表 users
source_url string 输入视频流地址RTSP、本地等
push_url string 输出推流地址RTMP
model_path string 检测模型路径(.pt 文件)
detect_classes string[] 检测目标类别列表
confidence float 检测置信度阈值,默认值为 0.5

成功响应

{
  "success": true,
  "message": "任务已启动",
  "task_id": "dc391d1f-2de3-4973-9025-8975cb3e3425"
}

错误响应

{
  "success": false,
  "message": "用户无权限,禁止启动任务"
}

🔹 2. 停止指定任务 `/ai/stream/<task_id>`

* **方法**`POST`
* **是否需要 Body**:❌ 
* **描述**:根据任务 ID 停止正在运行的检测任务。

---

🔹 3. 重启指定任务 `/ai/stream/restart/<task_id>`

* **方法**`POST`
* **是否需要 Body**:❌ 
* **描述**:重启指定任务。

---

🔹 4. 查询任务状态 `/ai/stream/<task_id>`

* **方法**`GET`
* **是否需要 Body**:❌ 
* **描述**:查看指定任务的运行状态。

---

🔹 5. 获取所有任务 `/ai/stream/tasks`

* **方法**`GET`
* **是否需要 Body**:❌ 
* **描述**:返回当前所有正在运行的任务信息。

---

🔹 6. 停止所有任务 `/ai/stream/stopTasks`

* **方法**`POST`
* **是否需要 Body**:❌ 
* **描述**:停止所有正在运行的检测任务。

---

🔹 7. 重置服务 `/ai/reset`

* **方法**`POST`
* **是否需要 Body**:❌ 
* **描述**:清除全部状态,重置模型、任务、资源状态。