jakaskerl
Getting the following error:
for detection in packet.spatials.detections:
^^^^^^^^^^^^^^^
AttributeError: 'DisparityDepthPacket' object has no attribute 'spatials'
import depthai as dai
from depthai_sdk import OakCamera
from depthai_sdk.classes import SpatialBbMappingPacket
with OakCamera() as oak:
left = oak.create_camera("left")
right = oak.create_camera("right")
stereo = oak.create_stereo(left=left, right=right, fps=30)
stereo.set_auto_ir(auto_mode=False, continuous_mode=False)
stereo.set_ir(dot_projector_brightness=200, flood_brightness=1000)
nn = oak.create_nn('yolov8n_coco_640x352', left, spatial=stereo)
#def packets for printing data
def cb(packet: SpatialBbMappingPacket):
for detection in packet.spatial.detection:
print(detection.spatialCoordinates.x, detection.spatialCoordinates.y, detection.spatialCoordinates.z)
nn.config_spatial(
bb_scale_factor=0.5, # Scaling bounding box before averaging the depth in that ROI
lower_threshold=300, # Discard depth points below 30cm
upper_threshold=10000, # Discard depth pints above 10m
#Average depth points before calculating X and Y spatial coordinates:
calc_algo=dai.SpatialLocationCalculatorAlgorithm.AVERAGE
)
oak.visualize([nn.out.main, stereo.out.depth], fps=True, callback = cb)
oak.callback(nn.out.main, callback=cb)
#oak.show_graph()
oak.start(blocking=True)