No is not working with normal mode. The synchronised frames never get into the script node. Yes my camera has emmc storage. It is the OAK-D POE model. Please help me structure the code properly for getting the synchroised frames into the script node.
Below is my updated script:
import depthai as dai
import os
import struct
from datetime import timedelta
# Create the pipeline
pipeline = dai.Pipeline()
# Board configuration to enable EMMC
board = dai.BoardConfig()board.emmc = True
pipeline.setBoardConfig(board)
fps = 20
# I/O configuration
cam_rgb = pipeline.create(dai.node.ColorCamera)
cam_rgb.setBoardSocket(dai.CameraBoardSocket.CAM_A)
cam_rgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
cam_rgb.setIspScale(1, 3, 10, 27)
cam_rgb.setFps(fps)cam_rgb.initialControl.setSharpness(1)
cam_rgb.initialControl.setAutoExposureLimit(6000)
cam_rgb.initialControl.setAutoExposureCompensation(2)
cam_rgb.initialControl.setAutoFocusMode(dai.RawCameraControl.AutoFocusMode.AUTO)
monoLeft = pipeline.create(dai.node.MonoCamera)
monoRight = pipeline.create(dai.node.MonoCamera)
stereo = pipeline.create(dai.node.StereoDepth)
# Properties
monoLeft.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P)
monoLeft.setBoardSocket(dai.CameraBoardSocket.CAM_B)
monoRight.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P)
monoRight.setBoardSocket(dai.CameraBoardSocket.CAM_C)
stereo.initialConfig.setMedianFilter(dai.MedianFilter.KERNEL_5x5)
monoLeft.setFps(fps)monoRight.setFps(fps)
# Stereo Depth Configuration
stereo.setDepthAlign(dai.CameraBoardSocket.CAM_A)
# Align depth to RGB
stereo.setOutputSize(640, 400)
stereo.setLeftRightCheck(True)
stereo.setSubpixel(False)
# Configure post-processing
config = stereo.initialConfig.get()
config.postProcessing.spatialFilter.holeFillingRadius = 5
config.postProcessing.spatialFilter.numIterations = 1
config.postProcessing.decimationFilter.decimationFactor = 1
stereo.initialConfig.set(config)
stereo.initialConfig.setConfidenceThreshold(250)
sync = pipeline.create(dai.node.Sync)
sync.setSyncThreshold(timedelta(milliseconds=30))
# Linking
monoLeft.out.link(stereo.left)
monoRight.out.link(stereo.right)
sync.inputs["jpeg"].setBlocking(False)
sync.inputs["jpeg"].setQueueSize(4)
sync.inputs["depth"].setBlocking(False)
sync.inputs["depth"].setQueueSize(4)
jpegEncoder = pipeline.create(dai.node.VideoEncoder)
jpegEncoder.setDefaultProfilePreset(1, dai.VideoEncoderProperties.Profile.MJPEG)
cam_rgb.video.link(jpegEncoder.input)
jpegEncoder.bitstream.link(sync.inputs['jpeg'])
# Script to save RGB and Depth data on EMMC
script_save = pipeline.create(dai.node.Script)
script_save.setProcessor(dai.ProcessorType.LEON_CSS)
sync.out.link(script_save.inputs["jpeg"])
sync.out.link(script_save.inputs["depth"])
stereo.depth.link(script_save.inputs['depth'])
script_save.setScript("""import os
import struct
import time
index = 0
….
while True:
jpg_fname = f'{index}_rgb.jpg'
depthmap_fname = f'{index}_depth.npy'
jpeg_path = os.path.join(ROOT_MEDIA_DIR, next_sess_dir, jpg_fname)
depth_path = os.path.join(ROOT_MEDIA_DIR, next_sess_dir, depthmap_fname)
if not os.path.exists(jpeg_path) and not os.path.exists(depth_path):
try:
jpeg_frame = node.io['jpeg'].get()
….
depth_frame = node.io['depth'].get()
…..
""")
with dai.Device(pipeline) as device:
print("Pipeline running...")
while True:
pass