简介
本文档提供关于提交视频目标检测任务的相关 API 概览以及 SDK 示例代码。
API | 操作描述 |
提交一个视频目标检测任务。 |
提交任务
腾讯云数据万象通过 CreateJob 接口创建一个视频目标检测任务。
方法原型
func (s *CIService) CreateJob(ctx context.Context, opt *CreateJobsOptions) (*CreateJobsResult, *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.CreateJobsOptions{Tag: "VideoTargetRec",Input: &cos.JobInput{Object: "input/test.mp4",},Operation: &cos.MediaProcessJobOperation{VideoTargetRec: &cos.VideoTargetRec{Body: "false",Pet: "false",Car: "false",Face: "true",Plate: "true",ProcessType: "Mosaic",TransTpl: &cos.VTRTranscode{Container: &cos.Container{Format: "mp4",},Video: &cos.VTRVideo{Codec: "h.264",Width: "1280",Fps: "30",},},},Output: &cos.JobOutput{Region: "ap-beijing",Bucket: "test-1234567890",Object: "output/out.mp4",},UserData: "This is my VideoTargetRec job",JobLevel: 1,},}resp, _, err := c.CI.CreateJob(context.Background(), opt)log_status(err)fmt.Printf("%+v\\n", resp.JobsDetail)
参数说明
type CreateJobsOptions CreateMediaJobsOptionstype CreateMediaJobsOptions struct {XMLName xml.Name `xml:"Request"`Tag string `xml:"Tag,omitempty"`Input *JobInput `xml:"Input,omitempty"`Operation *MediaProcessJobOperation `xml:"Operation,omitempty"`QueueId string `xml:"QueueId,omitempty"`QueueType string `xml:"QueueType,omitempty"`CallBackFormat string `xml:"CallBackFormat,omitempty"`CallBackType string `xml:"CallBackType,omitempty"`CallBack string `xml:"CallBack,omitempty"`CallBackMqConfig *NotifyConfigCallBackMqConfig `xml:"CallBackMqConfig,omitempty"`}type JobInput struct {Object string `xml:"Object,omitempty"`}type MediaProcessJobOperation struct {TemplateId string `xml:"TemplateId,omitempty"`VideoTargetRec *VideoTargetRec `xml:"VideoTargetRec,omitempty"`UserData string `xml:"UserData,omitempty"`Output *JobOutput `xml:"Output,omitempty"`JobLevel int `xml:"JobLevel,omitempty"`SnapshotPrefix string `xml:"SnapshotPrefix,omitempty"`}type NotifyConfigCallBackMqConfig struct {MqMode string `xml:"MqMode,omitempty"`MqRegion string `xml:"MqRegion,omitempty"`MqName string `xml:"MqName,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 ClipConfig struct {Duration string `xml:"Duration"`}type Container struct {Format string `xml:"Format,omitempty"`ClipConfig *ClipConfig `xml:"ClipConfig,omitempty"`}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"`}type JobOutput struct {Region string `xml:"Region,omitempty"`Bucket string `xml:"Bucket,omitempty"`Object string `xml:"Object,omitempty"`}
具体的数据描述如下:
Container 类型 CreateMediaJobsOptions 的具体数据描述如下:
参数名称 | 描述 | 类型 | 是否必选 |
Tag | 创建任务的 Tag:VideoTargetRec | String | 是 |
Input | 待操作的媒体信息 | Container | 是 |
Operation | 操作规则 | Container | 是 |
QueueId | String | 否 | |
QueueType | 队列类型 | String | 否 |
CallBackFormat | 任务回调格式,JSON 或 XML,默认 XML,优先级高于队列的回调格式 | String | 否 |
CallBackType | 任务回调类型,Url 或 TDMQ,默认 Url,优先级高于队列的回调类型 | String | 否 |
CallBack | 任务回调地址,优先级高于队列的回调地址。设置为 no 时,表示队列的回调地址不产生回调 | String | 否 |
CallBackMqConfig | Container | 否 |
Container 类型 Input 的具体数据描述如下:
参数名称 | 描述 | 类型 | 是否必选 |
Object | 媒体文件名 | String | 是 |
Container 类型 Operation 的具体数据描述如下:
参数名称 | 描述 | 类型 | 是否必选 |
TemplateId | 视频目标检测模板 ID | String | 否 |
VideoTargetRec | Container | 否 | |
UserData | 透传用户信息, 可打印的 ASCII 码, 长度不超过1024 | String | 否 |
Output | 结果输出配置,当设置了后置处理时必填 | Container | 否 |
JobLevel | 任务优先级,级别限制:0 、1 、2 。级别越大任务优先级越高,默认为0 | String | 否 |
SnapshotPrefix | 截图输出前缀。配置后,截图输出到用户桶,路径为 "SnapshotPrefix/<jobId>/<随机的截图名>" ,会额外产生费用。为空时不保存截图 | String | 否 |
Container 类型 Output 的具体数据描述如下:
参数名称 | 描述 | 类型 | 是否必选 |
Region | 存储桶的地域 | String | 否 |
Bucket | 存储结果的存储桶 | String | 否 |
Object | 输出结果的文件名 | String | 否 |
返回结果说明
type CreateMediaJobsResult struct {XMLName xml.Name `xml:"Response"`JobsDetail *MediaProcessJobDetail `xml:"JobsDetail,omitempty"`}type MediaProcessJobDetail struct {Code string `xml:"Code,omitempty"`Message string `xml:"Message,omitempty"`JobId string `xml:"JobId,omitempty"`Tag string `xml:"Tag,omitempty"`Progress string `xml:"Progress,omitempty"`State string `xml:"State,omitempty"`CreationTime string `xml:"CreationTime,omitempty"`StartTime string `xml:"StartTime,omitempty"`EndTime string `xml:"EndTime,omitempty"`QueueId string `xml:"QueueId,omitempty"`Input *JobInput `xml:"Input,omitempty"`Operation *MediaProcessJobOperation `xml:"Operation,omitempty"`}
具体的数据描述如下:
Container 类型 CreateMediaJobsResult 的具体数据描述如下:
节点名称(关键字) | 描述 | 类型 |
JobsDetail | 任务的详细信息 | Container |
Container 类型 JobsDetail 的具体数据描述如下:
节点名称(关键字) | 描述 | 类型 |
Code | 错误码,只有 State 为 Failed 时有意义 | String |
Message | 错误描述,只有 State 为 Failed 时有意义 | String |
JobId | 新创建任务的 ID | String |
Tag | 新创建任务的 Tag:FileCompress | String |
Progress | 任务进度 | String |
State | 任务的状态,为 Submitted、Running、Success、Failed、Pause、Cancel 其中一个 | String |
CreationTime | 任务的创建时间 | String |
StartTime | 任务的开始时间 | String |
EndTime | 任务的结束时间 | String |
QueueId | String | |
Input | 同请求中的 Input 节点 | Container |
Operation | 该任务的规则 | Container |
Container 类型 Operation 的具体数据描述如下:
节点名称(关键字) | 描述 | 类型 |
TemplateId | 任务的模板 ID | String |
TemplateName | 任务的模板名称,当 TemplateId 存在时返回 | String |
VideoTargetRec | 同请求中的 Request.Operation.VideoTargetRec | Container |
VideoTargetRecResult | 视频目标检测结果 | Container |
UserData | 透传用户信息 | String |
JobLevel | 任务优先级 | String |
Container 类型 VideoTargetRecResult 的具体数据描述如下:
节点名称(关键字) | 描述 | 类型 |
Sensitive | 脱敏标记,如输入视频中被检测的每一帧都不出现用户所选的检测的模型信息,则此字段值为 false,大于等于一帧出现检测的模型信息时,此字段都为 true,sensitive 为 false 时不返回后处理视频 | String |
BodyRecognition | 人体识别结果 | Container 数组 |
PetRecognition | 宠物识别结果 | Container 数组 |
CarRecognition | 车辆识别结果 | Container 数组 |
FaceRecognition | 人脸识别结果 | Container 数组 |
LicenseRecognitionResult | 车牌识别结果 | Container 数组 |
Container 类型 BodyRecognitionResult 的具体数据描述如下:
节点名称(关键字) | 描述 | 类型 |
FusionScore | 混合置信度,取值范围 [0,100] | String |
ResultDetails | 识别结果 | Container 数组 |
Container 类型 ResultDetails 的具体数据描述如下:
节点名称(关键字) | 描述 | 类型 |
Time | 截图的时间点,单位为秒 | String |
Url | 截图 URL | String |
ResultInfo | 识别结果,可能有多个 | Container 数组 |
Container 类型 ResultInfo 的具体数据描述如下:
节点名称(关键字) | 描述 | 类型 |
Name | 识别类型 | String |
Score | 识别的置信度,取值范围为 [0-100]。值越高概率越大。 | Int |
Location | 图中识别到的坐标 | Container |
Container 类型 Location 的具体数据描述如下:
节点名称(关键字) | 描述 | 类型 |
X | X 坐标 | String |
Y | Y 坐标 | String |
Height | (X,Y)坐标距离高度 | String |
Width | (X,Y)坐标距离长度 | String |
Container 类型节点 PetRecognitionResult 、CarRecognitionResult 、FaceRecognitionResult、 LicenseRecognitionResult 节点的内容与 BodyRecognitionResult 节点相同。
查询任务结果
功能说明
查询一个视频目标检测任务,根据任务 ID 查询任务详情。
方法原型
func (s *CIService) DescribeJob(ctx context.Context, jobid string) (*DescribeJobsResult, *Response, error)
请求示例
jobid := "<jobid>"res, _, err := c.CI.DescribeJob(context.Background(), jobid)
参数说明
参数名称 | 描述 | 类型 | 是否必选 |
jobid | ship 任务 ID | String | 是 |
返回结果说明
type CreateMediaJobsResult struct {XMLName xml.Name `xml:"Response"`JobsDetail *MediaProcessJobDetail `xml:"JobsDetail,omitempty"`}type MediaProcessJobDetail struct {Code string `xml:"Code,omitempty"`Message string `xml:"Message,omitempty"`JobId string `xml:"JobId,omitempty"`Tag string `xml:"Tag,omitempty"`Progress string `xml:"Progress,omitempty"`State string `xml:"State,omitempty"`CreationTime string `xml:"CreationTime,omitempty"`StartTime string `xml:"StartTime,omitempty"`EndTime string `xml:"EndTime,omitempty"`QueueId string `xml:"QueueId,omitempty"`Input *JobInput `xml:"Input,omitempty"`Operation *MediaProcessJobOperation `xml:"Operation,omitempty"`}
返回结果具体的数据描述同创建任务返回结果。