|
| 1 | +from depthai_sdk import OakCamera, RecordType |
| 2 | +import depthai as dai |
| 3 | + |
| 4 | +FPS = 30 |
| 5 | +with OakCamera() as oak: |
| 6 | + color = oak.create_camera('CAM_A', resolution='1080p', encode='mjpeg', fps=FPS) |
| 7 | + color.config_color_camera(isp_scale=(2,3)) # 720P color frames, mjpeg |
| 8 | + |
| 9 | + stereo = oak.create_stereo(resolution='720p', fps=FPS) |
| 10 | + stereo.config_stereo(align=color, subpixel=True, lr_check=True) |
| 11 | + stereo.node.setOutputSize(640, 360) # 720p, downscaled to 640x360 (decimation filter, median filtering) |
| 12 | + # On-device post processing for stereo depth |
| 13 | + config = stereo.node.initialConfig.get() |
| 14 | + stereo.node.setPostProcessingHardwareResources(3, 3) |
| 15 | + config.postProcessing.speckleFilter.enable = True |
| 16 | + config.postProcessing.thresholdFilter.minRange = 400 |
| 17 | + config.postProcessing.thresholdFilter.maxRange = 10_000 # 10m |
| 18 | + config.postProcessing.decimationFilter.decimationFactor = 2 |
| 19 | + config.postProcessing.decimationFilter.decimationMode = dai.StereoDepthConfig.PostProcessing.DecimationFilter.DecimationMode.NON_ZERO_MEDIAN |
| 20 | + stereo.node.initialConfig.set(config) |
| 21 | + """ |
| 22 | + Depth will get encoded on-host with FFV1 codec (it supports 16bit grey), and color will be |
| 23 | + encoded on-device with MJPEG codec. FFV1 works well with .avi container, so depth video will be |
| 24 | + saved as .avi, and color video will be saved as .mp4. |
| 25 | + """ |
| 26 | + record_components = [stereo.out.depth, color.out.encoded] |
| 27 | + oak.record(record_components, './', record_type=RecordType.VIDEO).configure_syncing(True, threshold_ms=500/30) |
| 28 | + oak.start(blocking=True) |
| 29 | + |
| 30 | + |
0 commit comments