更新时间:2022-03-17 GMT+08:00
分享

创建边缘交通流量作业

功能介绍

该API可分析边缘摄像头输出的RTSP视频流,提供了过线车流量统计、监测功能。给定流量统计的输出间隔,得到车流量信息。

目前支持H264、H265编码格式的RTSP视频流。

调试

您可以在API Explorer中调试该接口。

URI

  • URI格式
    POST /v2/{project_id}/services/c-traffic-flow-edge/tasks
  • 参数说明

    参数

    是否必选

    类型

    说明

    project_id

    String

    服务所在区域对应的项目ID,获取方法请参见获取项目ID

请求

  • 请求样例1(摄像头输入+DIS/Webhook输出)
    POST /v2/6204a5bd270343b5885144cf9c8c158d/services/c-traffic-flow-edge/tasks
    {
        "name": "vehicleflowdetection-edge-task",
        "description": "vehicleflowdetection task test",
        "input": {
            "type": "edgecamera",
            "data": [
                {
                    "id": "aec5857c-222f-4aa9-be39-23654e118886",
                    "index": 0
                }
            ]
        },
        "output": {
            "dis": {
                "stream_name": "dis-campusgo"
            },
            "webhook": {
                "url": "https://apigw.huawei.com/api/event/callback",
                "headers": {
                    "content-type": "application/json"
                }
            }
        },
        "service_version": "3.0",
        "resource_order_id": "840a5cf90d4a4bbaa71f251dfe8fe64e",
        "edge_pool_id": "8dcf5ec7bc4d4a26aa1d3e1bb5ed2b5a",
        "service_config": {
            "common": {
                      "target_roi": "{\"lines\":[{\"data\":[[50,606],[100,616]],\"properties\":{\"type\":0}},{\"data\":[[50,756],[100,616]],\"properties\":{\"type\":1}},{\"data\":[[50,256],[100,116]],\"properties\":{\"type\":1}}]}",
                      "flow_output_interval": 1
            }
       }
    }
  • 请求样例2(edgerestful输入+DIS/Webhook输出)
    POST /v2/6204a5bd270343b5885144cf9c8c158d/services/c-traffic-flow-edge/tasks
    {
        "name": "vehicleflowdetection-edge-task",
        "description": "Vehicleflowdetection task test",
        "input": {
            "type": "edgerestful",
            "data": [
                {
                    "index": 0,
                    "url":"https://100.127.134.69:554/test/data",
                    "certificate_check": false,
                    "rtsp_path_in_response": "data/url"
                }
            ]
        },
        "output": {
            "dis": {
                "stream_name": "dis-campusgo"
            },
            "webhook": {
                "url": "https://apigw.huawei.com/api/event/callback",
                "headers": {
                    "content-type": "application/json"
                }
            }
        },
        "service_version": "3.0",
        "resource_order_id": "840a5cf90d4a4bbaa71f251dfe8fe64e",
        "edge_pool_id": "8dcf5ec7bc4d4a26aa1d3e1bb5ed2b5a",
        "service_config": {
            "common": {
                  "target_roi": "{\"lines\":[{\"data\":[[50,606],[100,616]],\"properties\":{\"type\":0}},{\"data\":[[50,756],[100,616]],\"properties\":{\"type\":1}},{\"data\":[[50,256],[100,116]],\"properties\":{\"type\":1}}]}",
                  "flow_output_interval": 1
             }
       }
    }
  • 请求样例3(VCN输入+DIS/Webhook输出)
    POST /v2/6204a5bd270343b5885144cf9c8c158d/services/c-traffic-flow-edge/tasks
    {
        "name": "vehicleflowdetection-edge-task",
        "description": "Vehicleflowdetection task test",
        "input": {
            "type": "vcn",
            "vcn": {
                    "ip":"172.100.119.6",
                    "password":"CQeNfcRLwyMvH77AkDBaPS+BKXdFu/1bAXtIMNTx3QPbVewjipNq06nNodxWI28I1lCUsvv2+wB1joepzynLVW3g2nz0k9vaCRDoK6=",
                    "port":"4675",
                    "username":"testname"
            },
            "data": [
                {
                    "index": 0,
                    "device_id":"07211540881586160101#f7964493ff764bbf9294d58b22e63de6",
                    "stream_type": 1
                }
            ]
        },
        "output": {
            "dis": {
                "stream_name": "dis-campusgo"
            },
            "webhook": {
                "url": "https://apigw.huawei.com/api/event/callback",
                "headers": {
                    "content-type": "application/json"
                }
            }
        },
        "service_version": "3.0",
        "resource_order_id": "840a5cf90d4a4bbaa71f251dfe8fe64e",
        "edge_pool_id": "8dcf5ec7bc4d4a26aa1d3e1bb5ed2b5a",
        "service_config": {
            "common": {           
                   "target_roi": "{\"lines\":[{\"data\":[[50,606],[100,616]],\"properties\":{\"type\":0}},{\"data\":[[50,756],[100,616]],\"properties\":{\"type\":1}},{\"data\":[[50,256],[100,116]],\"properties\":{\"type\":1}}]}",
                   "flow_output_interval": 1
            }
       }
    }
  • 参数说明

    参数

    是否必选

    类型

    说明

    name

    String

    作业名称,只能由中文、字母(a~zA~Z)、数字(0~9)、中划线(-)、下划线(_)组成,长度范围为[1,100]。

    description

    String

    作业描述信息,最大长度为500字符长度。

    input

    Object

    视频数据输入列表,支持从指定的边缘摄像头读取数据,即输入类型为“edgecamera”“edgerestful”“VCN”

    详细参数定义参见task.input(任务输入参数)

    service_version

    String

    功能版本号,版本号为3.0。边缘算法版本支持的显卡硬件为T4和华为自研Davinci芯片。

    resource_order_id

    String

    购买的算法能力包ID,在服务界面购买算法能力包获取。

    edge_pool_id

    String

    边缘运行池ID,获取方法参见创建边缘运行池

    output

    Object

    结果数据的输出列表,目前支持以下输出类型:
    • DIS:将结果输出到您指定的DIS通道 。
    • Webhook:将结果输出到Webhook URL。
    • Localpath:将作业的运行结果保存在边缘节点本地(节点必须为linux系统),必须为linux路径,例如“/opt/cloud/”

      详细参数定义见task.output(任务输出参数)

    service_config

    Object

    服务的算法配置,配置参数见ServiceConfig参数说明

    • service_config参数说明

      字段

      是否必选

      类型

      说明

      target_roi

      String

      roi区域。包括流量线和车道线的信息。

      flow_output_interval

      Int

      流量统计的输出间隔,单位为秒。

      取值范围为[1, 600],最长输出间隔为10分钟。

    • target_roi参数说明

      字段

      是否必选

      类型

      说明

      lines

      List<Object>

      道路线集合,包括流量线和车道线信息。

    • 道路线lines参数说明

    字段

    是否必选

    类型

    参数说明

    data

    List<Object>

    划线信息,即线的两个端点坐标(x1,y1)和(x2,y2)。

    properties

    Object

    道路线属性信息。

    "type"为0时表示流量线,"type"为1时表示车道线。

响应

  • 响应样例
    [
      { 
        "id": "61761681a6014e7c9024d642a0d4d412"
      }
    ]
  • 返回作业ID列表

    参数

    类型

    说明

    id

    String

    作业ID。

检测结果

  • 输出JSON数据流到DIS指定的通道或者Webhook URL,包括告警结构化数据和图片数据。
  • JSON结果示例:
    {
    	"event_type": 73728,
    	"task_id": "61761681a6014e7c9024d642a0d4d412",
    	"stream_id": "03543400000000000101#1c471506397a48ecab0ba52360bdd430",
    	"timestamp": 1535546604,
    	"message_id": "0DD1BEA6-634B-11E8-8B0B-407D0FAD9218",
    	"image_base64": "",
    	"data": {
                  "interval": 1,
                  "flow_set": [{
                        "lane_id": 0,
                        "flow_count": [15, 4]
                   },{		
                        "lane_id": 1,	
                        "flow_count": [15, 4]
                   }]  
    	}
    }
  • JSON格式说明

    字段

    类型

    说明

    event_type

    Int

    流量监测结果输出标志,固定为73728。

    task_id

    String

    作业ID。

    stream_id

    String

    摄像机ID,唯一表示;离线视频会输出视频名信息,区分不同的视频输出。

    timestamp

    Int

    输出流量监测结果的时间戳。

    message_id

    String

    该条json输出的uuid,唯一标识这一条输出记录。

    image_base64

    String

    图像的base64编码。

    data

    Object

    流量监测结果的输出信息字段集合,参见data参数格式说明。

  • data参数格式说明

    字段

    类型

    说明

    flow_set

    List<Object>

    分车道的流量监测信息列表。

    interval

    Double

    流量输出时间间隔,以秒为单位。

  • flow_set参数格式说明

    字段

    类型

    说明

    lane_id

    Int

    车道编号,视频画面从左到右开始编号,从0开始。

    flow_count

    List

    交通流量信息。

    数组[15,4]依次表示车流方向为0和1的车流量信息,其中:

    0表示从视频画面上端向下端行驶,看见车头。

    1表示从视频画面下端向上端行驶,看见车尾。

返回值

  • 正常

    201

  • 异常

    返回值

    说明

    400 Bad Request

    请求错误,具体返回错误码请参考错误码

    401 Unauthorized

    鉴权失败。

    403 Forbidden

    没有操作权限。

    404 Not Found

    找不到资源。

    500 Internal Server Error

    服务内部错误。

    503 Service Unavailable

    服务不可用。

分享:

    相关文档

    相关产品