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)

Hi,

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.

Thanks.

Hello,

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

Hi,

For example:
https://github.com/dusty-nv/jetson-inference/blob/master/python/examples/detectnet.py#L71

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

Thanks.

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 imagenet.py does:

https://github.com/dusty-nv/jetson-inference/blob/88a9b5494b8ee6b884c592d3101d3cd9ff2f7e71/python/examples/imagenet.py#L74

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