简介
本文档提供关于创建视频目标检测模板的相关 API 概览以及 SDK 示例代码。
API | 操作描述 |
更新一个视频目标检测模板。 |
更新模板
腾讯云数据万象通过 UpdateVideoTargetRecTemplate 接口更新一个视频目标检测模板。
方法原型
func (s *CIService) UpdateVideoTargetRecTemplate(ctx context.Context, opt *CreateVideoTargetRecTemplateOptions, templateId string) (*CreateMediaTemplateResult, *Response, error)
请求示例
// 将 examplebucket-1250000000 和 COS_REGION 修改为真实的信息u, _ := url.Parse("https://examplebucket-1250000000.cos.COS_REGION.myqcloud.com")cu, _ := url.Parse("https://examplebucket-1250000000.ci.COS_REGION.myqcloud.com")b := &cos.BaseURL{BucketURL: u, CIURL: cu}c := cos.NewClient(b, &http.Client{Transport: &cos.AuthorizationTransport{SecretID: os.Getenv("SECRETID"),SecretKey: os.Getenv("SECRETKEY"),},})opt := &cos.CreateVideoTargetRecTemplateOptions{Tag: "VideoTargetRec",Name: "VideoTargetRec-test",VideoTargetRec: &cos.VideoTargetRec{Body: "false",Pet: "false",Car: "false",Face: "false",Plate: "true",ProcessType: "Mosaic",TransTpl: &cos.VTRTranscode{Container: &cos.Container{Format: "mp4",},Video: &cos.VTRVideo{Codec: "h.264",Width: "1280",Fps: "30",},},},}templateId := "t1234567890abcdef1234567890abcdef1"resp, _, err := c.CI.UpdateVideoTargetRecTemplate(context.Background(), opt, templateId)log_status(err)fmt.Printf("%+v\\n", resp.Template)
参数说明
type CreateVideoTargetRecTemplateOptions struct {XMLName xml.Name `xml:"Request"`Tag string `xml:"Tag,omitempty"`Name string `xml:"Name,omitempty"`VideoTargetRec *VideoTargetRec `xml:"VideoTargetRec,omitempty" json:"VideoTargetRec,omitempty"`}type VideoTargetRec struct {Body string `xml:"Body,omitempty"`Pet string `xml:"Pet,omitempty"`Car string `xml:"Car,omitempty"`Face string `xml:"Face,omitempty"`Plate string `xml:"Plate,omitempty"`ProcessType string `xml:"ProcessType,omitempty"`TransTpl *VTRTranscode `xml:"TransTpl,omitempty"`}type VTRTranscode struct {Container *Container `xml:"Container,omitempty"`Video *VTRVideo `xml:"Video,omitempty"`}type Container struct {Format string `xml:"Format,omitempty"`ClipConfig *ClipConfig `xml:"ClipConfig,omitempty"`}type ClipConfig struct {Duration string `xml:"Duration"`}type VTRVideo struct {Codec string `xml:"Codec"`Bitrate string `xml:"Bitrate,omitempty"`Crf string `xml:"Crf,omitempty"`Width string `xml:"Width,omitempty"`Height string `xml:"Height,omitempty"`Fps string `xml:"Fps,omitempty"`}
具体的数据描述如下:
Container 类型 CreateVideoTargetRecTemplateOptions 的具体数据描述如下:
参数名称 | 描述 | 类型 | 是否必选 |
Tag | 模板类型:VideoTargetRec | String | 是 |
Name | 模板名称 仅支持中文、英文、数字、 _ 、- 和* | String | 是 |
VideoTargetRec | 视频目标检测参数 | Container | 是 |
Container 类型 VideoTargetRec 的具体数据描述如下:
参数名称 | 描述 | 类型 | 是否必选 |
Body | 是否开启人体检测 | string | 否 |
Pet | 是否开启宠物检测 | string | 否 |
Car | 是否开启车辆检测 | string | 否 |
Plate | 是否开启人脸检测 | string | 否 |
Face | 是否开启车牌检测 | string | 否 |
ProcessType | 后处理类型,该参数不为空则标识开启检测后处理,支持马赛克类型,只有 Face、Plate 两种检测支持检测后处理 | string | 否 |
TransTpl | 识别后处理参数,当 ProcessType 不为空时生效且必填 | Container | 否 |
注意:
Body、Pet、Car、Face、Plate 不能同时为 false。
开启检测后处理即 ProcessType 不为空时,Body、Pet、Car 不能为 true。
Container 类型 TransTpl 的具体数据描述如下:
参数名称 | 描述 | 类型 | 是否必选 |
Container | 封装格式 | Container | 是 |
Video | 视频参数 | Container | 否 |
Container 类型 Container 的具体数据描述如下:
参数名称 | 描述 | 类型 | 是否必选 |
Format | 封装格式:支持 mp4,flv,mkv,hls,ts,avi,mov | String | 是 |
ClipConfig | 分片配置,当 format 为 hls 时有效 | Container | 否 |
Container 类型 ClipConfig 的具体数据描述如下:
参数名称 | 描述 | 类型 | 是否必选 |
Duration | 分片时长,默认5s | String | 否 |
Container 类型 Video 的具体数据描述如下:
参数名称 | 描述 | 类型 | 是否必选 |
Codec | 编解码格式 | string | 否 |
Bitrate | 视频码率 | string | 否 |
Crf | 码率,质量控制因子 | string | 否 |
Width | 宽 | string | 否 |
Height | 高 | string | 否 |
Fps | 帧率 | string | 否 |
返回结果说明
type CreateMediaTemplateResult struct {XMLName xml.Name `xml:"Response"`RequestId string `xml:"RequestId,omitempty"`Template *Template `xml:"Template,omitempty"`}type Template struct {TemplateId string `xml:"TemplateId,omitempty"`Tag string `xml:"Code,omitempty"`Name string `xml:"Name,omitempty"`TransTpl *Transcode `xml:"TransTpl,omitempty"`CreateTime string `xml:"CreateTime,omitempty"`UpdateTime string `xml:"UpdateTime,omitempty"`BucketId string `xml:"BucketId,omitempty"`Category string `xml:"Category,omitempty"`VideoTargetRec *VideoTargetRec `xml:"VideoTargetRec,omitempty" json:"VideoTargetRec,omitempty"`}
具体的数据描述如下:
Container 类型 CreateMediaTemplateResult 的具体数据描述如下:
节点名称(关键字) | 描述 | 类型 |
RequestId | 请求的唯一 ID | String |
Template | 保存模板详情的容器 | Container |
Container 类型 Template 的具体数据描述如下:
节点名称(关键字) | 描述 | 类型 |
TemplateId | 模板 ID | String |
Name | 模板名称 | String |
BucketId | 模板所属存储桶 | String |
Category | 模板属性,Custom 或者 Official | String |
Tag | 模板类型,VideoTargetRec | String |
UpdateTime | 更新时间 | String |
CreateTime | 创建时间 | String |
VideoTargetRec | 同请求体中的 VideoTargetRec | Container |