• Spatial coordinates

I need some help getting X, Y,Z Spatial coordinates and print them in the terminal. I did spatial=True in sdk code.

from depthai_sdk import OakCamera, ArgsParser

import argparse

# parse arguments

parser = argparse.ArgumentParser()

parser.add_argument("-conf", "--config", help="Trained YOLO json config path", default='D:/yolo_retail/depthai_compatible/best.json', type=str)

args = ArgsParser.parseArgs(parser)

with OakCamera(args=args) as oak:

color = oak.create_camera('color')

nn = oak.create_nn('D:/yolo_retail/depthai_compatible/best_openvino_2021.4_6shave.blob', color, nn_type='yolo', spatial=True)

nn.config_yolo(2,4,[

            10\.0,

            13\.0,

            16\.0,

            30\.0,

            33\.0,

            23\.0,

            30\.0,

            61\.0,

            62\.0,

            45\.0,

            59\.0,

            119\.0,

            116\.0,

            90\.0,

            156\.0,

            198\.0,

            373\.0,

            326\.0

        ], {

            "side52": [

                0,

                1,

                2

            ],

            "side26": [

                3,

                4,

                5

            ],

            "side13": [

                6,

                7,

                8

            ]

        }, 0.5, 0.5)

oak.visualize(nn, fps=True)

oak.visualize(nn.out.passthrough, fps=True)

oak.start(blocking=True)
  • erik replied to this.

    Gillani at oak.visualize(nn, fps=True) add callback=my_cb_function, then print xyz;

    from depthai_sdk.classes import DetectionPacket
    
    def cb(packet: DetectionPacket):
        for det in packet.img_detections.detections:
            det.spatialCoordinates.x, det.spatialCoordinates.y, det.spatialCoordinates.z
    
    oak.visualize(nn, fps=True, callback=cb)