Multi-Device Synchronization Example
Demonstrates multi-device synchronization. This sample supports network devices, USB devices, and GMSL devices.
- The primary purpose of this repository is to demonstrate the multi-device synchronization functionality of different types of Orbbec devices, including detailed instructions for hardware connections and software configuration.
- The v2-main branch is based on the multi device sync sample and gmsl trigger sample provided by Orbbec SDK v2. If there are any updates or changes to the samples in Orbbec SDK v2, please refer to the official implementation in Orbbec SDK v2 as the authoritative version.
- The legacy main branch is based on Orbbec SDK v1 and only demonstrates multi-device synchronization for Femto Mega.
Supported Device Series
Program Overview
This project builds two standalone executables:
| Program |
Connection |
Platform |
Function |
| MultiDeviceSync |
USB / Ethernet /GMSL |
Windows / Linux x64 / Linux ARM64 |
Multi-device sync configuration, data stream acquisition, real-time preview |
| MultiDeviceSyncGmslTrigger |
GMSL |
Linux ARM64 (NVIDIA Jetson AGX Orin, NVIDIA Jetson Orin NX) |
GMSL PWM hardware trigger signal source |
- Notes: GMSL devices require two applications: MultiDeviceSync and MultiDeviceSyncGmslTrigger. The MultiDeviceSyncGmslTrigger application is responsible for sending trigger signals, while USB and Ethernet devices only require the MultiDeviceSync application.
Quick Start
1. Build
cd Multi-Device-Synchronization-Example
mkdir build && cd build
cmake ..
cmake --build . --config Release
Build artifacts are in the build/bin/ directory:
- Windows:
MultiDeviceSync.exe
- Linux:
MultiDeviceSync, MultiDeviceSyncGmslTrigger
2. Configuration
The program reads ./MultiDeviceSyncConfig.json from the current working directory by default. Device serial numbers can be found using the OrbbecViewer tool or in the program log after connecting devices.
Configuration File Structure
The following example includes all optional fields; use as needed based on your device series:
{
"devices": [
{
"sn": "CP123456789",
"syncConfig": {
"syncMode": "OB_MULTI_DEVICE_SYNC_MODE_PRIMARY",
"depthDelayUs": 0,
"colorDelayUs": 0,
"trigger2ImageDelayUs": 0,
"triggerOutEnable": true,
"triggerOutDelayUs": 0,
"framesPerTrigger": 1
},
"streamConfig": {
"depth": {
"width": 640,
"height": 480,
"fps": 30,
"format": "OB_FORMAT_Y16"
},
"color": {
"width": 640,
"height": 480,
"fps": 30,
"format": "OB_FORMAT_MJPG"
}
}
}
]
}
Field descriptions:
| Field |
Type |
Required |
Description |
sn |
string |
Yes |
Device serial number, used to match connected devices |
syncConfig.syncMode |
string |
Yes |
Sync mode, see table below for available values |
syncConfig.depthDelayUs |
int |
Yes |
IR/Depth/ToF trigger signal input delay (microseconds). Default 0; see the series-specific sync documentation for recommended per-device delay values |
syncConfig.colorDelayUs |
int |
Yes |
RGB trigger signal input delay (microseconds), typically 0 |
syncConfig.trigger2ImageDelayUs |
int |
Yes |
Delay from trigger signal input to image capture (microseconds), typically 0 |
syncConfig.triggerOutEnable |
bool |
Yes |
Device trigger signal output enable switch. With a star hub: enable on the primary device only. With a daisy-chain hub: enable on the primary and all secondary devices. Forcibly set to true in PRIMARY mode |
syncConfig.triggerOutDelayUs |
int |
Yes |
Device trigger signal output delay (microseconds), typically 0 |
syncConfig.framesPerTrigger |
int |
Yes |
Number of frames captured per trigger, only effective in software and hardware trigger modes |
streamConfig |
object |
No |
Stream profile overrides; omit the whole section to use the SDK default profile |
streamConfig.depth / streamConfig.color |
object |
No |
Per-sensor profile request. Each field is optional: width, height, fps (0 = not specified), format (empty = not specified, e.g. "OB_FORMAT_Y16", "OB_FORMAT_MJPG"). Unspecified fields match any value; stream start fails if the device has no matching profile |
Note: All devices must be configured with the same frame rate for each stream type. Multi-device frame grouping and pairing rely on a consistent frame interval; mixing frame rates across devices will lead to inaccurate synchronization and analysis results.
syncMode available values:
| Mode |
Description |
OB_MULTI_DEVICE_SYNC_MODE_PRIMARY |
Primary mode, outputs sync trigger signal |
OB_MULTI_DEVICE_SYNC_MODE_SECONDARY |
Secondary mode, receives trigger signal |
OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING |
Software trigger mode, PC controls capture timing |
OB_MULTI_DEVICE_SYNC_MODE_HARDWARE_TRIGGERING |
Hardware trigger mode, triggered by external hardware signal |
OB_MULTI_DEVICE_SYNC_MODE_SECONDARY_SYNCED |
Secondary synced variant, starts capturing immediately, auto-aligns when trigger signal is received |
3. Run MultiDeviceSync
./MultiDeviceSync
- Enter
0: Configure device sync mode and start streaming
- Enter
1: Start streaming directly (use when devices are already configured)
Keyboard shortcuts:
| Key |
Function |
S |
Sync device clocks |
T |
Software trigger capture |
ESC |
Stop streaming and exit |
Headless Mode
Run without the OpenCV preview window, suitable for remote sessions (SSH) or headless servers:
./MultiDeviceSync --headless
- Timestamp recording and sync monitor output run exactly as in normal mode
- No preview window is created
- Press
Ctrl+C to stop: the program catches SIGINT, flushes all CSV data, and shuts down streams before exiting
4. Run MultiDeviceSyncGmslTrigger
For GMSL2 connections to NVIDIA Jetson platforms. Devices can be configured as HARDWARE_TRIGGERING or SECONDARY_SYNCED mode.
sudo ./MultiDeviceSyncGmslTrigger
Run with sudo (root permission is required to open /dev/camsync).
Enter 0: Set trigger frequency (FPS)
Enter 1: Start PWM trigger signal
Enter 2: Stop PWM trigger signal
Enter 3: Exit
Recommended startup order (applicable only to HARDWARE_TRIGGERING and SECONDARY_SYNCED modes): Start the streams first, then enable the trigger signal. Run MultiDeviceSync first (enter 0 to configure the sync mode and start streaming), followed by MultiDeviceSyncGmslTrigger to activate the PWM signal. Devices in other sync modes do not rely on external triggering and are unaffected by the PWM signal.
5. Timestamp CSV Output
During streaming, each device and each sensor (depth/color) records its own timestamp CSV file under ./output/:
output/
sync_depth_dev0_<SN>.csv
sync_color_dev0_<SN>.csv
sync_depth_dev1_<SN>.csv
sync_color_dev1_<SN>.csv
...
Each file contains one row per captured frame:
| Field |
Description |
row_id |
Sequential row index |
sw_frame_num |
Software frame number from the SDK |
hw_frame_num |
Hardware frame number; -1 when the device does not support it |
system_ts_us |
Host system timestamp (microseconds) |
device_ts_us |
Device-side timestamp (microseconds) |
global_ts_us |
Global timestamp on the host clock domain (microseconds); 0 when unsupported |
Note: Some devices do not provide a global timestamp (global_ts_us is all 0) or a hardware frame number (hw_frame_num is -1). This is normal and expected.
6. Sync Accuracy Analysis (Python)
A standalone Python script evaluates synchronization accuracy from the recorded CSV files. It performs both multi-device checks (cross-device timestamp alignment) and intra-device checks (depth-color pairing offset and frame-drop detection):
- Script:
scripts/analyze_sync.py
- No third-party dependencies (Python standard library only)
Run it from the directory containing the CSV files (typically output/):
cd build/bin/output
python analyze_sync.py
Or analyze any folder:
python analyze_sync.py /path/to/csv_dir [options]
Options:
| Option |
Default |
Description |
[csv_dir] |
current directory |
Directory with the sync_*.csv files |
--fps |
auto |
Frame rate used to compute the grouping tolerance (half-frame interval); auto-detects from the median frame interval, falls back to 30 when there is too little data |
--threshold |
5000 |
In-group timestamp range (us) above which a matched group is flagged abnormal |