Hi there,
I need to get both color and depth streams, aligned and in sync, with medium resolution and a good fps. I'm running the same code, with depthai 2.28.0.0, with different cameras and getting inconsistent outcomes. The main problem is the drop of fps - understood as the time to get both frames. Specifically, I have three issues:
1. For different cameras, same setting (i.e. literally same computer and same cable), I get frames with a resolution different than the one that was set.
2. The setFPS does not set FPS.
3. For different settings, the FPS drops from like 300 to 1, with literally the same code and the same camera (same object, not version), but different computer/cables.
I am always using depthai 2.28 and cables cat 6 A. I tested the network, checked the devices, updated firmware and tested different scripts from github depthai-experiments; including bandwidth and latency tests as per https://github.com/luxonis/depthai-experiments/tree/master/random-scripts.
Partial code:
#################################################################
# CREATE nodes
monoLeft = pipeline.create(dai.node.MonoCamera)
monoRight = pipeline.create(dai.node.MonoCamera)
stereo = pipeline.create(dai.node.StereoDepth)
rgb = pipeline.create(dai.node.Camera)
sync = pipeline.create(dai.node.Sync)
xoutGrp = pipeline.create(dai.node.XLinkOut)
xoutGrp.setStreamName("xout")
# set Properties RGB
rgbCamSocket = dai.CameraBoardSocket.CAM_A
rgb.setBoardSocket(rgbCamSocket)
rgb.setSize(1280, 720)
rgb.setFps(FPS)
# set Properties LEFT
monoLeft.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P)
monoLeft.setCamera("left") #monoLeft.setBoardSocket(dai.CameraBoardSocket.CAM_B)
monoLeft.setFps(FPS)
# set Properties RIGHT
monoRight.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P)
monoRight.setCamera("right") #monoRight.setBoardSocket(dai.CameraBoardSocket.CAM_C)
monoRight.setFps(FPS)
# set Properties STEREO
stereo.setDepthAlign(rgbCamSocket)
stereo.initialConfig.setConfidenceThreshold(confidenceThreshold)
stereo.setLeftRightCheck(lr_check)
stereo.setSubpixel(subpixel)
stereo.setExtendedDisparity(extended_disparity)
stereo.initialConfig.setMedianFilter(dai.StereoDepthProperties.MedianFilter.KERNEL_7x7) # to reduce noise and smoothen the depth map
# set Properties SYNC
sync.setSyncThreshold(timedelta(milliseconds=100))
# Linking
monoLeft.out.link(stereo.left)
monoRight.out.link(stereo.right)
stereo.depth.link(sync.inputs["depth"])
rgb.video.link(sync.inputs["rgb"])
sync.out.link(xoutGrp.input)
if alpha is not None:
stereo.setAlphaScaling(alpha)
rgb.setCalibrationAlpha(alpha)
#####################################################
with dai.Device(pipeline) as device:
qSync = device.getOutputQueue(name="xout", maxSize=10, blocking=True)
while True:
s_time=time.time()
msgGrp = qSync.get()
for name, msg in msgGrp:
frame = msg.getCvFrame()
if name == "depth":
depth_frame = frame
depth_clock = msg.getTimestamp()
depth_bits = depth_frame.nbytes*8
depth_shape = depth_frame.shape
if name == "rgb":
rgb_frame = frame
rgb_clock = msg.getTimestamp()
rgb_bits = rgb_frame.nbytes*8
rgb_shape = rgb_frame.shape
print("Delta depth-rgb {} ms".format( (depth_clock - rgb_clock).total_seconds()*1000))
print("Bits depth {} and Bits rgb {}".format(depth_bits, rgb_bits))
print("Shape depth {} and Bits rgb {}".format(depth_shape, rgb_shape))
print("***fps sync : ",1/(time.time()-s_time))
#################################################################
Outcomes:
######################### Outcome 1 #########################
OAK-D PoE AF
Available camera sensors: {<CameraBoardSocket.CAM_B: 1>: 'OV9282', <CameraBoardSocket.CAM_A: 0>: 'IMX378', <CameraBoardSocket.CAM_C: 2>: 'OV9282'}Product name: OAK-D PoE AF, board name DM2088IMU type: BNO086
firmware version: 3.9.9, embedded firmware version: 3.9.9
USB speed: UsbSpeed.UNKNOWN
Delta depth-rgb 0.546 ms
Bits depth 33177600 and Bits rgb 49766400
Shape depth (1080, 1920) and rgb (1080, 1920, 3)
fps sync : 227.5679019044002
######################### Outcome 2 #########################
OAK-D-W-POE-97
Available camera sensors: {<CameraBoardSocket.CAM_B: 1>: 'OV9282', <CameraBoardSocket.CAM_A: 0>: 'OV9782', <CameraBoardSocket.CAM_C: 2>: 'OV9282'}Product name: OAK-D-W-POE-97, board name NG9097IMU type: BNO086,
firmware version: 3.9.9, embedded firmware version: 3.9.9
USB speed: UsbSpeed.UNKNOWN
Delta depth-rgb 95.834 ms
Bits depth 14745600 and Bits rgb 22118400
Shape depth (720, 1280) and rgb (720, 1280, 3)
fps sync : 269.03810134701735
######################## Outcome 3 #########################
OAK-D-PRO-W-POE
Available camera sensors: {<CameraBoardSocket.CAM_B: 1>: 'OV9282', <CameraBoardSocket.CAM_A: 0>: 'OV9782', <CameraBoardSocket.CAM_C: 2>: 'OV9282'}Product name: OAK-D-PRO-W-POE, board name NG9097IMU type: BNO086,
firmware version: 3.9.9, embedded firmware version: 3.9.9
USB speed: UsbSpeed.UNKNOWN
Delta depth-rgb 96.121 ms
Bits depth 14745600 and Bits rgb 22118400
Shape depth (720, 1280) and rgb (720, 1280, 3)
fps sync : 583.7583855254002
######################### Outcome 4 #########################
OAK-D-PRO-W-POE-97
Available camera sensors: {<CameraBoardSocket.CAM_B: 1>: 'OV9282', <CameraBoardSocket.CAM_A: 0>: 'OV9782', <CameraBoardSocket.CAM_C: 2>: 'OV9282'}
Product name: OAK-D-PRO-W-POE-97, board name NG9097IMU type: BNO086,
firmware version: 3.9.9, embedded firmware version: 3.9.9
USB speed: UsbSpeed.UNKNOWN
Delta depth-rgb 45.458999999999996 ms
Bits depth 14745600 and Bits rgb 22118400
Shape depth (720, 1280) and rgb (720, 1280, 3)
fps sync : 3.3333285649685727
######################### Outcome 5 #########################
OAK-D-PRO-W-POE (not the same as Outcome 3)
Available camera sensors: {<CameraBoardSocket.CAM_B: 1>: 'OV9282', <CameraBoardSocket.CAM_A: 0>: 'IMX378', <CameraBoardSocket.CAM_C: 2>: 'OV9282'}Product name: OAK-D-PRO-W-POE, board name NG9097IMU type: BNO086,
firmware version: 3.9.9, embedded firmware version: 3.9.9
USB speed: UsbSpeed.UNKNOWN
Delta depth-rgb 0.856 ms
Bits depth 33177600 and Bits rgb 49766400
Shape depth (1080, 1920) and rgb (1080, 1920, 3)
fps sync : 0.6608250229397115