Hi. I'm having an issue with depthai_sdk. I have task to detect objects using yolo, but what I need is only detections and a frame once per 1s. I use code below to print outputs of the yolo. with code as it is, I achieve 15FPS, but with commenting the 14,15 line, the FPS drops to 2 and no detection is provided. Als setting blocking = False on line 25 leads to failure.
Thank you, Jan
def callback(packet: DetectionPacket):
visualizer = packet.visualizer
try:
print()
for inx in range(len(packet.detections)):
print('Detected: ' + packet.detections[inx].label + ' at' + str(packet.detections[inx].centroid()))
print('Spatial: x ' + str(visualizer.objects[0].detections[0].spatialCoordinates.x) + 'mm ,y '
+ str(visualizer.objects[0].detections[inx].spatialCoordinates.y) + 'mm ,z '
+ str(visualizer.objects[0].detections[inx].spatialCoordinates.z) + 'mm.')
print('Confidence: ' + str(visualizer.objects[0].detections[inx].confidence))
print(visualizer.objects[1].text )
except:
pass
frame = visualizer.draw(packet.frame)
cv2.imshow('Visualizer', frame)
with OakCamera(args=args) as oak:
color = oak.create_camera('color')
color.config_color_camera(isp_scale=(1,2))
nn = oak.create_nn(args['config'], color, nn_type='yolo', spatial=True)
for inx in range(len(nn._labels)):
nn._labels[inx] = true_labels[inx]
oak.visualize(nn.out.passthrough, fps=True, callback=callback)
oak.start(blocking=True)