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

创建边缘共享单车检测作业

功能介绍

该API可分析边缘摄像头输出的RTSP视频流。提供了共享单车的检测功能。根据用户配置进行共享单车检测,当有共享单车停放在违规区域,会上报事件信息。

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

调试

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

URI

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

    参数

    是否必选

    类型

    说明

    project_id

    String

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

请求

  • 请求样例1(摄像头输入+DIS/Webhook输出)
    POST /v2/6204a5bd270343b5885144cf9c8c158d/services/c-sharedbicycledetection-edge/tasks
    {
        "name": "sharedbicycledetection-edge-task",
        "description": "Sharedbicycledetection task test",
        "input": {
            "type": "edgecamera",
            "data": [
                {
                    "id": "aec5857c-222f-4aa9-be39-23654e118886",
                    "index": 0
                }
            ]
        },
        "output": {
            "dis": {
                "stream_name": "dis-sharedbicycledetection-edge"
            },
            "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": {
                  "alert_mode": "single",
                  "alert_detection_interval": 60,
                  "illegal_park_alert_threshold": 30,
                  "render_result_sw": 1,
                  "target_roi": "{\"polygons\":[{\"data\":[[84,389],[1840,349],[1824,526],[78,526]]}]}",
                  "image_compression_ratio":90
                 }
            }
    }
  • 请求样例2(edgerestful输入+DIS/Webhook输出)
    POST /v2/6204a5bd270343b5885144cf9c8c158d/services/c-sharedbicycledetection-edge/tasks
    {
        "name": "sharedbicycledetection-edge-task",
        "description": "Sharedbicycledetection 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-sharedbicycledetection-edge"
            },
            "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": {
                  "alert_mode": "single",
                  "alert_detection_interval": 60,
                  "illegal_park_alert_threshold": 30,
                  "render_result_sw": 1,
                  "target_roi": "{\"polygons\":[{\"data\":[[84,389],[1840,349],[1824,526],[78,526]]}]}",
                  "image_compression_ratio":90
                 }
           }
    }
  • 请求样例3(VCN输入+DIS/Webhook输出)
    POST /v2/6204a5bd270343b5885144cf9c8c158d/services/c-sharedbicycledetection-edge/tasks
    {
        "name": "sharedbicycledetection-edge-task",
        "description": "Sharedbicycledetection 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-sharedbicycledetection-edge"
            },
            "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": {
                  "alert_mode": "single",
                  "alert_detection_interval": 60,
                  "illegal_park_alert_threshold": 30,
                  "render_result_sw": 1,
                  "target_roi": "{\"polygons\":[{\"data\":[[84,389],[1840,349],[1824,526],[78,526]]}]}",
                  "image_compression_ratio":90
                 }
           }
    }
  • 参数说明

    参数

    是否必选

    类型

    说明

    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中common参数说明

    字段

    是否必选

    类型

    说明

    alert_mode

    String

    对应控制台的界面参数“告警模式”

    共享单车违停告警模式,共有两种告警模式:

    • "single": 表示单次告警模式,每当出现新的告警目标时,上报告警信息。
    • "periodic": 表示周期告警模式,每过一个检测周期,上报当前所有告警目标信息。

    默认值:"single"。

    alert_detection_interval

    Int

    对应控制台的界面参数“检测周期”

    共享单车违停检测周期,单位为秒。取值范围为[1, 3600]。

    默认值:60。

    illegal_park_alert_threshold

    Int

    对应控制台的界面参数“告警触发时间”

    告警触发时间阈值,单位秒,取值范围[10,300]。共享单车停留超过这个时间则告警。

    默认值:30。

    all_print

    Int

    对应控制台的界面参数“全告警渲染开关”。

    是否开启全渲染开关在输出图片中,取值范围[0, 1],默认值为0:

    • "0":表示绘制只当前告警的目标边框,渲染方式见normal_render字段介绍;
    • "1":表示在画面中绘制所有告警过的违停共享单车,新增的告警目标与其余渲染目标在框的颜色上有所区分。

      当normal_render为0时,当前告警用红框+warning标志+红色底色渲染,历史告警用黄框+黄色底色渲染。

      当normal_render为1时,当前告警用红框渲染,历史告警用暗红色框渲染。

    只有在目标框渲染开关打开时,该字段才会生效。

    render_result_sw

    Int

    对应控制台的界面参数“目标框渲染开关”

    是否开启检测框渲染在输出图片中(渲染方式见normal_render字段说明),取值范围:

    • "0":表示不绘制。
    • "1":表示用绘制告警目标边框。

    默认值为0。

    target_roi

    String

    对应控制台的界面参数“区域设置”。

    • 合法停车区域,区域参数用"name":"legal"标识。车辆停在合法停车区域时不会触发违停事件;当"name"缺省时默认为合法停车区域。
    • 禁止停车区域,区域参数用"name":"illegal"标识。当有车辆停在禁止停车区域,则会触发违停事件。
    • 若name为"legal"和"illegal"以外的任何值,该区域默认为合法停车区域。

    该字段为JSON格式的字符串,API调用时需要加转义符。详细JSON格式参见target_roi(目标区域)。

    例如:

    {"polygons":[{"data":[[84,389],[1840,349],[1824,526],[78,526]],"name":"illegal"}]}

    参数没有携带时,默认整个视频帧都不是合法停车区,都是禁止停车区域。

    image_compression_ratio

    Int

    对应控制台的界面参数“图片压缩比”

    图片压缩百分比,取值范围为[20,100]。

    默认值:90,表示图片压缩比为90%。

    normal_render

    Int

    对应控制台的界面参数“经典渲染开关”。取值范围[0,1]。默认值为0。

    当all_print字段为0时,采用如下方式进行画面目标渲染:

    当为1时,对目标框采用红框标记。

    当为0时,对目标框采用红色边框+红色底色,同时在框左上角位置标上warning标志。

    all_print字段为1时,仍需参考all_print的值进行画面渲染,详见all_print字段介绍。

响应

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

    参数

    类型

    说明

    id

    String

    作业ID。

检测结果

  • 输出JSON数据流到DIS指定的通道或者Webhook URL,包括告警结构化数据和图片数据。
  • JSON结果示例:
    {
         "stream_id": "001",
         "event_type":655360,
         "task_id":"a9c003fa9c7843118f79ee2ddd4389f1",
         "timestamp": 1527603463,
         "message_id": "0DD1BEA6-634B-11E8-8B0B-407D0FAD9218",
         "data":{
             "event_set":[
                 {
                      "bounding_box":{
                           "x":100,
                           "y":200,
                           "w":80,
                           "h":150
                       },
                       "detection_id":"0DD1BEA6-634B-11E8-8B0B-407D0FAD9218"
                   },
                  {
                       "bounding_box":{
                            "x":200,
                            "y":300,
                            "w":70,
                            "h":150
                       },
                       "detection_id":"0DD1BEA6-634B-11E8-8B0B-407D0FAD9219"
                   }
               ]
          },
          "image_base64": "/3j24AAQSkZJRgABAQAAAQABAAD/2wBDAAIBAQE..."
    }
  • JSON格式说明

    字段

    类型

    说明

    stream_id

    String

    摄像头编号。

    event_type

    Uint64

    快速标识共享单车检测的输出消息类型。共享单车违停检测算法其值固定为655360,对应16进制为0x 0000 0000 000A 0000。

    task_id

    String

    作业ID。

    timestamp

    Uint64

    触发告警时间点的时间戳。

    message_id

    String

    告警ID,生成的唯一告警事件UUID。

    data

    Object

    详细输出内容。

    image_base64

    String

    告警时刻输入的视频图像的Base64编码结果。

  • data参数格式说明

    字段

    类型

    说明

    event_set

    List<Object>

    输出事件列表。

  • event_set参数格式说明

    字段

    类型

    说明

    bounding_box

    Object

    告警输出的违停共享单车对象矩形框。

    detection_id

    String

    每个告警目标的唯一ID标识

  • bounding_box参数格式说明

    字段

    类型

    说明

    x

    Int

    矩形框左上角横坐标。

    y

    Int

    矩形框左上角纵坐标。

    w

    Int

    矩形框宽度。

    h

    Int

    矩形框高度。

返回值

  • 正常

    201

  • 异常

    返回值

    说明

    400 Bad Request

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

    401 Unauthorized

    鉴权失败。

    403 Forbidden

    没有操作权限。

    404 Not Found

    找不到资源。

    500 Internal Server Error

    服务内部错误。

    503 Service Unavailable

    服务不可用。

分享:

    相关文档

    相关产品