jakaskerl
I will keep changing some of the configuration settings to see what gives me the best results. I just changed the settings to what you recommended. However it just slight changes. Here is the 1st half of the code that I am working with. As the remaining half doesn't change.
The lines that are grayscale are lines that I have changed to give me the best results. This is the most progress that I have so far while working with the camera. My remaining goal is to simply have the above screesnshot to be more clearer. As my manager is wanting to use this tool to display a part or material. From there the target is to view the part without having to move the camera and it(part or material).
import random
import time
from sys import maxsize
import cv2
import depthai as dai
import open3d as o3d
COLOR = True
lrcheck = True # Better handling for occlusions
extended = True # Closer-in minimum depth, disparity range is doubled
subpixel = True # Better accuracy for longer distance, fractional disparity 32-levels
# Options: MEDIAN_OFF, KERNEL_3x3, KERNEL_5x5, KERNEL_7x7
median = dai.StereoDepthProperties.MedianFilter.KERNEL_7x7
print("StereoDepth config options:")
print(" Left-Right check: ", lrcheck)
print(" Extended disparity:", extended)
print(" Subpixel: ", subpixel)
print(" Median filtering: ", median)
pipeline = dai.Pipeline()
colorLeft = pipeline.create(dai.node.ColorCamera)
colorLeft.setPreviewSize(1280,720) #288,288
colorLeft.setResolution(dai.ColorCameraProperties.SensorResolution.THE_720_P)
colorLeft.setBoardSocket(dai.CameraBoardSocket.CAM_B)
colorLeft.setInterleaved(False)
colorLeft.setColorOrder(dai.ColorCameraProperties.ColorOrder.RGB)
#colorLeft.setIspScale(1, 2)
colorRight = pipeline.create(dai.node.ColorCamera)
colorRight.setPreviewSize(1280,720) #288,288 -- 640,480 -- 1280,720
colorRight.setBoardSocket(dai.CameraBoardSocket.CAM_C)
colorRight.setResolution(dai.ColorCameraProperties.SensorResolution.THE_720_P)
colorRight.setInterleaved(False)
colorRight.setColorOrder(dai.ColorCameraProperties.ColorOrder.RGB)
#colorRight.setIspScale(1, 2)
print(f'left Isp size = {colorLeft.getIspSize()}')
print(f'left resolution = {colorLeft.getResolutionSize()}')
print(f'left preview size = {colorLeft.getPreviewSize()}')
print(f'left still size = {colorLeft.getStillSize()}')
print(f'left video size = {colorLeft.getVideoSize()}')
print('===============================================')
print(f'right Isp size = {colorRight.getIspSize()}')
print(f'right resolution = {colorRight.getResolutionSize()}')
print(f'right preview size = {colorRight.getPreviewSize()}')
print(f'Right still size = {colorLeft.getStillSize()}')
print(f'right video size = {colorRight.getVideoSize()}')
print("\n\n")
stereo = pipeline.createStereoDepth()
stereo.setDefaultProfilePreset(dai.node.StereoDepth.PresetMode.HIGH_DENSITY)
# stereo.setDefaultProfilePreset(dai.node.StereoDepth.PresetMode.HIGH_ACCURACY)
stereo.initialConfig.setMedianFilter(median)
#stereo.setOutputSize(288, 288)
stereo.initialConfig.setConfidenceThreshold(200)
stereo.setLeftRightCheck(lrcheck)
stereo.setExtendedDisparity(extended)
stereo.setSubpixel(subpixel)
colorLeft.preview.link(stereo.left)
colorRight.preview.link(stereo.right)
config = stereo.initialConfig.get()
##########################################################
config.postProcessing.speckleFilter.enable = True
#set line 295 to false
config.postProcessing.speckleFilter.speckleRange = 50
config.postProcessing.temporalFilter.enable = True
config.postProcessing.spatialFilter.enable = True
# set line 298 to true
config.postProcessing.spatialFilter.holeFillingRadius = 2
config.postProcessing.spatialFilter.numIterations = 1
config.postProcessing.thresholdFilter.maxRange = 2000
config.postProcessing.decimationFilter.decimationFactor = 1