I like having my screen full of bounding boxes but I need the network to pick only one. What can I modify in the network or in my python software based on detect net to have it identify only one object per class? Thanks for the help.
use for loop
for detect in detections:
xmin = detect.Left
xmax = detect.Right
ymin = detect.Top
ymax = detect.Bottom
class = detect.(?)...
break
1 Like
To expand on what @muhammedsezer12 suggested, here is a simple example that determines when a person is detected:
import jetson.inference
import jetson.utils
net = jetson.inference.detectNet("ssd-mobilenet-v2", threshold=0.5)
camera = jetson.utils.videoSource("/dev/video0")
display = jetson.utils.videoOutput("display://0")
for n in range(net.GetNumClasses()):
if net.GetClassDesc(n) == 'person':
person_class_id = n
while display.IsStreaming():
img = camera.Capture()
detections = net.Detect(img)
for detection in detections:
if detection.ClassID == person_class_id:
print('detected a person!')
display.Render(img)
display.SetStatus("Object Detection | Network {:.0f} FPS".format(net.GetNetworkFPS()))
1 Like