Holistic Replay
This example demonstrates how to replay previously recorded holistic data, feeding multiple synchronized streams such as video and IMU back into a DepthAI pipeline for testing and development.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
6
7parser = argparse.ArgumentParser()
8parser.add_argument("-s", "--source", default="recordings/recording.tar", help="Recording path")
9args = parser.parse_args()
10
11# Create pipeline
12with dai.Pipeline(True) as pipeline:
13 # Define source and output
14 camRgb = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_A)
15 camRgbOut = camRgb.requestOutput((1920, 1080), fps = 30)
16
17 imu = pipeline.create(dai.node.IMU)
18 imu.enableIMUSensor(dai.IMUSensor.ACCELEROMETER_RAW, 500);
19 imu.enableIMUSensor(dai.IMUSensor.GYROSCOPE_RAW, 400);
20 imu.setBatchReportThreshold(100)
21
22 pipeline.enableHolisticReplay(args.source)
23
24 videoQueue = camRgbOut.createOutputQueue()
25 imuQueue = imu.out.createOutputQueue()
26
27 # Connect to device and start pipeline
28 pipeline.start()
29 while pipeline.isRunning():
30 videoIn : dai.ImgFrame = videoQueue.get()
31 imuData : dai.IMUData = imuQueue.get()
32
33 # Get BGR frame from NV12 encoded video frame to show with opencv
34 # Visualizing the frame on slower hosts might have overhead
35 cv2.imshow("video", videoIn.getCvFrame())
36
37 for packet in imuData.packets:
38 print(f"IMU Accelerometer: {packet.acceleroMeter}")
39 print(f"IMU Gyroscope: {packet.gyroscope}")
40
41 if cv2.waitKey(1) == ord('q'):
42 break
Need assistance?
Head over to Discussion Forum for technical support or any other questions you might have.