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

创建视频车辆

功能介绍

该API可分析边缘摄像头输出的RTSP视频流,对于给定的视频,能输出视频里的车辆信息,并能根据指定的roi区域,准确输出车牌信息。

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

调试

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

URI

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

    参数

    是否必选

    类型

    说明

    project_id

    String

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

请求

  • 请求样例1(摄像头输入+DIS/Webhook输出)
    POST /v2/6204a5bd270343b5885144cf9c8c158d/services/c-vehicle-detection-edge/tasks
    {
        "name": "vehicledetection-edge-task",
        "description": "Vehicledetection task test",
        "input": {
            "type": "edgecamera",
            "data": [
                {
                    "id": "9f8933c9-448c-48e5-8bc0-631ea83b92eb",
                    "index": 0
                }
            ]
        },
        "output": {
            "dis": {
                "stream_name": "dis-vehicledetection-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": {
                           "target_roi": "{\"lines\":[{\"data\":[[50,756],[100,616]],\"properties\":{\"type\":0}},{\"data\":[[50,256],[100,116]],\"properties\":{\"type\":1}}],\"polygons\":[{\"data\":[[487,465],[1850,450],[1905,1013],[515,1050]]}]}",
    			"license_plate": {
    				"local_city": "B",
    				"local_province": "津"
    			},
    			"output_image_sw": 1,
    			"image_compression_ratio": 100
            }
       }
    }
  • 请求样例2(edgerestful输入+DIS/Webhook输出)
    POST /v2/6204a5bd270343b5885144cf9c8c158d/services/c-vehicle-detection-edge/tasks
    {
        "name": "vehicledetection-edge-task",
        "description": "Vehicledetection 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-vehicledetection-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": {       
                            "target_roi": "{\"lines\":[{\"data\":[[50,756],[100,616]],\"properties\":{\"type\":0}},{\"data\":[[50,256],[100,116]],\"properties\":{\"type\":1}}],\"polygons\":[{\"data\":[[487,465],[1850,450],[1905,1013],[515,1050]]}]}",
    			"license_plate": {
    				"local_city": "B",
    				"local_province": "津"
    			},
    			"output_image_sw": 1,
    			"image_compression_ratio": 100
            }
       }
    }
  • 请求样例3(VCN输入+DIS/Webhook输出)
    POST /v2/6204a5bd270343b5885144cf9c8c158d/services/c-vehicle-detection-edge/tasks
    {
        "name": "vehicledetection-edge-task",
        "description": "Vehicledetection 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-vehicledetection-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": {
                            "target_roi": "{\"lines\":[{\"data\":[[50,756],[100,616]],\"properties\":{\"type\":0}},{\"data\":[[50,256],[100,116]],\"properties\":{\"type\":1}}],\"polygons\":[{\"data\":[[487,465],[1850,450],[1905,1013],[515,1050]]}]}",
    			"license_plate": {
    				"local_city": "B",
    				"local_province": "津"
    			},
    			"output_image_sw": 1,
    			"image_compression_ratio": 100
            }
       }
    }
  • 参数说明

    参数

    是否必选

    类型

    说明

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

    参数

    是否必选

    类型

    说明

    target_roi

    String

    roi区域。包括车辆检测区域以及离开线和靠近线。

    license_plate

    Object

    车牌信息,具体参见license_plate参数格式说明。

    output_vehicle_type

    String

    输出车型信息,多类车型间以空格隔开。该字段不存在时默认输出所有车型。

    例如“0 1 2”表示仅输出0、1、2类车型信息,其余车型不输出。

    当前支持的车型输出:

    0 - 小汽车

    1 - 渣土车

    2 - 拖挂车

    3 - 水泥搅拌车

    4 - 环卫车

    5 - 吊车

    6 - 小货车

    7 - 巴士

    output_image_sw

    Int

    1表示输出,0表示不输出,其他值非法。

    image_compression_ratio

    Int

    输出图片的质量系数,取值范围[20,100],默认值是100。如果输入80,则输出图像清晰度是原图的80%。取值越低,则图片越模糊,客户需要接收的图片数据量越小。

  • target_roi字段参数描述

    字段

    是否必选

    类型

    说明

    lines

    List<Object>

    道路线集合,包括进入线和离开线。

    polygons

    List<Object>

    车辆检测区域。

  • lines字段参数描述

    字段

    是否必选

    类型

    说明

    data

    List<Object>

    道路线,由两个点坐标构成,格式[[x1,y1],[x2,y2]]。

    车辆进入线默认水平,画在距roi区域顶部高度占roi区域高度70%的位置。假设图像宽度为w,roi区域高度为h,roi区域顶部Y坐标为y,则该线默认位置是[[0,y+h*0.7-1],[w-1,y+h*0.7-1]]。

    车辆离开线默认水平,画在距画面顶部高度占图像高度50%的位置假设图像宽度为w,roi区域高度为h,roi区域顶部Y坐标为y,则该线默认位置是[[0,y+h*0.5-1],[w-1,y+h*0.5-1]]。

    properties

    Object

    道路线属性。

  • 道路线属性properties参数格式

    字段

    是否必选

    类型

    说明

    type

    Int

    0表示车辆靠近线,1表示车辆远离线。

    默认靠近线在远离线下方。

    当车辆从上往下行驶,触碰车辆靠近线时,发送检测结果。

    当车辆从下往上行驶,触碰车辆远离线时,发送检测结果。

    该字段可不配,算法会自动检测线的类型。

  • polygons字段参数描述

    字段

    是否必选

    类型

    说明

    data

    List<Object>

    道路线,由4个点坐标构成,格式[[x1,y1],[x2,y2],[x3,y3],[x4,y4]],由顺时针方向依次输入。

  • license_plate参数格式

    字段

    是否必选

    类型

    说明

    local_city

    String

    城市简称。

    local_province

    String

    省份简称。

    license_plate参数用来提高车牌检测的准确性,当首字符检测的置信度不高时,就会输出配置的省份信息。不会影响车辆检测。

响应

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

    参数

    类型

    说明

    id

    String

    作业ID。

检测结果

  • 输出JSON数据流到DIS指定的通道或者Webhook URL,包括告警结构化数据和图片数据。
  • JSON结果示例:
    {
    	"event_type": 75008,
    	"task_id": "a066974ae7334649a37257242c5fa4c3",
    	"stream_id": "03543400000000000101#1c471506397a48ecab0ba52360bdd430",
    	"timestamp": 1535546604,
    	"message_id": "0DD1BEA6-634B-11E8-8B0B-407D0FAD9218",
    	"image_base64": "/9j/4AAQSkZJRgABAJDA...",
    	"data": {
    		"vehicles": [{
    			"bounding_box": {
    				"x": 858,
    				"y": 200,
    				"w": 679,
    				"h": 535
    			},
    			"vehicle_type": 0,
    			"license_plate_id": "粤XXXXXX",
    			"license_plate_type": 0,
    			"direction": 1
    		}]
    	}
    }
  • JSON格式说明

    字段

    类型

    说明

    event_type

    Int

    车辆检测结果输出标志,固定为75008。

    message_id

    String

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

    stream_id

    String

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

    timestamp

    Int

    检测到视频车辆的时间戳。

    data

    Object

    视频车辆检测的输出信息字段集合,参见data参数格式说明。

    image_base64

    String

    图像的base64编码。

    task_id

    String

    作业ID。

  • data参数格式说明

    字段

    类型

    说明

    vehicles

    List<Object>

    输出车辆信息列表。

  • vehicles参数格式说明

    字段

    类型

    说明

    bounding_box

    Object

    车辆的位置坐标信息。

    vehicle_type

    Int

    检测到的车辆类型。

    -1 - 其它

    0 - 小汽车

    1 - 渣土车

    2 - 拖挂车

    3 - 水泥搅拌车

    4 - 环卫车

    5 - 吊车

    6 - 小货车

    7 - 巴士

    license_plate_id

    String

    检测到的车牌内容,当车牌内容无法识别时候输出空字符串

    license_plate_type

    Int

    检测到的车牌底色分类。0表示未知,1表示蓝色,2表示黄色,3表示绿色(新能源车),4表示白色,5表示黑色。当车牌无法识别时候输出0。

    direction

    Int

    表示检测到的车辆行驶方向

    0: 从上往下行驶,看到车头

    1: 从下往上行驶,看到车尾

  • bounding_box参数格式说明

    字段

    类型

    说明

    x

    Int

    表示车框左上角的坐标值X。

    y

    Int

    表示车框左上角的坐标值Y。

    w

    Int

    表示车框的宽W。

    h

    Int

    表示车框的高H。

返回值

  • 正常

    201

  • 异常

    返回值

    说明

    400 Bad Request

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

    401 Unauthorized

    鉴权失败。

    403 Forbidden

    没有操作权限。

    404 Not Found

    找不到资源。

    500 Internal Server Error

    服务内部错误。

    503 Service Unavailable

    服务不可用。

分享:

    相关文档

    相关产品