0. 背景介绍
本文主要对deepstream提供的Metadata结构进行分析,包括NvDsBatchMeta ,NvDsFrameMeta,NvDsObjectMeta和NvDsClassifierMeta等Metadata结构。
通过对官方文档的阅读,可以得到上述的结构图,描述了每个metadata结构之间的联系以及属性。此外,本文对这些metadata结构的测试是通过在pipeline中element的pad上添加probe回调函数,获取得到nvinfer推理之后的数据信息。
1. NvDsBatchMeta分析
NvDsBatchMeta的含义:
Holds information about a formed batch containing frames from different sources.
这个对象中包含来自不同源数据构建的batched buffers。
上图为NvDsBatchMeta结构中一些重要的属性,具体的含义如下:
Holds the number of frames now in the batch.当前batch buffer的batch size大小
Holds a pointer to a list of pointers of type NvDsFrameMeta or NvDsAudioFrameMeta (when the batch represent audio batch), representing frame metas used in the current batch。当前batch meta数据中包含的frame meta数据指针
Holds a pointer to a list of pointers of type NvDsUserMeta, representing user metas in the current batch. usermeta我暂时还没有学习和用到,但感觉挺重要的
2. NvDsFrameMeta
NvDsFrameMeta的含义如下:
Holds metadata for a frame in a batch.
一个batch中的一帧数据
上图为NvDsFrameMeta结构中一些重要的属性,具体的含义如下:
Holds the location of the frame in the batch.
在这个batch buffer中的第几帧数据
Holds the current frame number of the source.
当前frame meta数据为source id下的第frame_num帧数据
Holds the source IDof the frame in the batch,
batch buffer的数据是来自不同的源,因此对于不同的source会有一个独一无二的ID
Holds the number of object meta elements attached to current frame.
简单来说,就是这一帧数据中,算法检测出了几个物体
Holds a pointer to a list of pointers of type NvDsObjectMeta in use for the frame.
这一帧数据中,被检测出来物体的信息指针
通过下面代码就能从batch meta中获取到frame meta数据
NvDsMetaList * l_frame = NULL;
for (l_frame = batch_meta->frame_meta_list; l_frame != NULL; l_frame = l_frame->next)
{
NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);
// analyze
guint batch_id = frame_meta->batch_id;
...
}
3. NvDsObjectMeta
NvDsObjectMeta的含义如下:
Holds metadata for an object in the frame.
该metadata中包含的是一帧数据中单个object的信息
- class_id
Holds the index of the object class inferred by the primary detector/classifier.
该属性代表一级检测器或者分类器的预测类别index
- object_id
Holds a unique ID for tracking the object
如果一级目标检测后续连接了tracker,表示该框的tracked ID
- confidence
Holds a confidence value for the object, set by the inference component.
目标的分类置信度
- rect_params
Holds a structure containing positional parameters of the object processed by the last component that updates it in the pipeline.
目标框的位置信息以及需要传递给OSD渲染的信息
- obj_label
Holds a string describing the class of the detected object.
目标框的类别字符串
4. NvDsClassifierMeta分析
- num_labels
Holds the number of outputs/labels produced by the classifier.
分类网络的类别数
- unique_component_id
Holds a unique component ID for the classifier metadata.
指的是该分类metadata对应的gie-unique-id
- label_info_list
- Holds a pointer to a list of pointers of type NvDsLabelInfo.
指的是分类目标需要的信息
- NvDsLabelInfo
- result_label:预测目标的类别字符串
- result_class_id:预测目标的index
- result_prob:预测目标的分类置信度