Holistic Record
This example demonstrates how to record all selected input streams (such as video and IMU data) holistically during a DepthAI pipeline run, enabling full replay for development and testing.Setup
This example requires the DepthAI v3 API, see installation instructions.Pipeline
Source code
Python
C++
Python
PythonGitHub
1#!/usr/bin/env python3
2
3import cv2
4import depthai as dai
5import argparse
6from pathlib import Path
7
8parser = argparse.ArgumentParser()
9parser.add_argument("-o", "--output", default="recordings", help="Output path")
10args = parser.parse_args()
11
12# Create output directory if it doesn't exist
13Path(args.output).mkdir(parents=True, exist_ok=True)
14
15# Create pipeline
16with dai.Pipeline(True) as pipeline:
17 # Define source and output
18 camA = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_A)
19 camAOut = camA.requestOutput((600, 400))
20 camB = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B)
21 camBOut = camB.requestOutput((600, 400))
22 camC = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C)
23 camCOut = camC.requestOutput((600, 400))
24
25 imu = pipeline.create(dai.node.IMU)
26 imu.enableIMUSensor(dai.IMUSensor.ACCELEROMETER_RAW, 500)
27 imu.enableIMUSensor(dai.IMUSensor.GYROSCOPE_RAW, 400)
28 imu.setBatchReportThreshold(100)
29
30 config = dai.RecordConfig()
31 config.outputDir = args.output
32 config.videoEncoding.enabled = True
33 config.videoEncoding.bitrate = 0 # Automatic
34 config.videoEncoding.profile = dai.VideoEncoderProperties.Profile.H264_MAIN
35
36 pipeline.enableHolisticRecord(config)
37
38 videoQueueA = camAOut.createOutputQueue()
39 videoQueueB = camBOut.createOutputQueue()
40 videoQueueC = camCOut.createOutputQueue()
41 imuQueue = imu.out.createOutputQueue()
42
43 # Connect to device and start pipeline
44 pipeline.start()
45 while pipeline.isRunning():
46 videoInA : dai.ImgFrame = videoQueueA.get()
47 videoInB : dai.ImgFrame = videoQueueB.get()
48 videoInC : dai.ImgFrame = videoQueueC.get()
49 imuData : dai.IMUData = imuQueue.tryGetAll()
50
51 # Get BGR frame from NV12 encoded video frame to show with opencv
52 # Visualizing the frame on slower hosts might have overhead
53 cv2.imshow("video", videoInA.getCvFrame())
54 if imuData:
55 for packet in imuData[0].packets:
56 print(f"IMU Accelerometer: {packet.acceleroMeter}")
57 print(f"IMU Gyroscope: {packet.gyroscope}")
58
59 if cv2.waitKey(1) == ord('q'):
60 break
Need assistance?
Head over to Discussion Forum for technical support or any other questions you might have.