Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- C:\Users\george.profenza\Downloads\gp\depthai-experiments\gen2-syncing\host-multiple-OAK-sync.py
- +++ C:\Users\george.profenza\Downloads\gp\OpenCVSpatialAI\dai\sync-depth.py
- @@ -18,13 +18,8 @@
- 'left' : dai.CameraBoardSocket.LEFT,
- 'right': dai.CameraBoardSocket.RIGHT,
- }
- -cam_instance = {
- - 'rgb' : 0,
- - 'left' : 1,
- - 'right': 2,
- -}
- -def create_pipeline(cam_list):
- +def create_pipeline(cam_list, id):
- # Start defining a pipeline
- pipeline = dai.Pipeline()
- cam = {}
- @@ -37,12 +32,43 @@
- cam[c].setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
- cam[c].setIspScale(1, 3) # 1920x1080 -> 1280x720
- cam[c].isp.link(xout[c].input)
- - else:
- + elif c == 'left' or c == 'right':
- cam[c] = pipeline.create(dai.node.MonoCamera)
- cam[c].setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P)
- cam[c].out.link(xout[c].input)
- + else:
- + print('disparity has no hardware links to setup')
- + continue
- cam[c].setBoardSocket(cam_socket_opts[c])
- cam[c].setFps(args.fps)
- + # depth setup
- + print('setting up depth for id', id)
- + # Configure stereo pair for depth estimation
- + stereo = pipeline.createStereoDepth()
- + # Checks occluded pixels and marks them as invalid
- + stereo.setLeftRightCheck(True)
- +
- + # Configure left and right cameras to work as a stereo pair
- + cam['left'].out.link(stereo.left)
- + cam['right'].out.link(stereo.right)
- +
- + # Set XlinkOut for disparity, rectifiedLeft, and rectifiedRight
- + xoutDisp = pipeline.createXLinkOut()
- + xoutDisp.setStreamName("disparity")
- +
- + xoutRectifiedLeft = pipeline.createXLinkOut()
- + xoutRectifiedLeft.setStreamName("rectifiedLeft")
- +
- + xoutRectifiedRight = pipeline.createXLinkOut()
- + xoutRectifiedRight.setStreamName("rectifiedRight")
- +
- + stereo.disparity.link(xoutDisp.input)
- +
- + stereo.rectifiedLeft.link(xoutRectifiedLeft.input)
- + stereo.rectifiedRight.link(xoutRectifiedRight.input)
- +
- + print('depth for id', id, 'ready')
- +
- return pipeline
- @@ -62,10 +88,11 @@
- device = stack.enter_context(dai.Device(openvino_version, device_info, usb2_mode))
- stereo = 1 < len(device.getConnectedCameras())
- - cam_list = {'rgb', 'left', 'right'} if stereo else {'rgb'}
- + cam_list = {'rgb', 'left', 'right', 'disparity'} if stereo else {'rgb'}
- # Get a customized pipeline based on identified device type
- - device.startPipeline(create_pipeline(cam_list))
- + device.startPipeline(create_pipeline(cam_list, device.getMxId()))
- + # device.startPipeline(getDepthPipeline())
- # Output queue will be used to get the rgb frames from the output defined above
- for cam in cam_list:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement