jakaskerl
Hi Jaka,
The measured values are wrong. The real distance in Z is like 0.5 m, the displayed distance is the distance to the ground (matches the measurement with the location of the measurement in the image). What happens when you perform the setDepthAlign? Can we expect pixel-to-pixel correlation between RGB and Depth after matching the resolutions of both images? If so, something is definitely not working properly.
Some additional information, I'm handling everything within a class that stores all the device configurations, maybe there is something wrong with my setup:
def __init__(self, rgb_res:depthai.ColorCameraProperties.SensorResolution = depthai.ColorCameraProperties.SensorResolution.THE_12_MP, rgb_preview_res: Resolution = Resolution(1280,720), depth_res: depthai.MonoCameraProperties.SensorResolution = depthai.MonoCameraProperties.SensorResolution.THE_400_P, stereoProfile:depthai.node.StereoDepth.PresetMode = depthai.node.StereoDepth.PresetMode.HIGH_ACCURACY, use_alignment: bool = False, calibrate: bool = True):
self.pipeline = depthai.Pipeline()
self.cam_rgb = self.pipeline.create(depthai.node.ColorCamera)
self.monoLeft = self.pipeline.create(depthai.node.MonoCamera)
self.monoRight = self.pipeline.create(depthai.node.MonoCamera)
self.stereo = self.pipeline.create(depthai.node.StereoDepth)
self.spatialLocationCalculator = self.pipeline.create(depthai.node.SpatialLocationCalculator)
self.prepareRGBPipeline(rgb_res, rgb_preview_res)
self.prepareSpatialLocationCalculator(depth_res, stereoProfile)
if use_alignment: self.prepareAlignment()
self.device = depthai.Device(self.pipeline)
self.RGBQueue = self.device.getOutputQueue("rgb", maxSize=1, blocking=False) # set the max size to stop processing old images
self.depthQueue = self.device.getOutputQueue(name="depth", maxSize=1, blocking=False) # set the max size to stop processing old images
self.spatialCalcQueue = self.device.getOutputQueue(name="spatialData", maxSize=1, blocking=False)
self.spatialCalcConfigInQueue = self.device.getInputQueue("spatialCalcConfig")
self.device.setIrLaserDotProjectorBrightness(750) # in mA, 0..1200 - over 750 saturates (Docs)
self.device.setIrFloodLightBrightness(0)
if calibrate: self.calibrateRGB()
def prepareRGBPipeline(self, res: depthai.ColorCameraProperties.SensorResolution, preview_res: Resolution):
self.cam_rgb.setResolution(res)
self.cam_rgb.setPreviewSize(preview_res.width, preview_res.height)
self.cam_rgb.setInterleaved(False)
self.xout_rgb = self.pipeline.create(depthai.node.XLinkOut)
self.xout_rgb.setStreamName("rgb")
self.cam_rgb.preview.link(self.xout_rgb.input)
return True
def prepareAlignment(self):
self.stereo.setDepthAlign(depthai.CameraBoardSocket.RGB)
return True
def prepareSpatialLocationCalculator(self, monoRes:depthai.MonoCameraProperties.SensorResolution = depthai.MonoCameraProperties.SensorResolution.THE_400_P, stereoProfile:depthai.node.StereoDepth.PresetMode = depthai.node.StereoDepth.PresetMode.HIGH_ACCURACY):
# Define sources and outputs
self.xOutDepth = self.pipeline.create(depthai.node.XLinkOut)
self.xoutSpatialData = self.pipeline.create(depthai.node.XLinkOut)
self.xinSpatialCalcConfig = self.pipeline.create(depthai.node.XLinkIn)
self.xOutDepth.setStreamName("depth")
self.xoutSpatialData.setStreamName("spatialData")
self.xinSpatialCalcConfig.setStreamName("spatialCalcConfig")
# Properties
self.monoLeft.setResolution(monoRes)
self.monoLeft.setCamera("left")
self.monoRight.setResolution(monoRes)
self.monoRight.setCamera("right")
self.stereo.setDefaultProfilePreset(stereoProfile)
self.stereo.setLeftRightCheck(True)
self.stereo.setSubpixel(True)
# Config
self.initROIConfig()
# Linking
self.monoLeft.out.link(self.stereo.left)
self.monoRight.out.link(self.stereo.right)
self.spatialLocationCalculator.passthroughDepth.link(self.xOutDepth.input)
self.stereo.depth.link(self.spatialLocationCalculator.inputDepth)
self.spatialLocationCalculator.out.link(self.xoutSpatialData.input)
self.xinSpatialCalcConfig.out.link(self.spatialLocationCalculator.inputConfig)
return True
Thank you for your time.