首页 > 解决方案 > 如何从“jetson.inference.detectNet.Detection”类型中获取单独的值?

问题描述

我在我的 Jetson Nano 上使用 DetectNet,效果很好。该net.Detect()函数返回一个列表,其中每个对象都来自“jetson.inference.detectNet.Detection”类型。当我打印它时:

<detectNet.Detection object>
   -- ClassID: 1
   -- Confidence: 0.808974
   -- Left:    416.31
   -- Top:     218.694
   -- Right:   593.188
   -- Bottom:  703.127
   -- Width:   176.878
   -- Height:  484.433
   -- Area:    85685.7
   -- Center:  (504.749, 460.91)

现在我的问题是:我怎样才能分别访问这些值(例如,在这种情况下,只有 ClassID 为 1)?像 detection[0][0] 这样的行不起作用,因为它不是数组。我想计算检测到每个类的对象数量。谢谢!

标签: pythonobjecttypesobject-detectiondetection

解决方案


拥有检测对象后,您可以按名称访问其成员,例如:

top = detection.Top # with capital letters, just as they are shown by the print() statement.

希望能帮助到你。


推荐阅读