0

使用 nvidia deep stream - 推理引擎,无法获得分类器类。它总是显示索引 0。任何帮助表示赞赏。

l_classifier = obj_meta.classifier_meta_list
print('First Classifier at: ', l_classifier)
classifier_cnt = 0
while l_classifier is not None:
classifier_cnt += 1
print('Parsing Classifier at: ', l_classifier)
try:
    classifier_meta = pyds.glist_get_nvds_classifier_meta(
        l_classifier.data)
    print('Classifier Component ID:' + str(classifier_meta.unique_component_id))
    # nxt_classifier = classifier_meta.next
    # print(nxt_classifier)
    # print(dir(classifier_meta))

except Exception as ex:
    print('Could not parse MetaData: ', ex)

l_label = classifier_meta.label_info_list

uid=classifier_meta.unique_component_id
numLabel=classifier_meta.num_labels
classId = classifier_meta.class_id
label_info=pyds.glist_get_nvds_label_info(l_label.data)
classifier_class = label_info.result_class_id
num_classes = label_info.num_classes
label_id = label_info.label_id
result_prob = label_info.result_prob


print("1 l_label         :",l_label)
print("1 u id      ------------  :",uid)
print("1 numLabel        :",numLabel)
print("1 label_info      :",label_info)
print("1 classifier_class:",classifier_class)
print("1 num_classes     :",num_classes)
print("1 label_id        :",label_id)
print("classId ==>", classId)
l_classifier = l_classifier.next
print('Next Classifier: ', l_classifier)

样本输出为

1 l_label         : <pyds.GList object at 0x7fa740cfcf80>
1 u id      ------------  : 4
1 numLabel        : 1
1 label_info      : <pyds.NvDsLabelInfo object at 0x7fa740cfcf48>
1 classifier_class: 0
1 num_classes     : 0
1 label_id        : 0

分类器类始终显示为 0

4

1 回答 1

0

有点太晚了,但 label_info 有分类器数据。你需要转换 l_label 来获取 label_info。然后您需要添加“l_label=l_label.next”,以便它移动到下一个项目。以下链接有可获取的数据。 https://docs.nvidia.com/metropolis/deepstream/python-api/PYTHON_API/NvDsMeta/NvDsLabelInfo.html

           l_label = class_meta.label_info_list

            while l_label is not None:
                try:
                    label_info = pyds.NvDsLabelInfo.cast(l_label.data)
                except StopIteration:
                    break

                print(label_info.label_id)
            
                try:
                    l_label=l_label.next
                except StopIteration:
                    break
            try:
                l_class=l_class.next
            except StopIteration:
                break
于 2021-03-20T09:46:19.037 回答