So it seems to be working!
But now I am having trouble wrapping my head around how to print out the data now. I would like it to be in the format of something like:
Tracking ID: X-depth value, Y-depth value, Z-depth value
But I am having trouble wrapping my head around how to do this in the callback function. The original code in the SDK example is the following:
def cb(packet: TwoStagePacket):
detections = packet.img_detections.detections
vis = packet.visualizer
# Update the tracker
object_tracks = tracker.iter(detections, packet.nnData, (640, 640))
for track in object_tracks:
if not track.is_confirmed() or \
track.time_since_update > 1 or \
track.detection_id >= len(detections) or \
track.detection_id < 0:
continue
det = packet.detections[track.detection_id]
vis.add_text(f'ID: {track.track_id}', bbox=(*det.top_left, *det.bottom_right), position=TextPosition.MID)
frame = vis.draw(packet.frame)
cv2.imshow('DeepSort tracker', frame)
I was thinking that I should be able to print the spatial data by having something like this in the for loop:
print(packet.spatials.detections[track.detection_id].x)
but I am getting the error:
File "C:...\OakD\depthai-experiments\gen2-deepsort-tracking\jae_deepsort_spatial_mono.py", line 26, in cb
print(packet.spatials.detections[track.detection_id].x)
^^^^^^^^^^^^^^^
AttributeError: 'TwoStagePacket' object has no attribute 'spatials'
I am sort of at a loss here again....