Search code examples
pythonobjecttypesobject-detectiondetection

How to get separate values from type "jetson.inference.detectNet.Detection"?


I use DetectNet on my Jetson Nano which works well. The net.Detect() funcion gives back a list where each object is from type "jetson.inference.detectNet.Detection". When I print it:

<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)

Now my question is: How can I access these values separately (e.g. only the ClassID which, in this case, would be 1)? Lines like detection[0][0] don't work, since it is not an array. I want to count how many objects of each class were detected. Thanks!


Solution

  • once you have the Detection object you can access its members by name, for example:

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

    Hope it helps.