Jetson Nano Count bounding box for each class

I’m currently doing a video detection using jetson.inference of Jetson Nano to count the total number tray and book seperately. I know how to get total number for both, but not seperate. And I would like to display it anywhere in the video.

Appreciate your help :) p/s:*I’m really new to this area.

I just need to count like this: tray: 5 book: 2

Below is my current script:

while display.IsOpen():
img, width, height = camera.CaptureRGBA()
detections = net.Detect(img, width, height)
display.RenderOnce(img, width, height)
display.SetTitle("Object Detection | Network {:.0f} FPS".format(net.GetNetworkFPS()))

for detection in detections:
    class_name = net.GetClassDesc(detection.ClassID)


You can separate it via checking detection.ClassID.

The class ID indicates which class the bbox belongs to.
With this information, you can add the bbox number accordingly.



Thank you for the reply.
Yes, I tried use print it and it will be 1 for trolley and 0 for book.

But how do I calculate the trolley detected at instance? For example under the lens, 4 trolleys detected, and I want it to display or inform user 4. Put into some kind of variable is good enough.

I’m really new to this. Hopping someone could provide few lines script for that.

Appreciate it :)


For example:

num_trolley = 0
for detection in detections:
    if detection.ClassID==1: num_trolley += 1
print("Detect %d trolley"%(num_trolley))


Thanks for the reply! Works well!
Is there any way to display the number detected at the camera screen itself? Not at terminal

Hi @Hqm996 - sure, you can use jetson.utils.cudaFont to overlay the number onto the image the way that does:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.