Dear support,
device = OAK-D-SR-POE
python version = 3.8
oakd = DepthAI 2.30
I am currently developing a application in which I would like to sense the depth at a range of approximately 210mm-300mm. However at that range, from the left sight their is a spot with very high depth value's (>1500mm). I thought it might have to do with the TOF settings so I played a little bit around with tof_depth.py. There I noticed something strange, if I set phase unwrapping to 0 (which is fine due to the short minimal distance and range), every other image doesn't have this noise. I attached some code in which I adapted the code to only visualise every other frame, and which a keypress of "p" one can switch the displayed image. Why does every image have this artefact when phase unwrapping is turned on, and why is this artefact appering on every other image if phase unwrapping is turned off?


#!/usr/bin/env python3
import timeimport cv2import depthai as daiimport numpy as np
print(dai.__version__)
def mouse_callback(event, x, y, flags, param): if event == cv2.EVENT_MOUSEMOVE: pixel_value = depth_map[y, x] # Get the pixel value at the mouse position print("Pixel value at (x={}, y={}): {}".format(x, y, pixel_value))
cvColorMap = cv2.applyColorMap(np.arange(256, dtype=np.uint8), cv2.COLORMAP_JET)cvColorMap[0] = [0, 0, 0]
def create_pipeline(): pipeline = dai.Pipeline()
tof = pipeline.create(dai.node.ToF)
# Configure the ToF node tofConfig = tof.initialConfig.get()
# Optional. Best accuracy, but adds motion blur. # see ToF node docs on how to reduce/eliminate motion blur. tofConfig.enableOpticalCorrection = True tofConfig.enablePhaseShuffleTemporalFilter = False tofConfig.phaseUnwrappingLevel = 0 tofConfig.phaseUnwrapErrorThreshold = 300
tofConfig.enableTemperatureCorrection = False # Not yet supported
xinTofConfig = pipeline.create(dai.node.XLinkIn) xinTofConfig.setStreamName("tofConfig") xinTofConfig.out.link(tof.inputConfig)
tof.initialConfig.set(tofConfig)
cam_tof = pipeline.create(dai.node.Camera) cam_tof.setFps(60) # ToF node will produce depth frames at /2 of this rate cam_tof.setBoardSocket(dai.CameraBoardSocket.CAM_A) cam_tof.raw.link(tof.input)
xout = pipeline.create(dai.node.XLinkOut) xout.setStreamName("depth") tof.depth.link(xout.input)
tofConfig = tof.initialConfig.get()
return pipeline, tofConfig
if __name__ == '__main__': pipeline, tofConfig = create_pipeline()
with dai.Device(pipeline) as device: print('Connected cameras:', device.getConnectedCameraFeatures()) qDepth = device.getOutputQueue(name="depth")
tofConfigInQueue = device.getInputQueue("tofConfig")
counter = 0 while True: start = time.time() key = cv2.waitKey(1) if key == ord('f'): tofConfig.enableFPPNCorrection = not tofConfig.enableFPPNCorrection tofConfigInQueue.send(tofConfig) elif key == ord('o'): tofConfig.enableOpticalCorrection = not tofConfig.enableOpticalCorrection tofConfigInQueue.send(tofConfig) elif key == ord('w'): tofConfig.enableWiggleCorrection = not tofConfig.enableWiggleCorrection tofConfigInQueue.send(tofConfig) elif key == ord('t'): tofConfig.enableTemperatureCorrection = not tofConfig.enableTemperatureCorrection tofConfigInQueue.send(tofConfig) elif key == ord('q'): break elif key == ord('0'): tofConfig.enablePhaseUnwrapping = False tofConfig.phaseUnwrappingLevel = 0 tofConfigInQueue.send(tofConfig) elif key == ord('1'): tofConfig.enablePhaseUnwrapping = True tofConfig.phaseUnwrappingLevel = 1 tofConfigInQueue.send(tofConfig) elif key == ord('2'): tofConfig.enablePhaseUnwrapping = True tofConfig.phaseUnwrappingLevel = 2 tofConfigInQueue.send(tofConfig) elif key == ord('3'): tofConfig.enablePhaseUnwrapping = True tofConfig.phaseUnwrappingLevel = 3 tofConfigInQueue.send(tofConfig) elif key == ord('4'): tofConfig.enablePhaseUnwrapping = True tofConfig.phaseUnwrappingLevel = 4 tofConfigInQueue.send(tofConfig) elif key == ord('5'): tofConfig.enablePhaseUnwrapping = True tofConfig.phaseUnwrappingLevel = 5 tofConfigInQueue.send(tofConfig) elif key == ord('m'): medianSettings = [dai.MedianFilter.MEDIAN_OFF, dai.MedianFilter.KERNEL_3x3, dai.MedianFilter.KERNEL_5x5, dai.MedianFilter.KERNEL_7x7] currentMedian = tofConfig.median nextMedian = medianSettings[(medianSettings.index(currentMedian) + 1) % len(medianSettings)] print(f"Changing median to {nextMedian.name} from {currentMedian.name}") tofConfig.median = nextMedian tofConfigInQueue.send(tofConfig) elif key == ord('p'): counter+=1
imgFrame = qDepth.get() # blocking call, will wait until a new data has arrived if counter%2: depth_map = imgFrame.getFrame() #max_depth = (tofConfig.phaseUnwrappingLevel + 1) * 1500 # 100MHz modulation freq. max_depth = 350 depth_colorized = np.interp(depth_map, (0, max_depth), (0, 255)).astype(np.uint8) depth_colorized = cv2.applyColorMap(depth_colorized, cvColorMap) cv2.imshow("Colorized depth", depth_colorized) cv2.setMouseCallback("Colorized depth", mouse_callback) counter += 1
device.close()