正在使用nvidia深度流推理引擎,无法获取分类器类。它总是显示索引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
有点晚了,但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