Hi,
We're running the following pipeline on a OAK-D-S2-PoE. The camera is part of a robot that moves at max 16 cm/s on an uneven surface. It is hanging about 70 cms above the ground looking straight down. Our problem is that we often get blurry images. Not motion blur, but unsharp images. Sometimes even when the robot is standing still and no vibrations either. The camera seems to have trouble focusing.
pipeline = Pipeline()
pipeline.setCameraTuningBlobPath('path/to/tuning_exp_limit_500us.bin')
color = pipeline.createColorCamera()
color.setBoardSocket(CameraBoardSocket.RGB)
color.setFps(5.0)
color.setResolution(ColorCameraProperties.SensorResolution.THE_4_K)
color.setVideoSize(2144, 2144)
color.setInterleaved(False)
color.initialControl.setSharpness(0)
color.initialControl.setLumaDenoise(0)
color.initialControl.setChromaDenoise(1)
color.initialControl.setAutoFocusLensRange(0, 255)
color_width, color_height = color.getResolutionSize()
color_auto_focus_region = self.__compute_auto_focus_region(color_width, color_height, 0.1, 0.6)
color.initialControl.setAutoFocusRegion(*color_auto_focus_region)
left = pipeline.createMonoCamera()
left.setBoardSocket(CameraBoardSocket.LEFT)
left.setFps(10.0)
left.setResolution(MonoCameraProperties.SensorResolution.THE_400_P)
right = pipeline.createMonoCamera()
right.setBoardSocket(CameraBoardSocket.RIGHT)
right.setFps(10.0)
right.setResolution(MonoCameraProperties.SensorResolution.THE_400_P)
depth = pipeline.createStereoDepth()
depth.setLeftRightCheck(True)
depth.initialConfig.setConfidenceThreshold(180)
depth.initialConfig.setMedianFilter(StereoDepthProperties.MedianFilter.MEDIAN_OFF)
depth.initialConfig.setSubpixel(True)
depth.initialConfig.setBilateralFilterSigma(0)
depth.initialConfig.setSubpixelFractionalBits(5)
depth.initialConfig.setDisparityShift(30)
depth.initialConfig.setDepthUnit(RawStereoDepthConfig.AlgorithmControl.DepthUnit.CUSTOM)
depth_config = depth.initialConfig.get()
depth_config.algorithmControl.customDepthUnitMultiplier = 50000
depth.initialConfig.set(depth_config)
depth.enableDistortionCorrection(True)
# other nodes in the pipeline that should not be relevant
# camera parameters in this code snippet are hardcoded for readability
with
def __compute_auto_focus_region(self, width: int, height: int, relative_region_width: float, relative_region_height: float) -> Tuple[int, int, int, int]:
region_width = int(width * relative_region_width)
region_height = int(height * relative_region_height)
region_width_offset = (width - region_width) // 2
region_height_offset = (height - region_height) // 2
return region_width_offset, region_height_offset, region_width, region_height
Especially the middle part of the view (from top to bottom) should be in focus, so the auto focus region is a vertical strip in the middle of the view. But the camera doesn't focus properly without setting this region either.
We also tried restricting the auto focus range with color.initialControl.setAutoFocusLensRange(120, 160)
, but that didn't work so well either. Could you give us a clue why the camera is not focussing as it should? Thanks in advance.