diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64.zip b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64.zip deleted file mode 100644 index 50abe7b..0000000 Binary files a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64.zip and /dev/null differ diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/build_examples.sh b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/build_examples.sh new file mode 100755 index 0000000..4deb7b8 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/build_examples.sh @@ -0,0 +1,103 @@ +#!/bin/bash + +# Copyright (c) Orbbec Inc. All Rights Reserved. +# Licensed under the MIT License. + +echo "Checking if apt-get is workable ..." +apt_workable=1 +# Check if apt-get is installed +if ! command -v apt-get &> /dev/null +then + echo "apt-get could not be found." + apt_workable=0 +fi + +# check if apt-get is working +if ! command -v sudo apt-get update &> /dev/null +then + echo "apt-get update failed. apt-get may not be working properly." + apt_workable=0 +fi + +if [ $apt_workable -eq 1 ] +then + #install compiler and tools + if ! g++ --version &> /dev/null || ! make --version &> /dev/null + then + echo "C++ Compiler and tools could not be found. It is required to build the examples." + echo "Do you want to install it via install build-essential? (y/n)" + read answer + if [ "$answer" == "y" ] + then + sudo apt-get install -y build-essential + fi + else + echo "C++ Compiler and tools is installed." + fi + + # install cmake + if ! cmake --version &> /dev/null + then + echo "Cmake could not be found. It is required to build the examples." + echo "Do you want to install cmake? (y/n)" + read answer + if [ "$answer" == "y" ] + then + sudo apt-get install -y cmake + fi + else + echo "cmake is installed." + fi + + # install libopencv-dev + if ! dpkg -l | grep libopencv-dev &> /dev/null || ! dpkg -l | grep libopencv &> /dev/null + then + echo "libopencv-dev or libopencv could not be found. Without opencv, part of the examples may not be built successfully." + echo "Do you want to install libopencv-dev and libopencv? (y/n)" + read answer + if [ "$answer" == "y" ] + then + sudo apt-get install -y libopencv + sudo apt-get install -y libopencv-dev + fi + else + echo "libopencv-dev is installed." + fi +else + echo "apt-get is not workable, network connection may be down or the system may not have internet access. Build examples may not be successful." +fi + +# restore current directory +current_dir=$(pwd) + +# cd to the directory where this script is located +cd "$(dirname "$0")" +project_dir=$(pwd) +examples_dir=$project_dir/examples + +#detect cpu core count +cpu_count=$(grep -c ^processor /proc/cpuinfo) +half_cpu_count=$((cpu_count/2)) +if [ $half_cpu_count -eq 0 ] +then + half_cpu_count=1 +fi + +#cmake +echo "Building examples..." +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=Release -DOB_BUILD_LINUX=ON -DCMAKE_INSTALL_PREFIX=$project_dir $examples_dir +echo "Building examples with $half_cpu_count threads..." +cmake --build . -- -j$half_cpu_count # build with thread count equal to half of cpu count +# install the executable files to the project directory +make install + +# clean up +cd $project_dir +rm -rf build + +echo "OrbbecSDK examples built successfully!" +echo "The executable files located in: $project_dir/bin" + +cd $current_dir diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/CMakeLists.txt b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/CMakeLists.txt new file mode 100644 index 0000000..7656b8d --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/CMakeLists.txt @@ -0,0 +1,41 @@ +# Copyright (c) Orbbec Inc. All Rights Reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.5) + +project(orbbec_sdk_exampes) + +set(CMAKE_CXX_STANDARD 11) + +option(OB_BUILD_PCL_EXAMPLES "Build Point Cloud Library examples" OFF) +option(OB_BUILD_OPEN3D_EXAMPLES "Build Open3D examples" OFF) + +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +if(MSVC OR CMAKE_GENERATOR STREQUAL "Xcode") + message(STATUS "Using multi-config generator: ${CMAKE_GENERATOR}") + foreach(OUTPUTCONFIG DEBUG RELEASE RELWITHDEBINFO MINSIZEREL) + string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG_UPPER) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG_UPPER} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG_UPPER} "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG_UPPER} "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}") + endforeach() +endif() + +set(OrbbecSDK_DIR ${CMAKE_CURRENT_LIST_DIR}/../lib) +find_package(OrbbecSDK REQUIRED) + +if(APPLE) + set(CMAKE_MACOSX_RPATH ON) + set(CMAKE_INSTALL_RPATH "@loader_path/../lib") + set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +elseif(UNIX) + set(CMAKE_INSTALL_RPATH ${OrbbecSDK_DIR}) + set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +endif() + +add_subdirectory(src) + diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/0.basic.enumerate/CMakeLists.txt b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/0.basic.enumerate/CMakeLists.txt new file mode 100644 index 0000000..4576bc8 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/0.basic.enumerate/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) Orbbec Inc. All Rights Reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.5) +project(ob_enumerate) + +add_executable(${PROJECT_NAME} enumerate.cpp) + +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} ob::OrbbecSDK ob::examples::utils) + +set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") +if(MSVC) + set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") +endif() + +install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) + diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/0.basic.enumerate/README.md b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/0.basic.enumerate/README.md new file mode 100644 index 0000000..c767df7 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/0.basic.enumerate/README.md @@ -0,0 +1,127 @@ +# C++ Sample: 0.basic.enumerate + +## Overview + +Use the SDK interface to obtain camera-related information, including model, various sensors, and sensor-related configurations. + +### Knowledge + +Context is the environment context, the first object created during initialization, which can be used to perform some settings, including but not limited to device status change callbacks, log level settings, etc. Context can access multiple Devices. + +Device is the device object, which can be used to obtain the device information, such as the model, serial number, and various sensors.One actual hardware device corresponds to one Device object. + +## Code overview + +1. Create a context + + ```cpp + // Create a context. + ob::Context context; + ``` + +2. Check if there is a camera connected + + ```cpp + // Query the list of connected devices. + auto deviceList = context.queryDeviceList(); + if(deviceList->getCount() < 1) { + std::cout << "No device found! Please connect a supported device and retry this program." << std::endl; + return -1; + } + ``` + +3. Obtain and output relevant information of the access device + + ```cpp + std::cout << "enumerated devices: " << std::endl; + + std::shared_ptr device = nullptr; + std::shared_ptr deviceInfo = nullptr; + for(uint32_t index = 0; index < deviceList->getCount(); index++) { + // Get device from deviceList. + device = deviceList->getDevice(index); + // Get device information from device + deviceInfo = device->getDeviceInfo(); + std::cout << " - " << index << ". name: " << deviceInfo->getName() << " pid: " << deviceInfo->getPid() << " SN: " << deviceInfo->getSerialNumber() + << std::endl; + } + ``` + +4. Wait for keyboard input to select device + + ```cpp + // select a device. + int deviceSelected = ob_smpl::getInputOption(); + if(deviceSelected == -1) { + break; + } + ``` + +5. Output device sensors and wait for keyboard input + + ```cpp + // Enumerate sensors. + void enumerateSensors(std::shared_ptr device) { + while(true) { + std::cout << "Sensor list: " << std::endl; + // Get the list of sensors. + auto sensorList = device->getSensorList(); + for(uint32_t index = 0; index < sensorList->getCount(); index++) { + // Get the sensor type. + auto sensorType = sensorList->getSensorType(index); + std::cout << " - " << index << "." + << "sensor type: " << ob::TypeHelper::convertOBSensorTypeToString(sensorType) << std::endl; + } + + std::cout << "Select a sensor to enumerate its streams(input sensor index or \'ESC\' to enumerate device): " << std::endl; + + // Select a sensor. + int sensorSelected = ob_smpl::getInputOption(); + if(sensorSelected == -1) { + break; + } + + // Get sensor from sensorList. + auto sensor = sensorList->getSensor(sensorSelected); + enumerateStreamProfiles(sensor); + } + } + ``` + +6. Output information about the selected sensor + + ```cpp + // Enumerate stream profiles. + void enumerateStreamProfiles(std::shared_ptr sensor) { + // Get the list of stream profiles. + auto streamProfileList = sensor->getStreamProfileList(); + // Get the sensor type. + auto sensorType = sensor->getType(); + for(uint32_t index = 0; index < streamProfileList->getCount(); index++) { + // Get the stream profile. + auto profile = streamProfileList->getProfile(index); + if(sensorType == OB_SENSOR_IR || sensorType == OB_SENSOR_COLOR || sensorType == OB_SENSOR_DEPTH || sensorType == OB_SENSOR_IR_LEFT + || sensorType == OB_SENSOR_IR_RIGHT) { + printStreamProfile(profile, index); + } + else if(sensorType == OB_SENSOR_ACCEL) { + printAccelProfile(profile, index); + } + else if(sensorType == OB_SENSOR_GYRO) { + printGyroProfile(profile, index); + } + else { + break; + } + } + } + ``` + +## Run Sample + +In the window, enter the relevant information of the device sensor you want to view according to the prompts. +Press the Esc key in the window to exit the program. + +### Result + +![image](../../docs/resource/enumerate.jpg) diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/0.basic.enumerate/enumerate.cpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/0.basic.enumerate/enumerate.cpp new file mode 100644 index 0000000..7f336c9 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/0.basic.enumerate/enumerate.cpp @@ -0,0 +1,170 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +#include + +#include "utils.hpp" + +#include +#include + +// get input option +int getInputOption() { + char inputOption = ob_smpl::waitForKeyPressed(); + if(inputOption == ESC_KEY) { + return -1; + } + return inputOption - '0'; +} + +// Print stream profile information. +void printStreamProfile(std::shared_ptr profile, uint32_t index) { + // Get the video profile. + auto videoProfile = profile->as(); + // Get the format. + auto formatName = profile->getFormat(); + // Get the width. + auto width = videoProfile->getWidth(); + // Get the height. + auto height = videoProfile->getHeight(); + // Get the fps. + auto fps = videoProfile->getFps(); + std::cout << index << "." + << "format: " << ob::TypeHelper::convertOBFormatTypeToString(formatName) << ", " + << "res: " << width << "*" << height << ", " + << "fps: " << fps << std::endl; +} + +// Print accel profile information. +void printAccelProfile(std::shared_ptr profile, uint32_t index) { + // Get the profile of accel. + auto accProfile = profile->as(); + // Get the rate of accel. + auto accRate = accProfile->getSampleRate(); + std::cout << index << "." + << "acc rate: " << ob::TypeHelper::convertOBIMUSampleRateTypeToString(accRate) << std::endl; +} + +// Print gyro profile information. +void printGyroProfile(std::shared_ptr profile, uint32_t index) { + // Get the profile of gyro. + auto gyroProfile = profile->as(); + // Get the rate of gyro. + auto gyroRate = gyroProfile->getSampleRate(); + std::cout << index << "." + << "gyro rate: " << ob::TypeHelper::convertOBIMUSampleRateTypeToString(gyroRate) << std::endl; +} + +// Enumerate stream profiles. +void enumerateStreamProfiles(std::shared_ptr sensor) { + // Get the list of stream profiles. + auto streamProfileList = sensor->getStreamProfileList(); + // Get the sensor type. + auto sensorType = sensor->getType(); + for(uint32_t index = 0; index < streamProfileList->getCount(); index++) { + // Get the stream profile. + auto profile = streamProfileList->getProfile(index); + if(sensorType == OB_SENSOR_IR || sensorType == OB_SENSOR_COLOR || sensorType == OB_SENSOR_DEPTH || sensorType == OB_SENSOR_IR_LEFT + || sensorType == OB_SENSOR_IR_RIGHT) { + printStreamProfile(profile, index); + } + else if(sensorType == OB_SENSOR_ACCEL) { + printAccelProfile(profile, index); + } + else if(sensorType == OB_SENSOR_GYRO) { + printGyroProfile(profile, index); + } + else { + break; + } + } +} + +// Enumerate sensors. +void enumerateSensors(std::shared_ptr device) { + while(true) { + std::cout << "Sensor list: " << std::endl; + // Get the list of sensors. + auto sensorList = device->getSensorList(); + for(uint32_t index = 0; index < sensorList->getCount(); index++) { + // Get the sensor type. + auto sensorType = sensorList->getSensorType(index); + std::cout << " - " << index << "." + << "sensor type: " << ob::TypeHelper::convertOBSensorTypeToString(sensorType) << std::endl; + } + + std::cout << "Select a sensor to enumerate its streams(input sensor index or \'ESC\' to enumerate device): " << std::endl; + + // Select a sensor. + int sensorSelected = ob_smpl::getInputOption(); + if(sensorSelected >= static_cast(sensorList->getCount()) || sensorSelected < 0) { + if(sensorSelected == -1) { + break; + } + else { + std::cout << "\nInvalid input, please reselect the sensor!\n"; + continue; + } + } + + // Get sensor from sensorList. + auto sensor = sensorList->getSensor(sensorSelected); + enumerateStreamProfiles(sensor); + } +} + +int main(void) try { + + // Create a context. + ob::Context context; + + while(true) { + // Query the list of connected devices. + auto deviceList = context.queryDeviceList(); + if(deviceList->getCount() < 1) { + std::cout << "No device found! Please connect a supported device and retry this program." << std::endl; + std::cout << "\nPress any key to exit."; + ob_smpl::waitForKeyPressed(); + return -1; + } + + std::cout << "enumerated devices: " << std::endl; + + std::shared_ptr device = nullptr; + std::shared_ptr deviceInfo = nullptr; + for(uint32_t index = 0; index < deviceList->getCount(); index++) { + // Get device from deviceList. + device = deviceList->getDevice(index); + // Get device information from device + deviceInfo = device->getDeviceInfo(); + std::cout << " " << index << "- device name: " << deviceInfo->getName() << ", device pid: 0x" << std::hex << std::setw(4) << std::setfill('0') + << deviceInfo->getPid() << std::dec << " ,device SN: " << deviceInfo->getSerialNumber() << ", connection type:" << deviceInfo->getConnectionType() << std::endl; + } + + std::cout << "Select a device to enumerate its sensors (Input device index or \'ESC\' to exit program):" << std::endl; + + // select a device. + int deviceSelected = ob_smpl::getInputOption(); + if(deviceSelected >= static_cast(deviceList->getCount()) || deviceSelected < 0) { + if(deviceSelected == -1) { + break; + } + else { + std::cout << "\nInvalid input, please reselect the device!\n"; + continue; + } + } + + // Get the device. + auto selectedDevice = deviceList->getDevice(deviceSelected); + enumerateSensors(selectedDevice); + } + + return 0; +} +catch(ob::Error &e) { + std::cerr << "function:" << e.getFunction() << "\nargs:" << e.getArgs() << "\nmessage:" << e.what() << "\ntype:" << e.getExceptionType() << std::endl; + std::cout << "\nPress any key to exit."; + ob_smpl::waitForKeyPressed(); + exit(EXIT_FAILURE); +} diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync/CMakeLists.txt b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync/CMakeLists.txt new file mode 100644 index 0000000..d9b97f9 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) Orbbec Inc. All Rights Reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.5) +project(ob_multi_devices_sync) + +add_executable(${PROJECT_NAME} ob_multi_devices_sync.cpp utils/cJSON.c) + +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} ob::OrbbecSDK ob::examples::utils) + +set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") +if(MSVC) + set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") +endif() + +install(FILES ${CMAKE_CURRENT_LIST_DIR}/MultiDeviceSyncConfig.json DESTINATION bin) +install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync/MultiDeviceSyncConfig.json b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync/MultiDeviceSyncConfig.json new file mode 100644 index 0000000..84e0a3f --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync/MultiDeviceSyncConfig.json @@ -0,0 +1,132 @@ +{ + "version": "1.0.0", + "configTime": "2023/01/01", + "streamProfile": { + "color": { + "width": 1280, + "height": 800, + "format": "YUYV", + "fps": 30 + }, + "depth": { + "width": 1280, + "height": 800, + "format": "Y16", + "fps": 30 + } + }, + "sensorControl": { + "enable": true, + "depthPreset": "Default", + "laserPowerLevel": 6, + "laserOn": true, + "disparitySearchRange": "256", + "hardwareD2d": true, + "hardwareNoiseRemoval": true, + "softwareNoiseRemoval": false, + "colorAutoExposure": true, + "colorExposure": 50, + "colorGain": 16, + "irAutoExposure": false, + "irExposure": 7500, + "irGain": 16 + }, + "devices": [ + { + "sn": "CP4R84P0008J", + "syncConfig": { + "syncMode": "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", + "depthDelayUs": 0, + "colorDelayUs": 0, + "trigger2ImageDelayUs": 0, + "triggerOutEnable": true, + "triggerOutDelayUs": 0, + "framesPerTrigger": 1 + } + }, + { + "sn": "CP4R84P000B5", + "syncConfig": { + "syncMode": "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", + "depthDelayUs": 0, + "colorDelayUs": 0, + "trigger2ImageDelayUs": 0, + "triggerOutEnable": true, + "triggerOutDelayUs": 0, + "framesPerTrigger": 1 + } + }, + { + "sn": "CP4R84P0006H", + "syncConfig": { + "syncMode": "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", + "depthDelayUs": 0, + "colorDelayUs": 0, + "trigger2ImageDelayUs": 0, + "triggerOutEnable": true, + "triggerOutDelayUs": 0, + "framesPerTrigger": 1 + } + }, + { + "sn": "CP4R84P000A3", + "syncConfig": { + "syncMode": "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", + "depthDelayUs": 0, + "colorDelayUs": 0, + "trigger2ImageDelayUs": 0, + "triggerOutEnable": true, + "triggerOutDelayUs": 0, + "framesPerTrigger": 1 + } + }, + { + "sn": "CP4H74D0002K", + "syncConfig": { + "syncMode": "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", + "depthDelayUs": 0, + "colorDelayUs": 0, + "trigger2ImageDelayUs": 0, + "triggerOutEnable": true, + "triggerOutDelayUs": 0, + "framesPerTrigger": 1 + } + }, + { + "sn": "CP4H74D00041", + "syncConfig": { + "syncMode": "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", + "depthDelayUs": 0, + "colorDelayUs": 0, + "trigger2ImageDelayUs": 0, + "triggerOutEnable": true, + "triggerOutDelayUs": 0, + "framesPerTrigger": 1 + } + }, + { + "sn": "CP4H74D0003X", + "syncConfig": { + "syncMode": "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", + "depthDelayUs": 0, + "colorDelayUs": 0, + "trigger2ImageDelayUs": 0, + "triggerOutEnable": true, + "triggerOutDelayUs": 0, + "framesPerTrigger": 1 + } + }, + { + "sn": "CP4R84P0003W", + "syncConfig": { + "syncMode": "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", + "depthDelayUs": 0, + "colorDelayUs": 0, + "trigger2ImageDelayUs": 0, + "triggerOutEnable": true, + "triggerOutDelayUs": 0, + "framesPerTrigger": 1 + } + } + ] +} diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync/ob_multi_devices_sync.cpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync/ob_multi_devices_sync.cpp new file mode 100644 index 0000000..b541e55 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync/ob_multi_devices_sync.cpp @@ -0,0 +1,924 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +#include + +#include "utils.hpp" +#include "utils_opencv.hpp" +#include "utils/cJSON.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX_DEVICE_COUNT 9 +#define CONFIG_FILE "./MultiDeviceSyncConfig.json" +#define KEY_ESC 27 + +static bool quitStreamPreview = false; + +OBFormat textToOBFormat(const char *text) { + if(strcmp(text, "YUYV") == 0) { + return OB_FORMAT_YUYV; + } + else if(strcmp(text, "YUY2") == 0) { + return OB_FORMAT_YUY2; + } + else if(strcmp(text, "UYUV") == 0) { + return OB_FORMAT_UYVY; + } + else if(strcmp(text, "NV12") == 0) { + return OB_FORMAT_NV12; + } + else if(strcmp(text, "NV21") == 0) { + return OB_FORMAT_NV21; + } + else if(strcmp(text, "MJPEG") == 0) { + return OB_FORMAT_MJPEG; + } + else if(strcmp(text, "MJPG") == 0) { + return OB_FORMAT_MJPG; + } + else if(strcmp(text, "H264") == 0) { + return OB_FORMAT_H264; + } + else if(strcmp(text, "H265") == 0) { + return OB_FORMAT_H265; + } + else if(strcmp(text, "Y8") == 0) { + return OB_FORMAT_Y8; + } + else if(strcmp(text, "Y10") == 0) { + return OB_FORMAT_Y10; + } + else if(strcmp(text, "Y12") == 0) { + return OB_FORMAT_Y12; + } + else if(strcmp(text, "Y14") == 0) { + return OB_FORMAT_Y14; + } + else if(strcmp(text, "Y16") == 0) { + return OB_FORMAT_Y16; + } + else if(strcmp(text, "GRAY") == 0) { + return OB_FORMAT_GRAY; + } + else if(strcmp(text, "RLE") == 0) { + return OB_FORMAT_RLE; + } + else if(strcmp(text, "RGB") == 0) { + return OB_FORMAT_RGB; + } + else if(strcmp(text, "RGB888") == 0) { + return OB_FORMAT_RGB888; + } + else if(strcmp(text, "BGR") == 0) { + return OB_FORMAT_BGR; + } + else if(strcmp(text, "BGRA") == 0) { + return OB_FORMAT_BGRA; + } + else if(strcmp(text, "COMPRESSED") == 0) { + return OB_FORMAT_COMPRESSED; + } + else if(strcmp(text, "RVL") == 0) { + return OB_FORMAT_RVL; + } + return OB_FORMAT_UNKNOWN; +} + +typedef struct DeviceConfigInfo_t { + std::string deviceSN; + OBMultiDeviceSyncConfig syncConfig; +} DeviceConfigInfo; + +typedef struct StreamConfigInfo_t { + OBSensorType sensorType; + int width; + int height; + OBFormat format; + int fps; + bool enable; +} StreamConfigInfo; + +typedef struct SensorControlInfo_t { + bool enable; + std::string depthPreset; // Default + int laserPowerLevel; // 0~6 + int disparitySearchRange; // 0:64,1:128,2:256 + bool hardwareD2d; // true: hw d2d, false: sw d2d + bool hardwareNoiseRemoval; // true: hardware noise removal filter enable, false: hardware noise removal filter enable + bool softwareNoiseRemoval; // true: software noise removal filter enable, false: software noise removal filter enable + bool laserOn; + bool colorAutoExposure; + int colorExposure; + int colorGain; + bool irAutoExposure; + int irExposure; + int irGain; +} SensorControlInfo; + +typedef struct PipelineHolder_t { + std::shared_ptr pipeline; + OBSensorType sensorType; + int deviceIndex; + std::string deviceSN; +} PipelineHolder; + +std::ostream &operator<<(std::ostream &os, const PipelineHolder &holder); +std::ostream &operator<<(std::ostream &os, std::shared_ptr holder) { + return os << *holder; +} + +std::mutex frameMutex; +std::map> colorFrames; +std::map> depthFrames; + +std::vector> streamDevList; +std::vector> configDevList; +std::vector> deviceConfigList; +std::vector> streamConfigList; +std::shared_ptr sensorControlInfo = nullptr; + +std::condition_variable waitRebootCompleteCondition; +std::mutex rebootingDevInfoListMutex; +std::vector> rebootingDevInfoList; +std::vector> pipelineHolderList; + +bool loadConfigFile(); +int configMultiDeviceSync(); +int testMultiDeviceSync(); + +void startStream(std::shared_ptr pipelineHolder); +void stopStream(std::shared_ptr pipelineHolder); + +void handleColorStream(uint8_t devIndex, std::shared_ptr frame); +void handleDepthStream(uint8_t devIndex, std::shared_ptr frame); + +std::string OBSyncModeToString(const OBMultiDeviceSyncMode syncMode); +OBMultiDeviceSyncMode stringToOBSyncMode(const std::string &modeString); + +OBFrameType mapFrameType(OBSensorType sensorType); +std::string readFileContent(const char *filePath); + +int strcmp_nocase(const char *str0, const char *str1); +bool checkDevicesWithDeviceConfigs(const std::vector> &deviceList); + +std::shared_ptr createPipelineHolder(std::shared_ptr device, OBSensorType sensorType, int deviceIndex); + +ob::Context context; + +int main(void) try { + int choice; + int exitValue = 0; + constexpr std::streamsize maxInputIgnore = 10000; + + while(true) { + std::cout << "\n--------------------------------------------------\n"; + std::cout << "Please select options: \n"; + std::cout << " 0 --> config devices sync mode. \n"; + std::cout << " 1 --> start stream \n"; + std::cout << "--------------------------------------------------\n"; + std::cout << "Please select input: "; + // std::cin >> choice; + if(!(std::cin >> choice)) { + std::cin.clear(); + std::cin.ignore(maxInputIgnore, '\n'); + std::cout << "Invalid input. Please enter a number [0~1]" << std::endl; + continue; + } + std::cout << std::endl; + + if(!loadConfigFile()) { + std::cout << "load config failed" << std::endl; + return -1; + } + + switch(choice) { + case 0: + exitValue = configMultiDeviceSync(); + if(exitValue == 0) { + std::cout << "Config MultiDeviceSync Success. \n" << std::endl; + + exitValue = testMultiDeviceSync(); + } + break; + case 1: + std::cout << "\nStart Devices video stream." << std::endl; + exitValue = testMultiDeviceSync(); + break; + } + + if(exitValue == 0) { + break; + } + } + return exitValue; +} +catch(ob::Error &e) { + std::cerr << "function:" << e.getFunction() << "\nargs:" << e.getArgs() << "\nmessage:" << e.what() << "\ntype:" << e.getExceptionType() << std::endl; + std::cout << "\nPress any key to exit."; + ob_smpl::waitForKeyPressed(); + exit(EXIT_FAILURE); +} + +bool isValidStreamConfigInfo(const StreamConfigInfo &configInfo) { + return configInfo.width > 0 && configInfo.height > 0 && configInfo.fps > 0 && configInfo.format != OB_FORMAT_UNKNOWN; +} +bool isValidStreamConfigInfo(std::shared_ptr configInfo) { + return configInfo && isValidStreamConfigInfo(*configInfo); +} +int configMultiDeviceSync() { + try { + + if(deviceConfigList.empty()) { + std::cout << "DeviceConfigList is empty. please check config file: " << CONFIG_FILE << std::endl; + return -1; + } + + if(streamConfigList.empty()) { + std::cout << "streamConfigList is empty. please check config file (streamProfile): " << CONFIG_FILE << std::endl; + return -1; + } + + if(sensorControlInfo == nullptr) { + std::cout << "streamConfigList is empty. please check config file (sensorControl): " << CONFIG_FILE << std::endl; + return -1; + } + + // Query the list of connected devices + auto devList = context.queryDeviceList(); + int devCount = devList->deviceCount(); + for(int i = 0; i < devCount; i++) { + std::shared_ptr device = devList->getDevice(i); + configDevList.push_back(devList->getDevice(i)); + } + + if(configDevList.empty()) { + std::cerr << "Device list is empty. please check device connection state" << std::endl; + return -1; + } + + // write configuration to device + for(auto config: deviceConfigList) { + auto findItr = std::find_if(configDevList.begin(), configDevList.end(), [config](std::shared_ptr device) { + auto serialNumber = device->getDeviceInfo()->serialNumber(); + return strcmp_nocase(serialNumber, config->deviceSN.c_str()) == 0; + }); + if(findItr != configDevList.end()) { + auto device = (*findItr); + auto curConfig = device->getMultiDeviceSyncConfig(); + // Update the configuration items of the configuration file, and keep the original configuration for other items + curConfig.syncMode = config->syncConfig.syncMode; + curConfig.depthDelayUs = config->syncConfig.depthDelayUs; + curConfig.colorDelayUs = config->syncConfig.colorDelayUs; + curConfig.trigger2ImageDelayUs = config->syncConfig.trigger2ImageDelayUs; + curConfig.triggerOutEnable = config->syncConfig.triggerOutEnable; + curConfig.triggerOutDelayUs = config->syncConfig.triggerOutDelayUs; + curConfig.framesPerTrigger = config->syncConfig.framesPerTrigger; + std::cout << "-Config Device syncMode:" << curConfig.syncMode << ", syncModeStr:" << OBSyncModeToString(curConfig.syncMode) << std::endl; + device->setMultiDeviceSyncConfig(curConfig); + } + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + } + return 0; + } + catch(ob::Error &e) { + std::cerr << "configMultiDeviceSync failed! \n"; + std::cerr << "function:" << e.getName() << "\nargs:" << e.getArgs() << "\nmessage:" << e.getMessage() << "\ntype:" << e.getExceptionType() << std::endl; + return -1; + } +} + +void startDeviceStreams(const std::vector> &devices, int startIndex) { + std::vector sensorTypes = { OB_SENSOR_DEPTH, OB_SENSOR_COLOR }; + for(auto &dev: devices) { + if(sensorControlInfo->enable) { + // set param + try { + dev->loadPreset(sensorControlInfo->depthPreset.c_str()); + dev->setIntProperty(OB_PROP_LASER_POWER_LEVEL_CONTROL_INT, sensorControlInfo->laserPowerLevel); + dev->setIntProperty(OB_PROP_DISP_SEARCH_RANGE_MODE_INT, sensorControlInfo->disparitySearchRange); + // true: hardware d2d, false: software d2d + dev->setBoolProperty(OB_PROP_DISPARITY_TO_DEPTH_BOOL, sensorControlInfo->hardwareD2d); + dev->setBoolProperty(OB_PROP_LASER_CONTROL_INT, sensorControlInfo->laserOn); + dev->setBoolProperty(OB_PROP_COLOR_AUTO_EXPOSURE_BOOL, sensorControlInfo->colorAutoExposure); + if(!sensorControlInfo->colorAutoExposure) { + dev->setIntProperty(OB_PROP_COLOR_EXPOSURE_INT, sensorControlInfo->colorExposure); + dev->setIntProperty(OB_PROP_COLOR_GAIN_INT, sensorControlInfo->colorGain); + } + dev->setBoolProperty(OB_PROP_IR_AUTO_EXPOSURE_BOOL, sensorControlInfo->irAutoExposure); + if(!sensorControlInfo->irAutoExposure) { + dev->setIntProperty(OB_PROP_IR_EXPOSURE_INT, sensorControlInfo->irExposure); + dev->setIntProperty(OB_PROP_IR_GAIN_INT, sensorControlInfo->irGain); + } + + dev->setBoolProperty(OB_PROP_HW_NOISE_REMOVE_FILTER_ENABLE_BOOL, sensorControlInfo->hardwareNoiseRemoval); + dev->setBoolProperty(OB_PROP_DEPTH_NOISE_REMOVAL_FILTER_BOOL, sensorControlInfo->softwareNoiseRemoval); + /* + //start print param + auto hwD2D = dev->getBoolProperty(OB_PROP_DISPARITY_TO_DEPTH_BOOL); + auto colorAE = dev->getBoolProperty(OB_PROP_COLOR_AUTO_EXPOSURE_BOOL); + auto colorExp = dev->getIntProperty(OB_PROP_COLOR_EXPOSURE_INT); + auto colorGain = dev->getIntProperty(OB_PROP_COLOR_GAIN_INT); + + auto depthAE = dev->getBoolProperty(OB_PROP_IR_AUTO_EXPOSURE_BOOL); + auto depthExp = dev->getIntProperty(OB_PROP_IR_EXPOSURE_INT); + auto depthGain = dev->getIntProperty(OB_PROP_IR_GAIN_INT); + + auto laserPowerLevel = dev->getIntProperty(OB_PROP_LASER_POWER_LEVEL_CONTROL_INT); + auto dispSearchRange = dev->getIntProperty(OB_PROP_DISP_SEARCH_RANGE_MODE_INT); + auto hwNoiseRemoval = dev->getBoolProperty(OB_PROP_HW_NOISE_REMOVE_FILTER_ENABLE_BOOL); + auto swNoiseRemoval = dev->getBoolProperty(OB_PROP_DEPTH_NOISE_REMOVAL_FILTER_BOOL); + std::cout << "hwD2D: " << hwD2D << " colorAE: " << colorAE << " colorExp: " << colorExp << " colorGain: " << colorGain << " depthAE: " << depthAE << " depthExp: " << depthExp << "depthGain: " << depthGain << std::endl; + std::cout << "laserPowerLevel: " << laserPowerLevel << " dispSearchRange: " << dispSearchRange << " hwNoiseRemoval: " << hwNoiseRemoval << " swNoiseRemoval: " << swNoiseRemoval << std::endl; + //end print param + */ + } + catch(ob::Error &e) { + std::cerr << "set camera param failed! \n"; + std::cerr << "function:" << e.getName() << "\nargs:" << e.getArgs() << "\nmessage:" << e.getMessage() << "\ntype:" << e.getExceptionType() + << std::endl; + } + } + + for(auto sensorType: sensorTypes) { + auto holder = createPipelineHolder(dev, sensorType, startIndex); + pipelineHolderList.push_back(holder); + startStream(holder); + } + + startIndex++; + } + quitStreamPreview = false; +} + +// key press event processing +void handleKeyPress(ob_smpl::CVWindow &win, int key) { + // Get the key value + if(key == KEY_ESC) { + if(!quitStreamPreview) { + win.setShowInfo(false); + win.setShowSyncTimeInfo(false); + quitStreamPreview = true; + win.close(); + win.destroyWindow(); + std::cout << "press ESC quitStreamPreview" << std::endl; + } + } + else if(key == 'S' || key == 's') { + std::cout << "syncDevicesTime..." << std::endl; + context.enableDeviceClockSync(60000); // Manual update synchronization + } + else if(key == 'T' || key == 't') { + // software trigger + std::cout << "check software trigger mode" << std::endl; + for(auto &dev: streamDevList) { + auto multiDeviceSyncConfig = dev->getMultiDeviceSyncConfig(); + if(multiDeviceSyncConfig.syncMode == OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING) { + std::cout << "software trigger..." << std::endl; + dev->triggerCapture(); + } + } + } +} + +int testMultiDeviceSync() { + try { + streamDevList.clear(); + // Query the list of connected devices + auto devList = context.queryDeviceList(); + int devCount = devList->deviceCount(); + for(int i = 0; i < devCount; i++) { + streamDevList.push_back(devList->getDevice(i)); + } + + if(streamDevList.empty()) { + std::cerr << "Device list is empty. please check device connection state" << std::endl; + return -1; + } + + // traverse the device list and create the device + std::vector> primary_devices; + std::vector> secondary_devices; + for(auto dev: streamDevList) { + auto config = dev->getMultiDeviceSyncConfig(); + if(config.syncMode == OB_MULTI_DEVICE_SYNC_MODE_PRIMARY) { + primary_devices.push_back(dev); + } + else { + secondary_devices.push_back(dev); + } + } + + std::cout << "Secondary devices start..." << std::endl; + startDeviceStreams(secondary_devices, 0); + + if(primary_devices.empty()) { + std::cerr << "WARNING primary_devices is empty!!!" << std::endl; + } + else { + std::cout << "Primary device start..." << std::endl; + startDeviceStreams(primary_devices, static_cast(secondary_devices.size())); + } + + // Start the multi-device time synchronization function + context.enableDeviceClockSync(60000); // update and sync every minitor + + // Create a window for rendering and set the resolution of the window + ob_smpl::CVWindow win("MultiDeviceSyncViewer", 1600, 900, ob_smpl::ARRANGE_GRID); + + // set key prompt + win.setKeyPrompt("'S': syncDevicesTime, 'T': software trigger"); + // set the callback function for the window to handle key press events + win.setKeyPressedCallback([&](int key) { handleKeyPress(win, key); }); + + win.setShowInfo(true); + win.setShowSyncTimeInfo(true); + while(win.run() && !quitStreamPreview) { + if(quitStreamPreview) { + break; + } + std::vector, std::shared_ptr>> framePairs; + { + std::lock_guard lock(frameMutex); + for(uint8_t i = 0; i < static_cast(std::min(MAX_DEVICE_COUNT, (int)depthFrames.size())); i++) { + if(depthFrames[i] != nullptr && colorFrames[i] != nullptr) { + framePairs.emplace_back(depthFrames[i], colorFrames[i]); + } + } + } + auto groudID = 0; + for(const auto &pair: framePairs) { + groudID++; + win.pushFramesToView({ pair.first, pair.second }, groudID); + } + } + + // Stop streams and clear resources + for(auto &holder: pipelineHolderList) { + stopStream(holder); + } + pipelineHolderList.clear(); + depthFrames.clear(); + colorFrames.clear(); + + // Release resource + streamDevList.clear(); + configDevList.clear(); + deviceConfigList.clear(); + return 0; + } + catch(ob::Error &e) { + std::cerr << "function:" << e.getName() << "\nargs:" << e.getArgs() << "\nmessage:" << e.getMessage() << "\ntype:" << e.getExceptionType() << std::endl; + std::cout << "\nPress any key to exit."; + ob_smpl::waitForKeyPressed(); + exit(EXIT_FAILURE); + return -1; + } +} + +std::shared_ptr createPipelineHolder(std::shared_ptr device, OBSensorType sensorType, int deviceIndex) { + auto holder = std::make_shared(); + holder->pipeline = std::make_shared(device); + holder->sensorType = sensorType; + holder->deviceIndex = deviceIndex; + holder->deviceSN = device->getDeviceInfo()->serialNumber(); + return holder; +} + +void processFrame(std::shared_ptr frameSet, OBFrameType frameType, int deviceIndex) { + if(!frameSet) { + std::cerr << "Invalid frameSet received." << std::endl; + return; + } + + if(quitStreamPreview) { + // std::cerr << "press ESC quit Stream ProcessFrame." << std::endl; + return; + } + + auto frame = frameSet->getFrame(frameType); + if(frame) { + if(frameType == OB_FRAME_COLOR) { + handleColorStream(static_cast(deviceIndex), frame); + } + else if(frameType == OB_FRAME_DEPTH) { + handleDepthStream(static_cast(deviceIndex), frame); + } + } +} + +void handleStreamError(const ob::Error &e) { + // Separate error handling logic + std::cerr << "Function: " << e.getName() << "\nArgs: " << e.getArgs() << "\nMessage: " << e.getMessage() << "\nType: " << e.getExceptionType() << std::endl; +} + +void startStream(std::shared_ptr holder) { + std::cout << "startStream. " << holder << std::endl; + try { + auto pipeline = holder->pipeline; + auto profileList = pipeline->getStreamProfileList(holder->sensorType); + + int width = OB_WIDTH_ANY; + int height = OB_HEIGHT_ANY; + OBFormat format = OB_FORMAT_UNKNOWN; + int fps = OB_FPS_ANY; + + for(auto config: streamConfigList) { + if(config->sensorType == holder->sensorType && isValidStreamConfigInfo(config)) { + width = config->width; + height = config->height; + format = config->format; + fps = config->fps; + break; + } + } + + auto streamProfile = profileList->getVideoStreamProfile(width, height, format, fps); + + auto frameType = mapFrameType(holder->sensorType); + auto deviceIndex = holder->deviceIndex; + + std::shared_ptr config = std::make_shared(); + config->enableStream(streamProfile); + + pipeline->start(config, [frameType, deviceIndex](std::shared_ptr frameSet) { processFrame(frameSet, frameType, deviceIndex); }); + } + catch(ob::Error &e) { + std::cerr << "starting stream failed: " << holder << std::endl; + handleStreamError(e); + } +} + +void stopStream(std::shared_ptr holder) { + try { + std::cout << "stopStream " << holder << std::endl; + holder->pipeline->stop(); + } + catch(ob::Error &e) { + std::cerr << "stopping stream failed: " << holder << std::endl; + std::cerr << "function:" << e.getName() << "\nargs:" << e.getArgs() << "\nmessage:" << e.getMessage() << "\ntype:" << e.getExceptionType() << std::endl; + } +} + +void handleStream(uint8_t devIndex, std::shared_ptr frame, const char *frameType) { + std::lock_guard lock(frameMutex); + std::cout << "Device#" << static_cast(devIndex) << ", " << frameType << " frame(us) " + << ", frame timestamp=" << frame->timeStampUs() << "," + << "global timestamp = " << frame->globalTimeStampUs() << "," + << "system timestamp = " << frame->systemTimeStampUs() << std::endl; + + if(strcmp(frameType, "color") == 0) { + colorFrames[devIndex] = frame; + } + else if(strcmp(frameType, "depth") == 0) { + depthFrames[devIndex] = frame; + } +} + +void handleColorStream(uint8_t devIndex, std::shared_ptr frame) { + handleStream(devIndex, frame, "color"); +} + +void handleDepthStream(uint8_t devIndex, std::shared_ptr frame) { + handleStream(devIndex, frame, "depth"); +} + +std::string readFileContent(const char *filePath) { + std::ostringstream oss; + std::ifstream file(filePath, std::fstream::in); + if(!file.is_open()) { + std::cerr << "Failed to open file: " << filePath << std::endl; + return ""; + } + oss << file.rdbuf(); + file.close(); + return oss.str(); +} + +std::shared_ptr parseStreamProfileConfig(cJSON *streamProfileElem, const std::string &sensorKey) { + cJSON *sensorElem = cJSON_GetObjectItem(streamProfileElem, sensorKey.c_str()); + if(!sensorElem) { + std::cout << "parseConfig[" << sensorKey << "] not find root json element" << std::endl; + return nullptr; + } + + auto streamConfigInfo = std::shared_ptr(new StreamConfigInfo{}); + cJSON *widthElem = cJSON_GetObjectItemCaseSensitive(sensorElem, "width"); + if(widthElem && cJSON_IsNumber(widthElem)) { + streamConfigInfo->width = widthElem->valueint; + } + else { + std::cout << "parseConfig[" << sensorKey << "] not find 'width' json element" << std::endl; + } + + cJSON *heightElem = cJSON_GetObjectItemCaseSensitive(sensorElem, "height"); + if(heightElem && cJSON_IsNumber(heightElem)) { + streamConfigInfo->height = heightElem->valueint; + } + else { + std::cout << "parseConfig[" << sensorKey << "] not find 'height' json element" << std::endl; + } + + cJSON *formatElem = cJSON_GetObjectItemCaseSensitive(sensorElem, "format"); + if(formatElem && cJSON_IsString(formatElem)) { + streamConfigInfo->format = textToOBFormat(formatElem->valuestring); + } + else { + std::cout << "parseConfig[" << sensorKey << "] not find 'format' json element" << std::endl; + } + + cJSON *fpsElem = cJSON_GetObjectItemCaseSensitive(sensorElem, "fps"); + if(fpsElem && cJSON_IsNumber(fpsElem)) { + streamConfigInfo->fps = fpsElem->valueint; + } + else { + std::cout << "parseConfig[" << sensorKey << "] not find 'fps' json element" << std::endl; + } + + cJSON *enableElem = cJSON_GetObjectItemCaseSensitive(sensorElem, "enable"); + if(enableElem && cJSON_IsBool(enableElem)) { + streamConfigInfo->enable = (bool)enableElem->valueint; + } + if(!isValidStreamConfigInfo(streamConfigInfo)) { + std::cout << "parseConfig[" << sensorKey << "] StreamConfigInfo is invalid." << std::endl; + return nullptr; + } + return streamConfigInfo; +} + +bool loadConfigFile() { + int deviceCount = 0; + std::shared_ptr devConfigInfo = nullptr; + cJSON *deviceElem = nullptr; + + auto content = readFileContent(CONFIG_FILE); + if(content.empty()) { + std::cerr << "load config file failed." << std::endl; + return false; + } + + cJSON *rootElem = cJSON_Parse(content.c_str()); + if(rootElem == nullptr) { + const char *errMsg = cJSON_GetErrorPtr(); + std::cout << std::string(errMsg) << std::endl; + cJSON_Delete(rootElem); + return true; + } + + // 1. multi device sync config + cJSON *devicesElem = cJSON_GetObjectItem(rootElem, "devices"); + cJSON_ArrayForEach(deviceElem, devicesElem) { + devConfigInfo = std::make_shared(); + memset(&devConfigInfo->syncConfig, 0, sizeof(devConfigInfo->syncConfig)); + devConfigInfo->syncConfig.syncMode = OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN; + + cJSON *snElem = cJSON_GetObjectItem(deviceElem, "sn"); + if(cJSON_IsString(snElem) && snElem->valuestring != nullptr) { + devConfigInfo->deviceSN = std::string(snElem->valuestring); + } + cJSON *deviceConfigElem = cJSON_GetObjectItem(deviceElem, "syncConfig"); + if(cJSON_IsObject(deviceConfigElem)) { + cJSON *numberElem = nullptr; + cJSON *strElem = nullptr; + cJSON *bElem = nullptr; + strElem = cJSON_GetObjectItemCaseSensitive(deviceConfigElem, "syncMode"); + if(cJSON_IsString(strElem) && strElem->valuestring != nullptr) { + devConfigInfo->syncConfig.syncMode = stringToOBSyncMode(strElem->valuestring); + std::cout << "config[" << (deviceCount++) << "]: SN=" << std::string(devConfigInfo->deviceSN) << ", mode=" << strElem->valuestring << std::endl; + } + numberElem = cJSON_GetObjectItemCaseSensitive(deviceConfigElem, "depthDelayUs"); + if(cJSON_IsNumber(numberElem)) { + devConfigInfo->syncConfig.depthDelayUs = numberElem->valueint; + } + numberElem = cJSON_GetObjectItemCaseSensitive(deviceConfigElem, "colorDelayUs"); + if(cJSON_IsNumber(numberElem)) { + devConfigInfo->syncConfig.colorDelayUs = numberElem->valueint; + } + numberElem = cJSON_GetObjectItemCaseSensitive(deviceConfigElem, "trigger2ImageDelayUs"); + if(cJSON_IsNumber(numberElem)) { + devConfigInfo->syncConfig.trigger2ImageDelayUs = numberElem->valueint; + } + numberElem = cJSON_GetObjectItemCaseSensitive(deviceConfigElem, "triggerOutDelayUs"); + if(cJSON_IsNumber(numberElem)) { + devConfigInfo->syncConfig.triggerOutDelayUs = numberElem->valueint; + } + bElem = cJSON_GetObjectItemCaseSensitive(deviceConfigElem, "triggerOutEnable"); + if(cJSON_IsBool(bElem)) { + devConfigInfo->syncConfig.triggerOutEnable = (bool)bElem->valueint; + } + bElem = cJSON_GetObjectItemCaseSensitive(deviceConfigElem, "framesPerTrigger"); + if(cJSON_IsNumber(bElem)) { + devConfigInfo->syncConfig.framesPerTrigger = bElem->valueint; + } + } + + if(OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN != devConfigInfo->syncConfig.syncMode) { + deviceConfigList.push_back(devConfigInfo); + } + else { + std::cerr << "Invalid sync mode of deviceSN: " << devConfigInfo->deviceSN << std::endl; + } + devConfigInfo = nullptr; + } + + // 2. Get sensor control config + { + cJSON *sensorControlElem = cJSON_GetObjectItem(rootElem, "sensorControl"); + cJSON *strElem = nullptr; + cJSON *bElem = nullptr; + cJSON *intElem = nullptr; + if(sensorControlElem) { + sensorControlInfo = std::shared_ptr(new SensorControlInfo{}); + // sensor control switch + bElem = cJSON_GetObjectItemCaseSensitive(sensorControlElem, "enable"); + if(cJSON_IsBool(bElem)) { + sensorControlInfo->enable = bElem->valueint; + } + // depth preset + strElem = cJSON_GetObjectItemCaseSensitive(sensorControlElem, "depthPreset"); + if(cJSON_IsString(strElem) && strElem->valuestring != nullptr) { + sensorControlInfo->depthPreset = std::string(strElem->valuestring); + } + + // laser power level + intElem = cJSON_GetObjectItemCaseSensitive(sensorControlElem, "laserPowerLevel"); + if(cJSON_IsNumber(intElem)) { + sensorControlInfo->laserPowerLevel = intElem->valueint; + } + // disparity search range + std::map disparitySearchRangeMap = { { "64", 0 }, { "128", 1 }, { "256", 2 } }; + strElem = cJSON_GetObjectItemCaseSensitive(sensorControlElem, "disparitySearchRange"); + if(cJSON_IsString(strElem) && strElem->valuestring != nullptr) { + sensorControlInfo->disparitySearchRange = disparitySearchRangeMap[strElem->valuestring]; + } + + // hardware d2d + bElem = cJSON_GetObjectItemCaseSensitive(sensorControlElem, "hardwareD2d"); + if(cJSON_IsBool(bElem)) { + sensorControlInfo->hardwareD2d = bElem->valueint; + } + + // hardware noise removal + bElem = cJSON_GetObjectItemCaseSensitive(sensorControlElem, "hardwareNoiseRemoval"); + if(cJSON_IsBool(bElem)) { + sensorControlInfo->hardwareNoiseRemoval = bElem->valueint; + } + + // software noise removal + bElem = cJSON_GetObjectItemCaseSensitive(sensorControlElem, "softwareNoiseRemoval"); + if(cJSON_IsBool(bElem)) { + sensorControlInfo->softwareNoiseRemoval = bElem->valueint; + } + + // laser on + bElem = cJSON_GetObjectItemCaseSensitive(sensorControlElem, "laserOn"); + if(cJSON_IsBool(bElem)) { + sensorControlInfo->laserOn = bElem->valueint; + } + + // color auto exposure + bElem = cJSON_GetObjectItemCaseSensitive(sensorControlElem, "colorAutoExposure"); + if(cJSON_IsBool(bElem)) { + sensorControlInfo->colorAutoExposure = bElem->valueint; + } + + // color exposure and gain + intElem = cJSON_GetObjectItemCaseSensitive(sensorControlElem, "colorExposure"); + if(cJSON_IsNumber(intElem)) { + sensorControlInfo->colorExposure = intElem->valueint; + } + + intElem = cJSON_GetObjectItemCaseSensitive(sensorControlElem, "colorGain"); + if(cJSON_IsNumber(intElem)) { + sensorControlInfo->colorGain = intElem->valueint; + } + + // ir AE + bElem = cJSON_GetObjectItemCaseSensitive(sensorControlElem, "irAutoExposure"); + if(cJSON_IsBool(bElem)) { + sensorControlInfo->irAutoExposure = bElem->valueint; + } + + // ir exposure and gain + intElem = cJSON_GetObjectItemCaseSensitive(sensorControlElem, "irExposure"); + if(cJSON_IsNumber(intElem)) { + sensorControlInfo->irExposure = intElem->valueint; + } + + intElem = cJSON_GetObjectItemCaseSensitive(sensorControlElem, "irGain"); + if(cJSON_IsNumber(intElem)) { + sensorControlInfo->irGain = intElem->valueint; + } + } + } + // 3. Get sensor config + cJSON *streamProfileElem = cJSON_GetObjectItem(rootElem, "streamProfile"); + if(streamProfileElem) { + std::vector sensorNames = { "color", "depth" }; + std::map sensorTypeMap = { { "color", OB_SENSOR_COLOR }, { "depth", OB_SENSOR_DEPTH } }; + for(const std::string &sensorName: sensorNames) { + auto profileConfig = parseStreamProfileConfig(streamProfileElem, sensorName); + if(profileConfig) { + profileConfig->sensorType = sensorTypeMap[sensorName]; + streamConfigList.push_back(profileConfig); + } + } + } + + cJSON_Delete(rootElem); + return true; +} + +OBMultiDeviceSyncMode stringToOBSyncMode(const std::string &modeString) { + static const std::unordered_map syncModeMap = { + { "OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN", OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN }, + { "OB_MULTI_DEVICE_SYNC_MODE_STANDALONE", OB_MULTI_DEVICE_SYNC_MODE_STANDALONE }, + { "OB_MULTI_DEVICE_SYNC_MODE_PRIMARY", OB_MULTI_DEVICE_SYNC_MODE_PRIMARY }, + { "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", OB_MULTI_DEVICE_SYNC_MODE_SECONDARY }, + { "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY_SYNCED", OB_MULTI_DEVICE_SYNC_MODE_SECONDARY_SYNCED }, + { "OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING", OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING }, + { "OB_MULTI_DEVICE_SYNC_MODE_HARDWARE_TRIGGERING", OB_MULTI_DEVICE_SYNC_MODE_HARDWARE_TRIGGERING } + }; + auto it = syncModeMap.find(modeString); + if(it != syncModeMap.end()) { + return it->second; + } + // Constructing exception messages with stringstream + std::stringstream ss; + ss << "Unrecognized sync mode: " << modeString; + throw std::invalid_argument(ss.str()); +} + +std::string OBSyncModeToString(const OBMultiDeviceSyncMode syncMode) { + static const std::unordered_map modeToStringMap = { + { OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN, "OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN" }, + { OB_MULTI_DEVICE_SYNC_MODE_STANDALONE, "OB_MULTI_DEVICE_SYNC_MODE_STANDALONE" }, + { OB_MULTI_DEVICE_SYNC_MODE_PRIMARY, "OB_MULTI_DEVICE_SYNC_MODE_PRIMARY" }, + { OB_MULTI_DEVICE_SYNC_MODE_SECONDARY, "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY" }, + { OB_MULTI_DEVICE_SYNC_MODE_SECONDARY_SYNCED, "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY_SYNCED" }, + { OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING, "OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING" }, + { OB_MULTI_DEVICE_SYNC_MODE_HARDWARE_TRIGGERING, "OB_MULTI_DEVICE_SYNC_MODE_HARDWARE_TRIGGERING" } + }; + + auto it = modeToStringMap.find(syncMode); + if(it != modeToStringMap.end()) { + return it->second; + } + std::stringstream ss; + ss << "Unmapped sync mode value: " << static_cast(syncMode) << ". Please check the sync mode value."; + throw std::invalid_argument(ss.str()); +} + +int strcmp_nocase(const char *str0, const char *str1) { +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) + return _strcmpi(str0, str1); +#else + return strcasecmp(str0, str1); +#endif +} + +OBFrameType mapFrameType(OBSensorType sensorType) { + switch(sensorType) { + case OB_SENSOR_COLOR: + return OB_FRAME_COLOR; + case OB_SENSOR_IR: + return OB_FRAME_IR; + case OB_SENSOR_IR_LEFT: + return OB_FRAME_IR_LEFT; + case OB_SENSOR_IR_RIGHT: + return OB_FRAME_IR_RIGHT; + case OB_SENSOR_DEPTH: + return OB_FRAME_DEPTH; + default: + return OBFrameType::OB_FRAME_UNKNOWN; + } +} + +std::ostream &operator<<(std::ostream &os, const PipelineHolder &holder) { + if(os.good()) { + os << "deviceSN: " << holder.deviceSN << ", sensorType: "; + switch(holder.sensorType) { + case OB_SENSOR_COLOR: + os << "OB_SENSOR_COLOR"; + break; + case OB_SENSOR_DEPTH: + os << "OB_SENSOR_DEPTH"; + break; + default: + os << static_cast(holder.sensorType); + break; + } + os << ", deviceIndex: " << holder.deviceIndex; + } + return os; +} diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync/utils/cJSON.c b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync/utils/cJSON.c new file mode 100644 index 0000000..4a338db --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync/utils/cJSON.c @@ -0,0 +1,2667 @@ +/* + Copyright (c) 2009-2017 Dave Gamble and cJSON contributors + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/* cJSON */ +/* JSON parser in C. */ + +/* disable warnings about old C89 functions in MSVC */ +#if !defined(_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) +#define _CRT_SECURE_NO_DEPRECATE +#endif + +#ifdef __GNUC__ +#pragma GCC visibility push(default) +#endif +#if defined(_MSC_VER) +#pragma warning(push) +/* disable warning about single line comments in system headers */ +#pragma warning(disable : 4001) +#endif + +#include +#include +#include +#include +#include +#include +#include + +#ifdef ENABLE_LOCALES +#include +#endif + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + +#include "cJSON.h" + +/* define our own boolean type */ +#ifdef true +#undef true +#endif +#define true ((cJSON_bool)1) + +#ifdef false +#undef false +#endif +#define false ((cJSON_bool)0) + +/* define isnan and isinf for ANSI C, if in C99 or above, isnan and isinf has been defined in math.h */ +#ifndef isinf +#define isinf(d) (isnan((d - d)) && !isnan(d)) +#endif +#ifndef isnan +#define isnan(d) (d != d) +#endif + +#ifndef NAN +#ifdef _WIN32 +#define NAN sqrt(-1.0) +#else +#define NAN 0.0 / 0.0 +#endif +#endif + +typedef struct { + const unsigned char *json; + size_t position; +} error; +static error global_error = { NULL, 0 }; + +CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void) { + return (const char *)(global_error.json + global_error.position); +} + +CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON *const item) { + if(!cJSON_IsString(item)) { + return NULL; + } + + return item->valuestring; +} + +CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON *const item) { + if(!cJSON_IsNumber(item)) { + return (double)NAN; + } + + return item->valuedouble; +} + +/* This is a safeguard to prevent copy-pasters from using incompatible C and header files */ +#if(CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 15) +#error cJSON.h and cJSON.c have different versions. Make sure that both have the same. +#endif + +CJSON_PUBLIC(const char *) cJSON_Version(void) { + static char version[15]; + sprintf(version, "%i.%i.%i", CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH); + + return version; +} + +/* Case insensitive string comparison, doesn't consider two NULL pointers equal though */ +static int case_insensitive_strcmp(const unsigned char *string1, const unsigned char *string2) { + if((string1 == NULL) || (string2 == NULL)) { + return 1; + } + + if(string1 == string2) { + return 0; + } + + for(; tolower(*string1) == tolower(*string2); (void)string1++, string2++) { + if(*string1 == '\0') { + return 0; + } + } + + return tolower(*string1) - tolower(*string2); +} + +typedef struct internal_hooks { + void *(CJSON_CDECL *allocate)(size_t size); + void(CJSON_CDECL *deallocate)(void *pointer); + void *(CJSON_CDECL *reallocate)(void *pointer, size_t size); +} internal_hooks; + +#if defined(_MSC_VER) +/* work around MSVC error C2322: '...' address of dllimport '...' is not static */ +static void *CJSON_CDECL internal_malloc(size_t size) { + return malloc(size); +} +static void CJSON_CDECL internal_free(void *pointer) { + free(pointer); +} +static void *CJSON_CDECL internal_realloc(void *pointer, size_t size) { + return realloc(pointer, size); +} +#else +#define internal_malloc malloc +#define internal_free free +#define internal_realloc realloc +#endif + +/* strlen of character literals resolved at compile time */ +#define static_strlen(string_literal) (sizeof(string_literal) - sizeof("")) + +static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc }; + +static unsigned char *cJSON_strdup(const unsigned char *string, const internal_hooks *const hooks) { + size_t length = 0; + unsigned char *copy = NULL; + + if(string == NULL) { + return NULL; + } + + length = strlen((const char *)string) + sizeof(""); + copy = (unsigned char *)hooks->allocate(length); + if(copy == NULL) { + return NULL; + } + memcpy(copy, string, length); + + return copy; +} + +CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks *hooks) { + if(hooks == NULL) { + /* Reset hooks */ + global_hooks.allocate = malloc; + global_hooks.deallocate = free; + global_hooks.reallocate = realloc; + return; + } + + global_hooks.allocate = malloc; + if(hooks->malloc_fn != NULL) { + global_hooks.allocate = hooks->malloc_fn; + } + + global_hooks.deallocate = free; + if(hooks->free_fn != NULL) { + global_hooks.deallocate = hooks->free_fn; + } + + /* use realloc only if both free and malloc are used */ + global_hooks.reallocate = NULL; + if((global_hooks.allocate == malloc) && (global_hooks.deallocate == free)) { + global_hooks.reallocate = realloc; + } +} + +/* Internal constructor. */ +static cJSON *cJSON_New_Item(const internal_hooks *const hooks) { + cJSON *node = (cJSON *)hooks->allocate(sizeof(cJSON)); + if(node) { + memset(node, '\0', sizeof(cJSON)); + } + + return node; +} + +/* Delete a cJSON structure. */ +CJSON_PUBLIC(void) cJSON_Delete(cJSON *item) { + cJSON *next = NULL; + while(item != NULL) { + next = item->next; + if(!(item->type & cJSON_IsReference) && (item->child != NULL)) { + cJSON_Delete(item->child); + } + if(!(item->type & cJSON_IsReference) && (item->valuestring != NULL)) { + global_hooks.deallocate(item->valuestring); + } + if(!(item->type & cJSON_StringIsConst) && (item->string != NULL)) { + global_hooks.deallocate(item->string); + } + global_hooks.deallocate(item); + item = next; + } +} + +/* get the decimal point character of the current locale */ +static unsigned char get_decimal_point(void) { +#ifdef ENABLE_LOCALES + struct lconv *lconv = localeconv(); + return (unsigned char)lconv->decimal_point[0]; +#else + return '.'; +#endif +} + +typedef struct { + const unsigned char *content; + size_t length; + size_t offset; + size_t depth; /* How deeply nested (in arrays/objects) is the input at the current offset. */ + internal_hooks hooks; +} parse_buffer; + +/* check if the given size is left to read in a given parse buffer (starting with 1) */ +#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length)) +/* check if the buffer can be accessed at the given index (starting with 0) */ +#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length)) +#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index)) +/* get a pointer to the buffer at the position */ +#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset) + +/* Parse the input text to generate a number, and populate the result into item. */ +static cJSON_bool parse_number(cJSON *const item, parse_buffer *const input_buffer) { + double number = 0; + unsigned char *after_end = NULL; + unsigned char number_c_string[64]; + unsigned char decimal_point = get_decimal_point(); + size_t i = 0; + + if((input_buffer == NULL) || (input_buffer->content == NULL)) { + return false; + } + + /* copy the number into a temporary buffer and replace '.' with the decimal point + * of the current locale (for strtod) + * This also takes care of '\0' not necessarily being available for marking the end of the input */ + for(i = 0; (i < (sizeof(number_c_string) - 1)) && can_access_at_index(input_buffer, i); i++) { + switch(buffer_at_offset(input_buffer)[i]) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '+': + case '-': + case 'e': + case 'E': + number_c_string[i] = buffer_at_offset(input_buffer)[i]; + break; + + case '.': + number_c_string[i] = decimal_point; + break; + + default: + goto loop_end; + } + } +loop_end: + number_c_string[i] = '\0'; + + number = strtod((const char *)number_c_string, (char **)&after_end); + if(number_c_string == after_end) { + return false; /* parse_error */ + } + + item->valuedouble = number; + + /* use saturation in case of overflow */ + if(number >= INT_MAX) { + item->valueint = INT_MAX; + } + else if(number <= (double)INT_MIN) { + item->valueint = INT_MIN; + } + else { + item->valueint = (int)number; + } + + item->type = cJSON_Number; + + input_buffer->offset += (size_t)(after_end - number_c_string); + return true; +} + +/* don't ask me, but the original cJSON_SetNumberValue returns an integer or double */ +CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number) { + if(number >= INT_MAX) { + object->valueint = INT_MAX; + } + else if(number <= (double)INT_MIN) { + object->valueint = INT_MIN; + } + else { + object->valueint = (int)number; + } + + return object->valuedouble = number; +} + +CJSON_PUBLIC(char *) cJSON_SetValuestring(cJSON *object, const char *valuestring) { + char *copy = NULL; + /* if object's type is not cJSON_String or is cJSON_IsReference, it should not set valuestring */ + if(!(object->type & cJSON_String) || (object->type & cJSON_IsReference)) { + return NULL; + } + if(strlen(valuestring) <= strlen(object->valuestring)) { + strcpy(object->valuestring, valuestring); + return object->valuestring; + } + copy = (char *)cJSON_strdup((const unsigned char *)valuestring, &global_hooks); + if(copy == NULL) { + return NULL; + } + if(object->valuestring != NULL) { + cJSON_free(object->valuestring); + } + object->valuestring = copy; + + return copy; +} + +typedef struct { + unsigned char *buffer; + size_t length; + size_t offset; + size_t depth; /* current nesting depth (for formatted printing) */ + cJSON_bool noalloc; + cJSON_bool format; /* is this print a formatted print */ + internal_hooks hooks; +} printbuffer; + +/* realloc printbuffer if necessary to have at least "needed" bytes more */ +static unsigned char *ensure(printbuffer *const p, size_t needed) { + unsigned char *newbuffer = NULL; + size_t newsize = 0; + + if((p == NULL) || (p->buffer == NULL)) { + return NULL; + } + + if((p->length > 0) && (p->offset >= p->length)) { + /* make sure that offset is valid */ + return NULL; + } + + if(needed > INT_MAX) { + /* sizes bigger than INT_MAX are currently not supported */ + return NULL; + } + + needed += p->offset + 1; + if(needed <= p->length) { + return p->buffer + p->offset; + } + + if(p->noalloc) { + return NULL; + } + + /* calculate new buffer size */ + if(needed > (INT_MAX / 2)) { + /* overflow of int, use INT_MAX if possible */ + if(needed <= INT_MAX) { + newsize = INT_MAX; + } + else { + return NULL; + } + } + else { + newsize = needed * 2; + } + + if(p->hooks.reallocate != NULL) { + /* reallocate with realloc if available */ + newbuffer = (unsigned char *)p->hooks.reallocate(p->buffer, newsize); + if(newbuffer == NULL) { + p->hooks.deallocate(p->buffer); + p->length = 0; + p->buffer = NULL; + + return NULL; + } + } + else { + /* otherwise reallocate manually */ + newbuffer = (unsigned char *)p->hooks.allocate(newsize); + if(!newbuffer) { + p->hooks.deallocate(p->buffer); + p->length = 0; + p->buffer = NULL; + + return NULL; + } + + memcpy(newbuffer, p->buffer, p->offset + 1); + p->hooks.deallocate(p->buffer); + } + p->length = newsize; + p->buffer = newbuffer; + + return newbuffer + p->offset; +} + +/* calculate the new length of the string in a printbuffer and update the offset */ +static void update_offset(printbuffer *const buffer) { + const unsigned char *buffer_pointer = NULL; + if((buffer == NULL) || (buffer->buffer == NULL)) { + return; + } + buffer_pointer = buffer->buffer + buffer->offset; + + buffer->offset += strlen((const char *)buffer_pointer); +} + +/* securely comparison of floating-point variables */ +static cJSON_bool compare_double(double a, double b) { + double maxVal = fabs(a) > fabs(b) ? fabs(a) : fabs(b); + return (fabs(a - b) <= maxVal * DBL_EPSILON); +} + +/* Render the number nicely from the given item into a string. */ +static cJSON_bool print_number(const cJSON *const item, printbuffer *const output_buffer) { + unsigned char *output_pointer = NULL; + double d = item->valuedouble; + int length = 0; + size_t i = 0; + unsigned char number_buffer[26] = { 0 }; /* temporary buffer to print the number into */ + unsigned char decimal_point = get_decimal_point(); + double test = 0.0; + + if(output_buffer == NULL) { + return false; + } + + /* This checks for NaN and Infinity */ + if(isnan(d) || isinf(d)) { + length = sprintf((char *)number_buffer, "null"); + } + else { + /* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */ + length = sprintf((char *)number_buffer, "%1.15g", d); + + /* Check whether the original double can be recovered */ + if((sscanf((char *)number_buffer, "%lg", &test) != 1) || !compare_double((double)test, d)) { + /* If not, print with 17 decimal places of precision */ + length = sprintf((char *)number_buffer, "%1.17g", d); + } + } + + /* sprintf failed or buffer overrun occurred */ + if((length < 0) || (length > (int)(sizeof(number_buffer) - 1))) { + return false; + } + + /* reserve appropriate space in the output */ + output_pointer = ensure(output_buffer, (size_t)length + sizeof("")); + if(output_pointer == NULL) { + return false; + } + + /* copy the printed number to the output and replace locale + * dependent decimal point with '.' */ + for(i = 0; i < ((size_t)length); i++) { + if(number_buffer[i] == decimal_point) { + output_pointer[i] = '.'; + continue; + } + + output_pointer[i] = number_buffer[i]; + } + output_pointer[i] = '\0'; + + output_buffer->offset += (size_t)length; + + return true; +} + +/* parse 4 digit hexadecimal number */ +static unsigned parse_hex4(const unsigned char *const input) { + unsigned int h = 0; + size_t i = 0; + + for(i = 0; i < 4; i++) { + /* parse digit */ + if((input[i] >= '0') && (input[i] <= '9')) { + h += (unsigned int)input[i] - '0'; + } + else if((input[i] >= 'A') && (input[i] <= 'F')) { + h += (unsigned int)10 + input[i] - 'A'; + } + else if((input[i] >= 'a') && (input[i] <= 'f')) { + h += (unsigned int)10 + input[i] - 'a'; + } + else /* invalid */ + { + return 0; + } + + if(i < 3) { + /* shift left to make place for the next nibble */ + h = h << 4; + } + } + + return h; +} + +/* converts a UTF-16 literal to UTF-8 + * A literal can be one or two sequences of the form \uXXXX */ +static unsigned char utf16_literal_to_utf8(const unsigned char *const input_pointer, const unsigned char *const input_end, unsigned char **output_pointer) { + long unsigned int codepoint = 0; + unsigned int first_code = 0; + const unsigned char *first_sequence = input_pointer; + unsigned char utf8_length = 0; + unsigned char utf8_position = 0; + unsigned char sequence_length = 0; + unsigned char first_byte_mark = 0; + + if((input_end - first_sequence) < 6) { + /* input ends unexpectedly */ + goto fail; + } + + /* get the first utf16 sequence */ + first_code = parse_hex4(first_sequence + 2); + + /* check that the code is valid */ + if(((first_code >= 0xDC00) && (first_code <= 0xDFFF))) { + goto fail; + } + + /* UTF16 surrogate pair */ + if((first_code >= 0xD800) && (first_code <= 0xDBFF)) { + const unsigned char *second_sequence = first_sequence + 6; + unsigned int second_code = 0; + sequence_length = 12; /* \uXXXX\uXXXX */ + + if((input_end - second_sequence) < 6) { + /* input ends unexpectedly */ + goto fail; + } + + if((second_sequence[0] != '\\') || (second_sequence[1] != 'u')) { + /* missing second half of the surrogate pair */ + goto fail; + } + + /* get the second utf16 sequence */ + second_code = parse_hex4(second_sequence + 2); + /* check that the code is valid */ + if((second_code < 0xDC00) || (second_code > 0xDFFF)) { + /* invalid second half of the surrogate pair */ + goto fail; + } + + /* calculate the unicode codepoint from the surrogate pair */ + codepoint = 0x10000 + (((first_code & 0x3FF) << 10) | (second_code & 0x3FF)); + } + else { + sequence_length = 6; /* \uXXXX */ + codepoint = first_code; + } + + /* encode as UTF-8 + * takes at maximum 4 bytes to encode: + * 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */ + if(codepoint < 0x80) { + /* normal ascii, encoding 0xxxxxxx */ + utf8_length = 1; + } + else if(codepoint < 0x800) { + /* two bytes, encoding 110xxxxx 10xxxxxx */ + utf8_length = 2; + first_byte_mark = 0xC0; /* 11000000 */ + } + else if(codepoint < 0x10000) { + /* three bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx */ + utf8_length = 3; + first_byte_mark = 0xE0; /* 11100000 */ + } + else if(codepoint <= 0x10FFFF) { + /* four bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx 10xxxxxx */ + utf8_length = 4; + first_byte_mark = 0xF0; /* 11110000 */ + } + else { + /* invalid unicode codepoint */ + goto fail; + } + + /* encode as utf8 */ + for(utf8_position = (unsigned char)(utf8_length - 1); utf8_position > 0; utf8_position--) { + /* 10xxxxxx */ + (*output_pointer)[utf8_position] = (unsigned char)((codepoint | 0x80) & 0xBF); + codepoint >>= 6; + } + /* encode first byte */ + if(utf8_length > 1) { + (*output_pointer)[0] = (unsigned char)((codepoint | first_byte_mark) & 0xFF); + } + else { + (*output_pointer)[0] = (unsigned char)(codepoint & 0x7F); + } + + *output_pointer += utf8_length; + + return sequence_length; + +fail: + return 0; +} + +/* Parse the input text into an unescaped cinput, and populate item. */ +static cJSON_bool parse_string(cJSON *const item, parse_buffer *const input_buffer) { + const unsigned char *input_pointer = buffer_at_offset(input_buffer) + 1; + const unsigned char *input_end = buffer_at_offset(input_buffer) + 1; + unsigned char *output_pointer = NULL; + unsigned char *output = NULL; + + /* not a string */ + if(buffer_at_offset(input_buffer)[0] != '\"') { + goto fail; + } + + { + /* calculate approximate size of the output (overestimate) */ + size_t allocation_length = 0; + size_t skipped_bytes = 0; + while(((size_t)(input_end - input_buffer->content) < input_buffer->length) && (*input_end != '\"')) { + /* is escape sequence */ + if(input_end[0] == '\\') { + if((size_t)(input_end + 1 - input_buffer->content) >= input_buffer->length) { + /* prevent buffer overflow when last input character is a backslash */ + goto fail; + } + skipped_bytes++; + input_end++; + } + input_end++; + } + if(((size_t)(input_end - input_buffer->content) >= input_buffer->length) || (*input_end != '\"')) { + goto fail; /* string ended unexpectedly */ + } + + /* This is at most how much we need for the output */ + allocation_length = (size_t)(input_end - buffer_at_offset(input_buffer)) - skipped_bytes; + output = (unsigned char *)input_buffer->hooks.allocate(allocation_length + sizeof("")); + if(output == NULL) { + goto fail; /* allocation failure */ + } + } + + output_pointer = output; + /* loop through the string literal */ + while(input_pointer < input_end) { + if(*input_pointer != '\\') { + *output_pointer++ = *input_pointer++; + } + /* escape sequence */ + else { + unsigned char sequence_length = 2; + if((input_end - input_pointer) < 1) { + goto fail; + } + + switch(input_pointer[1]) { + case 'b': + *output_pointer++ = '\b'; + break; + case 'f': + *output_pointer++ = '\f'; + break; + case 'n': + *output_pointer++ = '\n'; + break; + case 'r': + *output_pointer++ = '\r'; + break; + case 't': + *output_pointer++ = '\t'; + break; + case '\"': + case '\\': + case '/': + *output_pointer++ = input_pointer[1]; + break; + + /* UTF-16 literal */ + case 'u': + sequence_length = utf16_literal_to_utf8(input_pointer, input_end, &output_pointer); + if(sequence_length == 0) { + /* failed to convert UTF16-literal to UTF-8 */ + goto fail; + } + break; + + default: + goto fail; + } + input_pointer += sequence_length; + } + } + + /* zero terminate the output */ + *output_pointer = '\0'; + + item->type = cJSON_String; + item->valuestring = (char *)output; + + input_buffer->offset = (size_t)(input_end - input_buffer->content); + input_buffer->offset++; + + return true; + +fail: + if(output != NULL) { + input_buffer->hooks.deallocate(output); + } + + if(input_pointer != NULL) { + input_buffer->offset = (size_t)(input_pointer - input_buffer->content); + } + + return false; +} + +/* Render the cstring provided to an escaped version that can be printed. */ +static cJSON_bool print_string_ptr(const unsigned char *const input, printbuffer *const output_buffer) { + const unsigned char *input_pointer = NULL; + unsigned char *output = NULL; + unsigned char *output_pointer = NULL; + size_t output_length = 0; + /* numbers of additional characters needed for escaping */ + size_t escape_characters = 0; + + if(output_buffer == NULL) { + return false; + } + + /* empty string */ + if(input == NULL) { + output = ensure(output_buffer, sizeof("\"\"")); + if(output == NULL) { + return false; + } + strcpy((char *)output, "\"\""); + + return true; + } + + /* set "flag" to 1 if something needs to be escaped */ + for(input_pointer = input; *input_pointer; input_pointer++) { + switch(*input_pointer) { + case '\"': + case '\\': + case '\b': + case '\f': + case '\n': + case '\r': + case '\t': + /* one character escape sequence */ + escape_characters++; + break; + default: + if(*input_pointer < 32) { + /* UTF-16 escape sequence uXXXX */ + escape_characters += 5; + } + break; + } + } + output_length = (size_t)(input_pointer - input) + escape_characters; + + output = ensure(output_buffer, output_length + sizeof("\"\"")); + if(output == NULL) { + return false; + } + + /* no characters have to be escaped */ + if(escape_characters == 0) { + output[0] = '\"'; + memcpy(output + 1, input, output_length); + output[output_length + 1] = '\"'; + output[output_length + 2] = '\0'; + + return true; + } + + output[0] = '\"'; + output_pointer = output + 1; + /* copy the string */ + for(input_pointer = input; *input_pointer != '\0'; (void)input_pointer++, output_pointer++) { + if((*input_pointer > 31) && (*input_pointer != '\"') && (*input_pointer != '\\')) { + /* normal character, copy */ + *output_pointer = *input_pointer; + } + else { + /* character needs to be escaped */ + *output_pointer++ = '\\'; + switch(*input_pointer) { + case '\\': + *output_pointer = '\\'; + break; + case '\"': + *output_pointer = '\"'; + break; + case '\b': + *output_pointer = 'b'; + break; + case '\f': + *output_pointer = 'f'; + break; + case '\n': + *output_pointer = 'n'; + break; + case '\r': + *output_pointer = 'r'; + break; + case '\t': + *output_pointer = 't'; + break; + default: + /* escape and print as unicode codepoint */ + sprintf((char *)output_pointer, "u%04x", *input_pointer); + output_pointer += 4; + break; + } + } + } + output[output_length + 1] = '\"'; + output[output_length + 2] = '\0'; + + return true; +} + +/* Invoke print_string_ptr (which is useful) on an item. */ +static cJSON_bool print_string(const cJSON *const item, printbuffer *const p) { + return print_string_ptr((unsigned char *)item->valuestring, p); +} + +/* Predeclare these prototypes. */ +static cJSON_bool parse_value(cJSON *const item, parse_buffer *const input_buffer); +static cJSON_bool print_value(const cJSON *const item, printbuffer *const output_buffer); +static cJSON_bool parse_array(cJSON *const item, parse_buffer *const input_buffer); +static cJSON_bool print_array(const cJSON *const item, printbuffer *const output_buffer); +static cJSON_bool parse_object(cJSON *const item, parse_buffer *const input_buffer); +static cJSON_bool print_object(const cJSON *const item, printbuffer *const output_buffer); + +/* Utility to jump whitespace and cr/lf */ +static parse_buffer *buffer_skip_whitespace(parse_buffer *const buffer) { + if((buffer == NULL) || (buffer->content == NULL)) { + return NULL; + } + + if(cannot_access_at_index(buffer, 0)) { + return buffer; + } + + while(can_access_at_index(buffer, 0) && (buffer_at_offset(buffer)[0] <= 32)) { + buffer->offset++; + } + + if(buffer->offset == buffer->length) { + buffer->offset--; + } + + return buffer; +} + +/* skip the UTF-8 BOM (byte order mark) if it is at the beginning of a buffer */ +static parse_buffer *skip_utf8_bom(parse_buffer *const buffer) { + if((buffer == NULL) || (buffer->content == NULL) || (buffer->offset != 0)) { + return NULL; + } + + if(can_access_at_index(buffer, 4) && (strncmp((const char *)buffer_at_offset(buffer), "\xEF\xBB\xBF", 3) == 0)) { + buffer->offset += 3; + } + + return buffer; +} + +CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated) { + size_t buffer_length; + + if(NULL == value) { + return NULL; + } + + /* Adding null character size due to require_null_terminated. */ + buffer_length = strlen(value) + sizeof(""); + + return cJSON_ParseWithLengthOpts(value, buffer_length, return_parse_end, require_null_terminated); +} + +/* Parse an object - create a new root, and populate. */ +CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated) { + parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } }; + cJSON *item = NULL; + + /* reset error position */ + global_error.json = NULL; + global_error.position = 0; + + if(value == NULL || 0 == buffer_length) { + goto fail; + } + + buffer.content = (const unsigned char *)value; + buffer.length = buffer_length; + buffer.offset = 0; + buffer.hooks = global_hooks; + + item = cJSON_New_Item(&global_hooks); + if(item == NULL) /* memory fail */ + { + goto fail; + } + + if(!parse_value(item, buffer_skip_whitespace(skip_utf8_bom(&buffer)))) { + /* parse failure. ep is set. */ + goto fail; + } + + /* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */ + if(require_null_terminated) { + buffer_skip_whitespace(&buffer); + if((buffer.offset >= buffer.length) || buffer_at_offset(&buffer)[0] != '\0') { + goto fail; + } + } + if(return_parse_end) { + *return_parse_end = (const char *)buffer_at_offset(&buffer); + } + + return item; + +fail: + if(item != NULL) { + cJSON_Delete(item); + } + + if(value != NULL) { + error local_error; + local_error.json = (const unsigned char *)value; + local_error.position = 0; + + if(buffer.offset < buffer.length) { + local_error.position = buffer.offset; + } + else if(buffer.length > 0) { + local_error.position = buffer.length - 1; + } + + if(return_parse_end != NULL) { + *return_parse_end = (const char *)local_error.json + local_error.position; + } + + global_error = local_error; + } + + return NULL; +} + +/* Default options for cJSON_Parse */ +CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value) { + return cJSON_ParseWithOpts(value, 0, 0); +} + +CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length) { + return cJSON_ParseWithLengthOpts(value, buffer_length, 0, 0); +} + +#define cjson_min(a, b) (((a) < (b)) ? (a) : (b)) + +static unsigned char *print(const cJSON *const item, cJSON_bool format, const internal_hooks *const hooks) { + static const size_t default_buffer_size = 256; + printbuffer buffer[1]; + unsigned char *printed = NULL; + + memset(buffer, 0, sizeof(buffer)); + + /* create buffer */ + buffer->buffer = (unsigned char *)hooks->allocate(default_buffer_size); + buffer->length = default_buffer_size; + buffer->format = format; + buffer->hooks = *hooks; + if(buffer->buffer == NULL) { + goto fail; + } + + /* print the value */ + if(!print_value(item, buffer)) { + goto fail; + } + update_offset(buffer); + + /* check if reallocate is available */ + if(hooks->reallocate != NULL) { + printed = (unsigned char *)hooks->reallocate(buffer->buffer, buffer->offset + 1); + if(printed == NULL) { + goto fail; + } + buffer->buffer = NULL; + } + else /* otherwise copy the JSON over to a new buffer */ + { + printed = (unsigned char *)hooks->allocate(buffer->offset + 1); + if(printed == NULL) { + goto fail; + } + memcpy(printed, buffer->buffer, cjson_min(buffer->length, buffer->offset + 1)); + printed[buffer->offset] = '\0'; /* just to be sure */ + + /* free the buffer */ + hooks->deallocate(buffer->buffer); + } + + return printed; + +fail: + if(buffer->buffer != NULL) { + hooks->deallocate(buffer->buffer); + } + + if(printed != NULL) { + hooks->deallocate(printed); + } + + return NULL; +} + +/* Render a cJSON item/entity/structure to text. */ +CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item) { + return (char *)print(item, true, &global_hooks); +} + +CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item) { + return (char *)print(item, false, &global_hooks); +} + +CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt) { + printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }; + + if(prebuffer < 0) { + return NULL; + } + + p.buffer = (unsigned char *)global_hooks.allocate((size_t)prebuffer); + if(!p.buffer) { + return NULL; + } + + p.length = (size_t)prebuffer; + p.offset = 0; + p.noalloc = false; + p.format = fmt; + p.hooks = global_hooks; + + if(!print_value(item, &p)) { + global_hooks.deallocate(p.buffer); + return NULL; + } + + return (char *)p.buffer; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format) { + printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }; + + if((length < 0) || (buffer == NULL)) { + return false; + } + + p.buffer = (unsigned char *)buffer; + p.length = (size_t)length; + p.offset = 0; + p.noalloc = true; + p.format = format; + p.hooks = global_hooks; + + return print_value(item, &p); +} + +/* Parser core - when encountering text, process appropriately. */ +static cJSON_bool parse_value(cJSON *const item, parse_buffer *const input_buffer) { + if((input_buffer == NULL) || (input_buffer->content == NULL)) { + return false; /* no input */ + } + + /* parse the different types of values */ + /* null */ + if(can_read(input_buffer, 4) && (strncmp((const char *)buffer_at_offset(input_buffer), "null", 4) == 0)) { + item->type = cJSON_NULL; + input_buffer->offset += 4; + return true; + } + /* false */ + if(can_read(input_buffer, 5) && (strncmp((const char *)buffer_at_offset(input_buffer), "false", 5) == 0)) { + item->type = cJSON_False; + input_buffer->offset += 5; + return true; + } + /* true */ + if(can_read(input_buffer, 4) && (strncmp((const char *)buffer_at_offset(input_buffer), "true", 4) == 0)) { + item->type = cJSON_True; + item->valueint = 1; + input_buffer->offset += 4; + return true; + } + /* string */ + if(can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '\"')) { + return parse_string(item, input_buffer); + } + /* number */ + if(can_access_at_index(input_buffer, 0) + && ((buffer_at_offset(input_buffer)[0] == '-') || ((buffer_at_offset(input_buffer)[0] >= '0') && (buffer_at_offset(input_buffer)[0] <= '9')))) { + return parse_number(item, input_buffer); + } + /* array */ + if(can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '[')) { + return parse_array(item, input_buffer); + } + /* object */ + if(can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '{')) { + return parse_object(item, input_buffer); + } + + return false; +} + +/* Render a value to text. */ +static cJSON_bool print_value(const cJSON *const item, printbuffer *const output_buffer) { + unsigned char *output = NULL; + + if((item == NULL) || (output_buffer == NULL)) { + return false; + } + + switch((item->type) & 0xFF) { + case cJSON_NULL: + output = ensure(output_buffer, 5); + if(output == NULL) { + return false; + } + strcpy((char *)output, "null"); + return true; + + case cJSON_False: + output = ensure(output_buffer, 6); + if(output == NULL) { + return false; + } + strcpy((char *)output, "false"); + return true; + + case cJSON_True: + output = ensure(output_buffer, 5); + if(output == NULL) { + return false; + } + strcpy((char *)output, "true"); + return true; + + case cJSON_Number: + return print_number(item, output_buffer); + + case cJSON_Raw: { + size_t raw_length = 0; + if(item->valuestring == NULL) { + return false; + } + + raw_length = strlen(item->valuestring) + sizeof(""); + output = ensure(output_buffer, raw_length); + if(output == NULL) { + return false; + } + memcpy(output, item->valuestring, raw_length); + return true; + } + + case cJSON_String: + return print_string(item, output_buffer); + + case cJSON_Array: + return print_array(item, output_buffer); + + case cJSON_Object: + return print_object(item, output_buffer); + + default: + return false; + } +} + +/* Build an array from input text. */ +static cJSON_bool parse_array(cJSON *const item, parse_buffer *const input_buffer) { + cJSON *head = NULL; /* head of the linked list */ + cJSON *current_item = NULL; + + if(input_buffer->depth >= CJSON_NESTING_LIMIT) { + return false; /* to deeply nested */ + } + input_buffer->depth++; + + if(buffer_at_offset(input_buffer)[0] != '[') { + /* not an array */ + goto fail; + } + + input_buffer->offset++; + buffer_skip_whitespace(input_buffer); + if(can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ']')) { + /* empty array */ + goto success; + } + + /* check if we skipped to the end of the buffer */ + if(cannot_access_at_index(input_buffer, 0)) { + input_buffer->offset--; + goto fail; + } + + /* step back to character in front of the first element */ + input_buffer->offset--; + /* loop through the comma separated array elements */ + do { + /* allocate next item */ + cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks)); + if(new_item == NULL) { + goto fail; /* allocation failure */ + } + + /* attach next item to list */ + if(head == NULL) { + /* start the linked list */ + current_item = head = new_item; + } + else { + /* add to the end and advance */ + current_item->next = new_item; + new_item->prev = current_item; + current_item = new_item; + } + + /* parse next value */ + input_buffer->offset++; + buffer_skip_whitespace(input_buffer); + if(!parse_value(current_item, input_buffer)) { + goto fail; /* failed to parse value */ + } + buffer_skip_whitespace(input_buffer); + } while(can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ',')); + + if(cannot_access_at_index(input_buffer, 0) || buffer_at_offset(input_buffer)[0] != ']') { + goto fail; /* expected end of array */ + } + +success: + input_buffer->depth--; + + if(head != NULL) { + head->prev = current_item; + } + + item->type = cJSON_Array; + item->child = head; + + input_buffer->offset++; + + return true; + +fail: + if(head != NULL) { + cJSON_Delete(head); + } + + return false; +} + +/* Render an array to text */ +static cJSON_bool print_array(const cJSON *const item, printbuffer *const output_buffer) { + unsigned char *output_pointer = NULL; + size_t length = 0; + cJSON *current_element = item->child; + + if(output_buffer == NULL) { + return false; + } + + /* Compose the output array. */ + /* opening square bracket */ + output_pointer = ensure(output_buffer, 1); + if(output_pointer == NULL) { + return false; + } + + *output_pointer = '['; + output_buffer->offset++; + output_buffer->depth++; + + while(current_element != NULL) { + if(!print_value(current_element, output_buffer)) { + return false; + } + update_offset(output_buffer); + if(current_element->next) { + length = (size_t)(output_buffer->format ? 2 : 1); + output_pointer = ensure(output_buffer, length + 1); + if(output_pointer == NULL) { + return false; + } + *output_pointer++ = ','; + if(output_buffer->format) { + *output_pointer++ = ' '; + } + *output_pointer = '\0'; + output_buffer->offset += length; + } + current_element = current_element->next; + } + + output_pointer = ensure(output_buffer, 2); + if(output_pointer == NULL) { + return false; + } + *output_pointer++ = ']'; + *output_pointer = '\0'; + output_buffer->depth--; + + return true; +} + +/* Build an object from the text. */ +static cJSON_bool parse_object(cJSON *const item, parse_buffer *const input_buffer) { + cJSON *head = NULL; /* linked list head */ + cJSON *current_item = NULL; + + if(input_buffer->depth >= CJSON_NESTING_LIMIT) { + return false; /* to deeply nested */ + } + input_buffer->depth++; + + if(cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '{')) { + goto fail; /* not an object */ + } + + input_buffer->offset++; + buffer_skip_whitespace(input_buffer); + if(can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '}')) { + goto success; /* empty object */ + } + + /* check if we skipped to the end of the buffer */ + if(cannot_access_at_index(input_buffer, 0)) { + input_buffer->offset--; + goto fail; + } + + /* step back to character in front of the first element */ + input_buffer->offset--; + /* loop through the comma separated array elements */ + do { + /* allocate next item */ + cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks)); + if(new_item == NULL) { + goto fail; /* allocation failure */ + } + + /* attach next item to list */ + if(head == NULL) { + /* start the linked list */ + current_item = head = new_item; + } + else { + /* add to the end and advance */ + current_item->next = new_item; + new_item->prev = current_item; + current_item = new_item; + } + + /* parse the name of the child */ + input_buffer->offset++; + buffer_skip_whitespace(input_buffer); + if(!parse_string(current_item, input_buffer)) { + goto fail; /* failed to parse name */ + } + buffer_skip_whitespace(input_buffer); + + /* swap valuestring and string, because we parsed the name */ + current_item->string = current_item->valuestring; + current_item->valuestring = NULL; + + if(cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != ':')) { + goto fail; /* invalid object */ + } + + /* parse the value */ + input_buffer->offset++; + buffer_skip_whitespace(input_buffer); + if(!parse_value(current_item, input_buffer)) { + goto fail; /* failed to parse value */ + } + buffer_skip_whitespace(input_buffer); + } while(can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ',')); + + if(cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '}')) { + goto fail; /* expected end of object */ + } + +success: + input_buffer->depth--; + + if(head != NULL) { + head->prev = current_item; + } + + item->type = cJSON_Object; + item->child = head; + + input_buffer->offset++; + return true; + +fail: + if(head != NULL) { + cJSON_Delete(head); + } + + return false; +} + +/* Render an object to text. */ +static cJSON_bool print_object(const cJSON *const item, printbuffer *const output_buffer) { + unsigned char *output_pointer = NULL; + size_t length = 0; + cJSON *current_item = item->child; + + if(output_buffer == NULL) { + return false; + } + + /* Compose the output: */ + length = (size_t)(output_buffer->format ? 2 : 1); /* fmt: {\n */ + output_pointer = ensure(output_buffer, length + 1); + if(output_pointer == NULL) { + return false; + } + + *output_pointer++ = '{'; + output_buffer->depth++; + if(output_buffer->format) { + *output_pointer++ = '\n'; + } + output_buffer->offset += length; + + while(current_item) { + if(output_buffer->format) { + size_t i; + output_pointer = ensure(output_buffer, output_buffer->depth); + if(output_pointer == NULL) { + return false; + } + for(i = 0; i < output_buffer->depth; i++) { + *output_pointer++ = '\t'; + } + output_buffer->offset += output_buffer->depth; + } + + /* print key */ + if(!print_string_ptr((unsigned char *)current_item->string, output_buffer)) { + return false; + } + update_offset(output_buffer); + + length = (size_t)(output_buffer->format ? 2 : 1); + output_pointer = ensure(output_buffer, length); + if(output_pointer == NULL) { + return false; + } + *output_pointer++ = ':'; + if(output_buffer->format) { + *output_pointer++ = '\t'; + } + output_buffer->offset += length; + + /* print value */ + if(!print_value(current_item, output_buffer)) { + return false; + } + update_offset(output_buffer); + + /* print comma if not last */ + length = ((size_t)(output_buffer->format ? 1 : 0) + (size_t)(current_item->next ? 1 : 0)); + output_pointer = ensure(output_buffer, length + 1); + if(output_pointer == NULL) { + return false; + } + if(current_item->next) { + *output_pointer++ = ','; + } + + if(output_buffer->format) { + *output_pointer++ = '\n'; + } + *output_pointer = '\0'; + output_buffer->offset += length; + + current_item = current_item->next; + } + + output_pointer = ensure(output_buffer, output_buffer->format ? (output_buffer->depth + 1) : 2); + if(output_pointer == NULL) { + return false; + } + if(output_buffer->format) { + size_t i; + for(i = 0; i < (output_buffer->depth - 1); i++) { + *output_pointer++ = '\t'; + } + } + *output_pointer++ = '}'; + *output_pointer = '\0'; + output_buffer->depth--; + + return true; +} + +/* Get Array size/item / object item. */ +CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array) { + cJSON *child = NULL; + size_t size = 0; + + if(array == NULL) { + return 0; + } + + child = array->child; + + while(child != NULL) { + size++; + child = child->next; + } + + /* FIXME: Can overflow here. Cannot be fixed without breaking the API */ + + return (int)size; +} + +static cJSON *get_array_item(const cJSON *array, size_t index) { + cJSON *current_child = NULL; + + if(array == NULL) { + return NULL; + } + + current_child = array->child; + while((current_child != NULL) && (index > 0)) { + index--; + current_child = current_child->next; + } + + return current_child; +} + +CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index) { + if(index < 0) { + return NULL; + } + + return get_array_item(array, (size_t)index); +} + +static cJSON *get_object_item(const cJSON *const object, const char *const name, const cJSON_bool case_sensitive) { + cJSON *current_element = NULL; + + if((object == NULL) || (name == NULL)) { + return NULL; + } + + current_element = object->child; + if(case_sensitive) { + while((current_element != NULL) && (current_element->string != NULL) && (strcmp(name, current_element->string) != 0)) { + current_element = current_element->next; + } + } + else { + while((current_element != NULL) && (case_insensitive_strcmp((const unsigned char *)name, (const unsigned char *)(current_element->string)) != 0)) { + current_element = current_element->next; + } + } + + if((current_element == NULL) || (current_element->string == NULL)) { + return NULL; + } + + return current_element; +} + +CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON *const object, const char *const string) { + return get_object_item(object, string, false); +} + +CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON *const object, const char *const string) { + return get_object_item(object, string, true); +} + +CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string) { + return cJSON_GetObjectItem(object, string) ? 1 : 0; +} + +/* Utility for array list handling. */ +static void suffix_object(cJSON *prev, cJSON *item) { + prev->next = item; + item->prev = prev; +} + +/* Utility for handling references. */ +static cJSON *create_reference(const cJSON *item, const internal_hooks *const hooks) { + cJSON *reference = NULL; + if(item == NULL) { + return NULL; + } + + reference = cJSON_New_Item(hooks); + if(reference == NULL) { + return NULL; + } + + memcpy(reference, item, sizeof(cJSON)); + reference->string = NULL; + reference->type |= cJSON_IsReference; + reference->next = reference->prev = NULL; + return reference; +} + +static cJSON_bool add_item_to_array(cJSON *array, cJSON *item) { + cJSON *child = NULL; + + if((item == NULL) || (array == NULL) || (array == item)) { + return false; + } + + child = array->child; + /* + * To find the last item in array quickly, we use prev in array + */ + if(child == NULL) { + /* list is empty, start new one */ + array->child = item; + item->prev = item; + item->next = NULL; + } + else { + /* append to the end */ + if(child->prev) { + suffix_object(child->prev, item); + array->child->prev = item; + } + } + + return true; +} + +/* Add item to array/object. */ +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item) { + return add_item_to_array(array, item); +} + +#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)))) +#pragma GCC diagnostic push +#endif +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wcast-qual" +#endif +/* helper function to cast away const */ +static void *cast_away_const(const void *string) { + return (void *)string; +} +#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)))) +#pragma GCC diagnostic pop +#endif + +static cJSON_bool add_item_to_object(cJSON *const object, const char *const string, cJSON *const item, const internal_hooks *const hooks, + const cJSON_bool constant_key) { + char *new_key = NULL; + int new_type = cJSON_Invalid; + + if((object == NULL) || (string == NULL) || (item == NULL) || (object == item)) { + return false; + } + + if(constant_key) { + new_key = (char *)cast_away_const(string); + new_type = item->type | cJSON_StringIsConst; + } + else { + new_key = (char *)cJSON_strdup((const unsigned char *)string, hooks); + if(new_key == NULL) { + return false; + } + + new_type = item->type & ~cJSON_StringIsConst; + } + + if(!(item->type & cJSON_StringIsConst) && (item->string != NULL)) { + hooks->deallocate(item->string); + } + + item->string = new_key; + item->type = new_type; + + return add_item_to_array(object, item); +} + +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item) { + return add_item_to_object(object, string, item, &global_hooks, false); +} + +/* Add an item to an object with constant string as key */ +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item) { + return add_item_to_object(object, string, item, &global_hooks, true); +} + +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) { + if(array == NULL) { + return false; + } + + return add_item_to_array(array, create_reference(item, &global_hooks)); +} + +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item) { + if((object == NULL) || (string == NULL)) { + return false; + } + + return add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false); +} + +CJSON_PUBLIC(cJSON *) cJSON_AddNullToObject(cJSON *const object, const char *const name) { + cJSON *null = cJSON_CreateNull(); + if(add_item_to_object(object, name, null, &global_hooks, false)) { + return null; + } + + cJSON_Delete(null); + return NULL; +} + +CJSON_PUBLIC(cJSON *) cJSON_AddTrueToObject(cJSON *const object, const char *const name) { + cJSON *true_item = cJSON_CreateTrue(); + if(add_item_to_object(object, name, true_item, &global_hooks, false)) { + return true_item; + } + + cJSON_Delete(true_item); + return NULL; +} + +CJSON_PUBLIC(cJSON *) cJSON_AddFalseToObject(cJSON *const object, const char *const name) { + cJSON *false_item = cJSON_CreateFalse(); + if(add_item_to_object(object, name, false_item, &global_hooks, false)) { + return false_item; + } + + cJSON_Delete(false_item); + return NULL; +} + +CJSON_PUBLIC(cJSON *) cJSON_AddBoolToObject(cJSON *const object, const char *const name, const cJSON_bool boolean) { + cJSON *bool_item = cJSON_CreateBool(boolean); + if(add_item_to_object(object, name, bool_item, &global_hooks, false)) { + return bool_item; + } + + cJSON_Delete(bool_item); + return NULL; +} + +CJSON_PUBLIC(cJSON *) cJSON_AddNumberToObject(cJSON *const object, const char *const name, const double number) { + cJSON *number_item = cJSON_CreateNumber(number); + if(add_item_to_object(object, name, number_item, &global_hooks, false)) { + return number_item; + } + + cJSON_Delete(number_item); + return NULL; +} + +CJSON_PUBLIC(cJSON *) cJSON_AddStringToObject(cJSON *const object, const char *const name, const char *const string) { + cJSON *string_item = cJSON_CreateString(string); + if(add_item_to_object(object, name, string_item, &global_hooks, false)) { + return string_item; + } + + cJSON_Delete(string_item); + return NULL; +} + +CJSON_PUBLIC(cJSON *) cJSON_AddRawToObject(cJSON *const object, const char *const name, const char *const raw) { + cJSON *raw_item = cJSON_CreateRaw(raw); + if(add_item_to_object(object, name, raw_item, &global_hooks, false)) { + return raw_item; + } + + cJSON_Delete(raw_item); + return NULL; +} + +CJSON_PUBLIC(cJSON *) cJSON_AddObjectToObject(cJSON *const object, const char *const name) { + cJSON *object_item = cJSON_CreateObject(); + if(add_item_to_object(object, name, object_item, &global_hooks, false)) { + return object_item; + } + + cJSON_Delete(object_item); + return NULL; +} + +CJSON_PUBLIC(cJSON *) cJSON_AddArrayToObject(cJSON *const object, const char *const name) { + cJSON *array = cJSON_CreateArray(); + if(add_item_to_object(object, name, array, &global_hooks, false)) { + return array; + } + + cJSON_Delete(array); + return NULL; +} + +CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON *const item) { + if((parent == NULL) || (item == NULL)) { + return NULL; + } + + if(item != parent->child) { + /* not the first element */ + item->prev->next = item->next; + } + if(item->next != NULL) { + /* not the last element */ + item->next->prev = item->prev; + } + + if(item == parent->child) { + /* first element */ + parent->child = item->next; + } + else if(item->next == NULL) { + /* last element */ + parent->child->prev = item->prev; + } + + /* make sure the detached item doesn't point anywhere anymore */ + item->prev = NULL; + item->next = NULL; + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which) { + if(which < 0) { + return NULL; + } + + return cJSON_DetachItemViaPointer(array, get_array_item(array, (size_t)which)); +} + +CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which) { + cJSON_Delete(cJSON_DetachItemFromArray(array, which)); +} + +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string) { + cJSON *to_detach = cJSON_GetObjectItem(object, string); + + return cJSON_DetachItemViaPointer(object, to_detach); +} + +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string) { + cJSON *to_detach = cJSON_GetObjectItemCaseSensitive(object, string); + + return cJSON_DetachItemViaPointer(object, to_detach); +} + +CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string) { + cJSON_Delete(cJSON_DetachItemFromObject(object, string)); +} + +CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string) { + cJSON_Delete(cJSON_DetachItemFromObjectCaseSensitive(object, string)); +} + +/* Replace array/object items with new ones. */ +CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem) { + cJSON *after_inserted = NULL; + + if(which < 0) { + return false; + } + + after_inserted = get_array_item(array, (size_t)which); + if(after_inserted == NULL) { + return add_item_to_array(array, newitem); + } + + newitem->next = after_inserted; + newitem->prev = after_inserted->prev; + after_inserted->prev = newitem; + if(after_inserted == array->child) { + array->child = newitem; + } + else { + newitem->prev->next = newitem; + } + return true; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON *const parent, cJSON *const item, cJSON *replacement) { + if((parent == NULL) || (replacement == NULL) || (item == NULL)) { + return false; + } + + if(replacement == item) { + return true; + } + + replacement->next = item->next; + replacement->prev = item->prev; + + if(replacement->next != NULL) { + replacement->next->prev = replacement; + } + if(parent->child == item) { + if(parent->child->prev == parent->child) { + replacement->prev = replacement; + } + parent->child = replacement; + } + else { /* + * To find the last item in array quickly, we use prev in array. + * We can't modify the last item's next pointer where this item was the parent's child + */ + if(replacement->prev != NULL) { + replacement->prev->next = replacement; + } + if(replacement->next == NULL) { + parent->child->prev = replacement; + } + } + + item->next = NULL; + item->prev = NULL; + cJSON_Delete(item); + + return true; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem) { + if(which < 0) { + return false; + } + + return cJSON_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which), newitem); +} + +static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive) { + if((replacement == NULL) || (string == NULL)) { + return false; + } + + /* replace the name in the replacement */ + if(!(replacement->type & cJSON_StringIsConst) && (replacement->string != NULL)) { + cJSON_free(replacement->string); + } + replacement->string = (char *)cJSON_strdup((const unsigned char *)string, &global_hooks); + replacement->type &= ~cJSON_StringIsConst; + + return cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement); +} + +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem) { + return replace_item_in_object(object, string, newitem, false); +} + +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem) { + return replace_item_in_object(object, string, newitem, true); +} + +/* Create basic types: */ +CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void) { + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) { + item->type = cJSON_NULL; + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void) { + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) { + item->type = cJSON_True; + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void) { + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) { + item->type = cJSON_False; + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean) { + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) { + item->type = boolean ? cJSON_True : cJSON_False; + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num) { + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) { + item->type = cJSON_Number; + item->valuedouble = num; + + /* use saturation in case of overflow */ + if(num >= INT_MAX) { + item->valueint = INT_MAX; + } + else if(num <= (double)INT_MIN) { + item->valueint = INT_MIN; + } + else { + item->valueint = (int)num; + } + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string) { + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) { + item->type = cJSON_String; + item->valuestring = (char *)cJSON_strdup((const unsigned char *)string, &global_hooks); + if(!item->valuestring) { + cJSON_Delete(item); + return NULL; + } + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string) { + cJSON *item = cJSON_New_Item(&global_hooks); + if(item != NULL) { + item->type = cJSON_String | cJSON_IsReference; + item->valuestring = (char *)cast_away_const(string); + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child) { + cJSON *item = cJSON_New_Item(&global_hooks); + if(item != NULL) { + item->type = cJSON_Object | cJSON_IsReference; + item->child = (cJSON *)cast_away_const(child); + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child) { + cJSON *item = cJSON_New_Item(&global_hooks); + if(item != NULL) { + item->type = cJSON_Array | cJSON_IsReference; + item->child = (cJSON *)cast_away_const(child); + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw) { + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) { + item->type = cJSON_Raw; + item->valuestring = (char *)cJSON_strdup((const unsigned char *)raw, &global_hooks); + if(!item->valuestring) { + cJSON_Delete(item); + return NULL; + } + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void) { + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) { + item->type = cJSON_Array; + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void) { + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) { + item->type = cJSON_Object; + } + + return item; +} + +/* Create Arrays: */ +CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count) { + size_t i = 0; + cJSON *n = NULL; + cJSON *p = NULL; + cJSON *a = NULL; + + if((count < 0) || (numbers == NULL)) { + return NULL; + } + + a = cJSON_CreateArray(); + + for(i = 0; a && (i < (size_t)count); i++) { + n = cJSON_CreateNumber(numbers[i]); + if(!n) { + cJSON_Delete(a); + return NULL; + } + if(!i) { + a->child = n; + } + else { + suffix_object(p, n); + } + p = n; + } + + if(a && a->child) { + a->child->prev = n; + } + + return a; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count) { + size_t i = 0; + cJSON *n = NULL; + cJSON *p = NULL; + cJSON *a = NULL; + + if((count < 0) || (numbers == NULL)) { + return NULL; + } + + a = cJSON_CreateArray(); + + for(i = 0; a && (i < (size_t)count); i++) { + n = cJSON_CreateNumber((double)numbers[i]); + if(!n) { + cJSON_Delete(a); + return NULL; + } + if(!i) { + a->child = n; + } + else { + suffix_object(p, n); + } + p = n; + } + + if(a && a->child) { + a->child->prev = n; + } + + return a; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count) { + size_t i = 0; + cJSON *n = NULL; + cJSON *p = NULL; + cJSON *a = NULL; + + if((count < 0) || (numbers == NULL)) { + return NULL; + } + + a = cJSON_CreateArray(); + + for(i = 0; a && (i < (size_t)count); i++) { + n = cJSON_CreateNumber(numbers[i]); + if(!n) { + cJSON_Delete(a); + return NULL; + } + if(!i) { + a->child = n; + } + else { + suffix_object(p, n); + } + p = n; + } + + if(a && a->child) { + a->child->prev = n; + } + + return a; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count) { + size_t i = 0; + cJSON *n = NULL; + cJSON *p = NULL; + cJSON *a = NULL; + + if((count < 0) || (strings == NULL)) { + return NULL; + } + + a = cJSON_CreateArray(); + + for(i = 0; a && (i < (size_t)count); i++) { + n = cJSON_CreateString(strings[i]); + if(!n) { + cJSON_Delete(a); + return NULL; + } + if(!i) { + a->child = n; + } + else { + suffix_object(p, n); + } + p = n; + } + + if(a && a->child) { + a->child->prev = n; + } + + return a; +} + +/* Duplication */ +CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse) { + cJSON *newitem = NULL; + cJSON *child = NULL; + cJSON *next = NULL; + cJSON *newchild = NULL; + + /* Bail on bad ptr */ + if(!item) { + goto fail; + } + /* Create new item */ + newitem = cJSON_New_Item(&global_hooks); + if(!newitem) { + goto fail; + } + /* Copy over all vars */ + newitem->type = item->type & (~cJSON_IsReference); + newitem->valueint = item->valueint; + newitem->valuedouble = item->valuedouble; + if(item->valuestring) { + newitem->valuestring = (char *)cJSON_strdup((unsigned char *)item->valuestring, &global_hooks); + if(!newitem->valuestring) { + goto fail; + } + } + if(item->string) { + newitem->string = (item->type & cJSON_StringIsConst) ? item->string : (char *)cJSON_strdup((unsigned char *)item->string, &global_hooks); + if(!newitem->string) { + goto fail; + } + } + /* If non-recursive, then we're done! */ + if(!recurse) { + return newitem; + } + /* Walk the ->next chain for the child. */ + child = item->child; + while(child != NULL) { + newchild = cJSON_Duplicate(child, true); /* Duplicate (with recurse) each item in the ->next chain */ + if(!newchild) { + goto fail; + } + if(next != NULL) { + /* If newitem->child already set, then crosswire ->prev and ->next and move on */ + next->next = newchild; + newchild->prev = next; + next = newchild; + } + else { + /* Set newitem->child and move to it */ + newitem->child = newchild; + next = newchild; + } + child = child->next; + } + if(newitem && newitem->child) { + newitem->child->prev = newchild; + } + + return newitem; + +fail: + if(newitem != NULL) { + cJSON_Delete(newitem); + } + + return NULL; +} + +static void skip_oneline_comment(char **input) { + *input += static_strlen("//"); + + for(; (*input)[0] != '\0'; ++(*input)) { + if((*input)[0] == '\n') { + *input += static_strlen("\n"); + return; + } + } +} + +static void skip_multiline_comment(char **input) { + *input += static_strlen("/*"); + + for(; (*input)[0] != '\0'; ++(*input)) { + if(((*input)[0] == '*') && ((*input)[1] == '/')) { + *input += static_strlen("*/"); + return; + } + } +} + +static void minify_string(char **input, char **output) { + (*output)[0] = (*input)[0]; + *input += static_strlen("\""); + *output += static_strlen("\""); + + for(; (*input)[0] != '\0'; (void)++(*input), ++(*output)) { + (*output)[0] = (*input)[0]; + + if((*input)[0] == '\"') { + (*output)[0] = '\"'; + *input += static_strlen("\""); + *output += static_strlen("\""); + return; + } + else if(((*input)[0] == '\\') && ((*input)[1] == '\"')) { + (*output)[1] = (*input)[1]; + *input += static_strlen("\""); + *output += static_strlen("\""); + } + } +} + +CJSON_PUBLIC(void) cJSON_Minify(char *json) { + char *into = json; + + if(json == NULL) { + return; + } + + while(json[0] != '\0') { + switch(json[0]) { + case ' ': + case '\t': + case '\r': + case '\n': + json++; + break; + + case '/': + if(json[1] == '/') { + skip_oneline_comment(&json); + } + else if(json[1] == '*') { + skip_multiline_comment(&json); + } + else { + json++; + } + break; + + case '\"': + minify_string(&json, (char **)&into); + break; + + default: + into[0] = json[0]; + json++; + into++; + } + } + + /* and null-terminate. */ + *into = '\0'; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON *const item) { + if(item == NULL) { + return false; + } + + return (item->type & 0xFF) == cJSON_Invalid; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON *const item) { + if(item == NULL) { + return false; + } + + return (item->type & 0xFF) == cJSON_False; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON *const item) { + if(item == NULL) { + return false; + } + + return (item->type & 0xff) == cJSON_True; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON *const item) { + if(item == NULL) { + return false; + } + + return (item->type & (cJSON_True | cJSON_False)) != 0; +} +CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON *const item) { + if(item == NULL) { + return false; + } + + return (item->type & 0xFF) == cJSON_NULL; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON *const item) { + if(item == NULL) { + return false; + } + + return (item->type & 0xFF) == cJSON_Number; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON *const item) { + if(item == NULL) { + return false; + } + + return (item->type & 0xFF) == cJSON_String; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON *const item) { + if(item == NULL) { + return false; + } + + return (item->type & 0xFF) == cJSON_Array; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON *const item) { + if(item == NULL) { + return false; + } + + return (item->type & 0xFF) == cJSON_Object; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON *const item) { + if(item == NULL) { + return false; + } + + return (item->type & 0xFF) == cJSON_Raw; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON *const a, const cJSON *const b, const cJSON_bool case_sensitive) { + if((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF))) { + return false; + } + + /* check if type is valid */ + switch(a->type & 0xFF) { + case cJSON_False: + case cJSON_True: + case cJSON_NULL: + case cJSON_Number: + case cJSON_String: + case cJSON_Raw: + case cJSON_Array: + case cJSON_Object: + break; + + default: + return false; + } + + /* identical objects are equal */ + if(a == b) { + return true; + } + + switch(a->type & 0xFF) { + /* in these cases and equal type is enough */ + case cJSON_False: + case cJSON_True: + case cJSON_NULL: + return true; + + case cJSON_Number: + if(compare_double(a->valuedouble, b->valuedouble)) { + return true; + } + return false; + + case cJSON_String: + case cJSON_Raw: + if((a->valuestring == NULL) || (b->valuestring == NULL)) { + return false; + } + if(strcmp(a->valuestring, b->valuestring) == 0) { + return true; + } + + return false; + + case cJSON_Array: { + cJSON *a_element = a->child; + cJSON *b_element = b->child; + + for(; (a_element != NULL) && (b_element != NULL);) { + if(!cJSON_Compare(a_element, b_element, case_sensitive)) { + return false; + } + + a_element = a_element->next; + b_element = b_element->next; + } + + /* one of the arrays is longer than the other */ + if(a_element != b_element) { + return false; + } + + return true; + } + + case cJSON_Object: { + cJSON *a_element = NULL; + cJSON *b_element = NULL; + cJSON_ArrayForEach(a_element, a) { + /* TODO This has O(n^2) runtime, which is horrible! */ + b_element = get_object_item(b, a_element->string, case_sensitive); + if(b_element == NULL) { + return false; + } + + if(!cJSON_Compare(a_element, b_element, case_sensitive)) { + return false; + } + } + + /* doing this twice, once on a and b to prevent true comparison if a subset of b + * TODO: Do this the proper way, this is just a fix for now */ + cJSON_ArrayForEach(b_element, b) { + a_element = get_object_item(a, b_element->string, case_sensitive); + if(a_element == NULL) { + return false; + } + + if(!cJSON_Compare(b_element, a_element, case_sensitive)) { + return false; + } + } + + return true; + } + + default: + return false; + } +} + +CJSON_PUBLIC(void *) cJSON_malloc(size_t size) { + return global_hooks.allocate(size); +} + +CJSON_PUBLIC(void) cJSON_free(void *object) { + global_hooks.deallocate(object); +} + diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync/utils/cJSON.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync/utils/cJSON.h new file mode 100644 index 0000000..f4a6db5 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync/utils/cJSON.h @@ -0,0 +1,298 @@ +/* + Copyright (c) 2009-2017 Dave Gamble and cJSON contributors + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#ifndef cJSON__h +#define cJSON__h + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32)) +#define __WINDOWS__ +#endif + +#ifdef __WINDOWS__ + +/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default +calling convention. For windows you have 3 define options: + +CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols +CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default) +CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol + +For *nix builds that support visibility attribute, you can define similar behavior by + +setting default visibility to hidden by adding +-fvisibility=hidden (for gcc) +or +-xldscope=hidden (for sun cc) +to CFLAGS + +then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does + +*/ + +#define CJSON_CDECL __cdecl +#define CJSON_STDCALL __stdcall + +/* export symbols by default, this is necessary for copy pasting the C and header file */ +#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS) +#define CJSON_EXPORT_SYMBOLS +#endif + +#if defined(CJSON_HIDE_SYMBOLS) +#define CJSON_PUBLIC(type) type CJSON_STDCALL +#elif defined(CJSON_EXPORT_SYMBOLS) +#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL +#elif defined(CJSON_IMPORT_SYMBOLS) +#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL +#endif +#else /* !__WINDOWS__ */ +#define CJSON_CDECL +#define CJSON_STDCALL + +#if(defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(CJSON_API_VISIBILITY) +#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type +#else +#define CJSON_PUBLIC(type) type +#endif +#endif + +/* project version */ +#define CJSON_VERSION_MAJOR 1 +#define CJSON_VERSION_MINOR 7 +#define CJSON_VERSION_PATCH 15 + +#include + +/* cJSON Types: */ +#define cJSON_Invalid (0) +#define cJSON_False (1 << 0) +#define cJSON_True (1 << 1) +#define cJSON_NULL (1 << 2) +#define cJSON_Number (1 << 3) +#define cJSON_String (1 << 4) +#define cJSON_Array (1 << 5) +#define cJSON_Object (1 << 6) +#define cJSON_Raw (1 << 7) /* raw json */ + +#define cJSON_IsReference 256 +#define cJSON_StringIsConst 512 + +/* The cJSON structure: */ +typedef struct cJSON { + /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */ + struct cJSON *next; + struct cJSON *prev; + /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */ + struct cJSON *child; + + /* The type of the item, as above. */ + int type; + + /* The item's string, if type==cJSON_String and type == cJSON_Raw */ + char *valuestring; + /* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */ + int valueint; + /* The item's number, if type==cJSON_Number */ + double valuedouble; + + /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */ + char *string; +} cJSON; + +typedef struct cJSON_Hooks { + /* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions + * directly. */ + void *(CJSON_CDECL *malloc_fn)(size_t sz); + void(CJSON_CDECL *free_fn)(void *ptr); +} cJSON_Hooks; + +typedef int cJSON_bool; + +/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them. + * This is to prevent stack overflows. */ +#ifndef CJSON_NESTING_LIMIT +#define CJSON_NESTING_LIMIT 1000 +#endif + +/* returns the version of cJSON as a string */ +CJSON_PUBLIC(const char *) cJSON_Version(void); + +/* Supply malloc, realloc and free functions to cJSON */ +CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks *hooks); + +/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib + * free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. + */ +/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */ +CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value); +CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length); +/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */ +/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */ +CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated); +CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated); + +/* Render a cJSON entity to text for transfer/storage. */ +CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item); +/* Render a cJSON entity to text for transfer/storage without any formatting. */ +CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item); +/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, + * =1 gives formatted */ +CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt); +/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */ +/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */ +CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format); +/* Delete a cJSON entity and all subentities. */ +CJSON_PUBLIC(void) cJSON_Delete(cJSON *item); + +/* Returns the number of items in an array (or object). */ +CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array); +/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */ +CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index); +/* Get item "string" from object. Case insensitive. */ +CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON *const object, const char *const string); +CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON *const object, const char *const string); +CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string); +/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when + * cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */ +CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void); + +/* Check item type and return its value */ +CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON *const item); +CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON *const item); + +/* These functions check the type of an item */ +CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON *const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON *const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON *const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON *const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON *const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON *const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON *const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON *const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON *const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON *const item); + +/* These calls create a cJSON item of the appropriate type. */ +CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void); +CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void); +CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void); +CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean); +CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num); +CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string); +/* raw json */ +CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw); +CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void); +CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void); + +/* Create a string where valuestring references a string so + * it will not be freed by cJSON_Delete */ +CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string); +/* Create an object/array that only references it's elements so + * they will not be freed by cJSON_Delete */ +CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child); +CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child); + +/* These utilities create an Array of count items. + * The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.*/ +CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count); +CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count); +CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count); +CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count); + +/* Append item to the specified array/object. */ +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item); +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item); +/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object. + * WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before + * writing to `item->string` */ +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item); +/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your + * existing cJSON. */ +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); +CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item); + +/* Remove/Detach items from Arrays/Objects. */ +CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON *const item); +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which); +CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which); +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string); +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string); +CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string); +CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string); + +/* Update array items. */ +CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */ +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON *const parent, cJSON *const item, cJSON *replacement); +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem); +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem); +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem); + +/* Duplicate a cJSON item */ +CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse); +/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will + * need to be released. With recurse!=0, it will duplicate any children connected to the item. + * The item->next and ->prev pointers are always zero on return from Duplicate. */ +/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal. + * case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */ +CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON *const a, const cJSON *const b, const cJSON_bool case_sensitive); + +/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings. + * The input pointer json cannot point to a read-only address area, such as a string constant, + * but should point to a readable and writable address area. */ +CJSON_PUBLIC(void) cJSON_Minify(char *json); + +/* Helper functions for creating and adding items to an object at the same time. + * They return the added item or NULL on failure. */ +CJSON_PUBLIC(cJSON *) cJSON_AddNullToObject(cJSON *const object, const char *const name); +CJSON_PUBLIC(cJSON *) cJSON_AddTrueToObject(cJSON *const object, const char *const name); +CJSON_PUBLIC(cJSON *) cJSON_AddFalseToObject(cJSON *const object, const char *const name); +CJSON_PUBLIC(cJSON *) cJSON_AddBoolToObject(cJSON *const object, const char *const name, const cJSON_bool boolean); +CJSON_PUBLIC(cJSON *) cJSON_AddNumberToObject(cJSON *const object, const char *const name, const double number); +CJSON_PUBLIC(cJSON *) cJSON_AddStringToObject(cJSON *const object, const char *const name, const char *const string); +CJSON_PUBLIC(cJSON *) cJSON_AddRawToObject(cJSON *const object, const char *const name, const char *const raw); +CJSON_PUBLIC(cJSON *) cJSON_AddObjectToObject(cJSON *const object, const char *const name); +CJSON_PUBLIC(cJSON *) cJSON_AddArrayToObject(cJSON *const object, const char *const name); + +/* When assigning an integer value, it needs to be propagated to valuedouble too. */ +#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number)) +/* helper for the cJSON_SetNumberValue macro */ +CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number); +#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number)) +/* Change the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String */ +CJSON_PUBLIC(char *) cJSON_SetValuestring(cJSON *object, const char *valuestring); + +/* Macro for iterating over an array or object */ +#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next) + +/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */ +CJSON_PUBLIC(void *) cJSON_malloc(size_t size); +CJSON_PUBLIC(void) cJSON_free(void *object); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync_gmsltrigger/CMakeLists.txt b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync_gmsltrigger/CMakeLists.txt new file mode 100644 index 0000000..81662b2 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync_gmsltrigger/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) Orbbec Inc. All Rights Reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.5) +project(ob_multi_devices_sync_gmsltrigger) + +add_executable(${PROJECT_NAME} ob_multi_devices_sync_gmsltrigger.cpp) + +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} ob::OrbbecSDK ob::examples::utils) + +set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") +if(MSVC) + set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") +endif() + +install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) + diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync_gmsltrigger/README.md b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync_gmsltrigger/README.md new file mode 100644 index 0000000..5728886 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync_gmsltrigger/README.md @@ -0,0 +1,114 @@ +# C++ Sample: 3.advanced.multi_devices_sync_gmsltrigger + +## Overview + +GMSL Multi-device Hardware Trigger Configuration + +support Connection of GMSL device (Nvidia Xavier/Orin platform) + +### Knowledge + +Send a hardware synchronization signal with a set frequency to all connected GMSL devices for multi-machine hardware synchronization through the /dev/camsync device node. + +## Code overview + +1.open /dev/camsync device. + +2.set trigger frequency + +```cpp + int startTrigger(uint16_t triggerFps) { + if(!isDeviceOpen) { + if(openDevice() < 0) { + error("open device Failed!"); + return -1; + } + } + cs_param_t wt_param = { WRITE_MODE, triggerFps }; + int ret = writeTriggerParam(wt_param); + if(ret < 0) { + error("write trigger parameter Failed!"); + return ret; + } + info("write param: ", wt_param); + + cs_param_t rd_param = { READ_MODE, 0 }; + ret = readTriggerParam(rd_param); + if(ret < 0) { + error("read trigger parameter Failed!"); + } + info("read param: ", rd_param); + + return ret; + } +``` + +## Run Sample + +### 1.**Setup of Trigger Source and Device Node Permissions** + +``` +sudo chmod 777 /dev/camsync +``` + +### 2.**Running Configuration and Triggering Program** + +The program is located in the Example/bin directory of the orbbecsdk. + +Sample Configuration: 30FPS and Trigger Source Frequency of 3000 + +``` +orbbec@agx:~/SensorSDK/build/install/Example/bin$ ./MultiDeviceSyncGmslTrigger +Please select options: +------------------------------------------------------------ + 0 --> config GMSL SOC hardware trigger Source. Set trigger fps: + 1 --> start Trigger + 2 --> stop Trigger + 3 --> exit +------------------------------------------------------------ +input select item: 0 + +Enter FPS (frames per second) (for example: 3000): 3000 +Setting FPS to 3000... +Please select options: +------------------------------------------------------------ + 0 --> config GMSL SOC hardware trigger Source. Set trigger fps: + 1 --> start Trigger + 2 --> stop Trigger + 3 --> exit +------------------------------------------------------------ +input select item: 1 + +write param: mode=1, fps=3000 +read param: mode=1, fps=3000 +start pwm source TriggerSync... + +Please select options: +------------------------------------------------------------ + 0 --> config GMSL SOC hardware trigger Source. Set trigger fps: + 1 --> start Trigger + 2 --> stop Trigger + 3 --> exit +------------------------------------------------------------ +input select item: + +``` + +**Brief description of configuring the trigger program** + +Please select options: + + 0 --> config GMSL SOC hardware trigger Source. Set trigger fps: + 1 --> start Trigger + 2 --> stop Trigger + 3 --> exit + +0: Configure the frequency of the SOC hardware trigger source. + +(config trigger frequency as 3000 (Note: It is recommended to configure the trigger frequency to be equal to or less than the set video frame frequency. For example, if the set video frame frequency is 30FPS, the trigger frequency should be 3000 or less.) + +1: Start hardware tigger. (start send hardware signal triggering at the configured trigger frequency) + +2: Stop triggering + +3: Exit the program diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync_gmsltrigger/ob_multi_devices_sync_gmsltrigger.cpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync_gmsltrigger/ob_multi_devices_sync_gmsltrigger.cpp new file mode 100644 index 0000000..4d32812 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync_gmsltrigger/ob_multi_devices_sync_gmsltrigger.cpp @@ -0,0 +1,167 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/* +Notes: MultiDeviceSyncGmslSocTrigger for GMSL device +on the nvidia arm64 xavier/orin platform ,this sample use nvidia platform soc pwm trigger to sync multi device. +*/ +#ifdef __linux__ +#include +#include +#include +#include +#include + +static const char * DEVICE_PATH = "/dev/camsync"; +static const uint8_t WRITE_MODE = 1; +static const uint8_t READ_MODE = 0; + +typedef struct { + uint8_t mode; + uint16_t fps; +} cs_param_t; + +class PwmTrigger { +public: + PwmTrigger() : fd(-1), isDeviceOpen(false) {} + ~PwmTrigger() { + closeDevice(); + } + int startTrigger(uint16_t triggerFps) { + if(!isDeviceOpen) { + if(openDevice() < 0) { + error("open device Failed!"); + return -1; + } + } + cs_param_t wt_param = { WRITE_MODE, triggerFps }; + int ret = writeTriggerParam(wt_param); + if(ret < 0) { + error("write trigger parameter Failed!"); + return ret; + } + info("write param: ", wt_param); + + cs_param_t rd_param = { READ_MODE, 0 }; + ret = readTriggerParam(rd_param); + if(ret < 0) { + error("read trigger parameter Failed!"); + } + info("read param: ", rd_param); + + return ret; + } + + int stopTrigger() { + int ret = 0; + if(isDeviceOpen) { + ret = closeDevice(); + } + return ret; + } + + void info(const std::string &msg, const cs_param_t ¶m) { + std::cout << msg << " mode=" << static_cast(param.mode) << ", fps=" << param.fps << std::endl; + } + void error(const std::string &msg) { + std::cerr << "Error: " << msg << std::endl; + } + +private: + int openDevice() { + fd = open(DEVICE_PATH, O_RDWR); + if(fd < 0) { + error("open /dev/camsync failed"); + return fd; + } + isDeviceOpen = true; + return fd; + } + int closeDevice() { + if(isDeviceOpen) { + isDeviceOpen = false; + int ret = close(fd); + fd = -1; + if(ret < 0) { + error("close /dev/camsync failed: " + std::to_string(errno)); + return ret; + } + } + return 0; + } + int writeTriggerParam(const cs_param_t ¶m) { + int ret = write(fd, ¶m, sizeof(param)); + if(ret < 0) { + error("write /dev/camsync failed: " + std::to_string(errno)); + } + return ret; + } + int readTriggerParam(cs_param_t ¶m) { + int ret = read(fd, ¶m, sizeof(param)); + if(ret < 0) { + error("read /dev/camsync failed: " + std::to_string(errno)); + } + return ret; + } + +private: + int fd; + bool isDeviceOpen; +}; + +int main(void) try { + PwmTrigger pwmTrigger; + uint16_t fps = 0; + constexpr std::streamsize maxInputIgnore = 10000; + while(true) { + std::cout << "Please select options: \n" + << "------------------------------------------------------------\n" + << " 0 --> config GMSL SOC PWM trigger Source. Set trigger fps: \n" + << " 1 --> start Trigger \n" + << " 2 --> stop Trigger \n" + << " 3 --> exit \n" + << "------------------------------------------------------------\n" + << "input select item: "; + int index = -1; + // std::cin >> index; + if(!(std::cin >> index)) { + std::cin.clear(); + std::cin.ignore(maxInputIgnore, '\n'); + std::cout << "Invalid input. Please enter a number." << std::endl; + continue; + } + std::cout << std::endl; + + switch(index) { + case 0: + std::cout << "Enter FPS (frames per second) (for example: 3000): "; + std::cin >> fps; // set the FPS here + std::cout << "Setting FPS to " << fps << "..." << std::endl; + break; + case 1: + if(pwmTrigger.startTrigger(fps) < 0) { + std::cerr << "Failed to start trigger." << std::endl; + } + std::cout << "start pwm source TriggerSync... \n" << std::endl; + break; + case 2: + pwmTrigger.stopTrigger(); + std::cout << "stop pwm source TriggerSync... \n" << std::endl; + break; + case 3: + pwmTrigger.stopTrigger(); + std::cout << "Program exit & clse device! \n" << std::endl; + return 0; + default: + std::cout << "-input Invalid index. \n" + << "-Please re-select and input valid param. \n"; + } + } + return 0; +} +catch(ob::Error &e) { + std::cerr << "function:" << e.getFunction() << "\nargs:" << e.getArgs() << "\nmessage:" << e.what() << "\ntype:" << e.getExceptionType() << std::endl; + exit(EXIT_FAILURE); +} + +#endif diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/CMakeLists.txt b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/CMakeLists.txt new file mode 100644 index 0000000..e16783a --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright (c) Orbbec Inc. All Rights Reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.5) + +file(GLOB subdirectories RELATIVE ${CMAKE_CURRENT_LIST_DIR} "*") + +# dependecies +find_package(OpenCV QUIET) +if(NOT ${OpenCV_FOUND}) + message(WARNING "OpenCV not found, some examples may not be built. Please install OpenCV or set OpenCV_DIR to the directory of your OpenCV installation.") +endif() + +# utils +add_subdirectory(utils) + +# cpp examples +add_subdirectory(3.advanced.multi_devices_sync) +add_subdirectory(3.advanced.multi_devices_sync_gmsltrigger) +add_subdirectory(0.basic.enumerate) + +# InstallRequiredSystemLibraries +include(InstallRequiredSystemLibraries) diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/CMakeLists.txt b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/CMakeLists.txt new file mode 100644 index 0000000..67791ce --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/CMakeLists.txt @@ -0,0 +1,29 @@ +# Copyright (c) Orbbec Inc. All Rights Reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.5) +project(ob_examples_utils) + +add_library(ob_examples_utils STATIC + ${CMAKE_CURRENT_LIST_DIR}/utils_c.c + ${CMAKE_CURRENT_LIST_DIR}/utils_c.h + ${CMAKE_CURRENT_LIST_DIR}/utils.cpp + ${CMAKE_CURRENT_LIST_DIR}/utils.hpp +) + +if(${OpenCV_FOUND}) + target_sources(ob_examples_utils PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/utils_opencv.cpp + ${CMAKE_CURRENT_LIST_DIR}/utils_opencv.hpp + ) + target_link_libraries(ob_examples_utils PUBLIC ${OpenCV_LIBS} ob::OrbbecSDK) + target_include_directories(ob_examples_utils PUBLIC ${OpenCV_INCLUDE_DIRS}) +endif() + +find_package(Threads REQUIRED) +target_link_libraries(ob_examples_utils PUBLIC Threads::Threads) + +target_include_directories(ob_examples_utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +add_library(ob::examples::utils ALIAS ob_examples_utils) +set_target_properties(ob_examples_utils PROPERTIES FOLDER "examples") diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils.cpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils.cpp new file mode 100644 index 0000000..618c648 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils.cpp @@ -0,0 +1,87 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +#include "utils.hpp" +#include "utils_c.h" + +#include + +namespace ob_smpl { +char waitForKeyPressed(uint32_t timeout_ms) { + return ob_smpl_wait_for_key_press(timeout_ms); +} + +uint64_t getNowTimesMs() { + return std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); +} + +int getInputOption() { + char inputOption = ob_smpl::waitForKeyPressed(); + if(inputOption == ESC_KEY) { + return -1; + } + return inputOption - '0'; +} + +std::string getFormatTimestamp() { + auto currentTime = std::chrono::system_clock::now(); + auto time_t_time = std::chrono::system_clock::to_time_t(currentTime); + std::tm tm; +#if defined(_WIN32) || defined(_WIN64) + localtime_s(&tm, &time_t_time); +#else + localtime_r(&time_t_time, &tm); +#endif + + std::stringstream ss; + ss << std::put_time(&tm, "%Y%m%d%H%M%S"); + return ss.str(); +} + +int mkDirs(const char *muldir) { + size_t i; + size_t len; + char str[512]; + int error = 0; +#ifdef _WIN32 + strncpy_s(str, muldir, 512); + len = strlen(str); + for(i = 0; i < len; i++) { + if(str[i] == '/' || str[i] == '\\') { + str[i] = '\0'; + if(_access(str, 0) != 0) { + error = _mkdir(str); + if(error != 0) { + return error; + } + } + str[i] = '/'; + } + } + if(len > 0 && _access(str, 0) != 0) { + error = _mkdir(str); + } + return error; +#else + strncpy(str, muldir, 512); + len = strlen(str); + umask(0000); + for(i = 0; i < len; i++) { + if(i > 0 && str[i] == '/') { + str[i] = '\0'; + if(access(str, 0) != 0) { + error = mkdir(str, 0777); + if(error != 0) { + return error; + } + } + str[i] = '/'; + } + } + if(len > 0 && access(str, 0) != 0) { + error = mkdir(str, 0777); + } + return error; +#endif +} +} // namespace ob_smpl diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils.hpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils.hpp new file mode 100644 index 0000000..e06c3bc --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils.hpp @@ -0,0 +1,39 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +#pragma once +#include +#include "utils_types.h" + +#include +#include +#include +#include + +#ifdef _WIN32 +#include +#include +#else +#include +#include +#include +#endif + +namespace ob_smpl { +char waitForKeyPressed(uint32_t timeout_ms = 0); + +uint64_t getNowTimesMs(); + +int getInputOption(); + +template std::string toString(const T a_value, const int n = 6) { + std::ostringstream out; + out.precision(n); + out << std::fixed << a_value; + return std::move(out).str(); +} + +std::string getFormatTimestamp(); + +int mkDirs(const char *muldir); +} // namespace ob_smpl diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils_c.c b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils_c.c new file mode 100644 index 0000000..fcfec6f --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils_c.c @@ -0,0 +1,138 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +#include "utils_c.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__linux__) || defined(__APPLE__) +#ifdef __linux__ +#include +#else +#include +#endif +#include +#include +#include +#include + +#define gets_s gets + +int getch(void) { + struct termios tm, tm_old; + int fd = 0, ch; + + if(tcgetattr(fd, &tm) < 0) { // Save the current terminal settings + return -1; + } + + tm_old = tm; + cfmakeraw(&tm); // Change the terminal settings to raw mode, in which all input data is processed in bytes + if(tcsetattr(fd, TCSANOW, &tm) < 0) { // Settings after changes on settings + return -1; + } + + ch = getchar(); + if(tcsetattr(fd, TCSANOW, &tm_old) < 0) { // Change the settings to what they were originally + return -1; + } + + return ch; +} + +int kbhit(void) { + struct termios oldt, newt; + int ch; + int oldf; + tcgetattr(STDIN_FILENO, &oldt); + newt = oldt; + newt.c_lflag &= ~(ICANON | ECHO); + tcsetattr(STDIN_FILENO, TCSANOW, &newt); + oldf = fcntl(STDIN_FILENO, F_GETFL, 0); + fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK); + ch = getchar(); + tcsetattr(STDIN_FILENO, TCSANOW, &oldt); + fcntl(STDIN_FILENO, F_SETFL, oldf); + if(ch != EOF) { + ungetc(ch, stdin); + return 1; + } + return 0; +} + +#include +uint64_t ob_smpl_get_current_timestamp_ms() { + struct timeval te; + gettimeofday(&te, NULL); // Get the current time + long long milliseconds = te.tv_sec * 1000LL + te.tv_usec / 1000; // Calculate milliseconds + return milliseconds; +} + +char ob_smpl_wait_for_key_press(uint32_t timeout_ms) { // Get the current time + struct timeval te; + gettimeofday(&te, NULL); + long long start_time = te.tv_sec * 1000LL + te.tv_usec / 1000; + + while(true) { + if(kbhit()) { + return getch(); + } + gettimeofday(&te, NULL); + long long current_time = te.tv_sec * 1000LL + te.tv_usec / 1000; + if(timeout_ms > 0 && current_time - start_time > timeout_ms) { + return 0; + } + usleep(100); + } +} + +#else // Windows +#include +#include + +uint64_t ob_smpl_get_current_timestamp_ms() { + FILETIME ft; + LARGE_INTEGER li; + GetSystemTimeAsFileTime(&ft); + li.LowPart = ft.dwLowDateTime; + li.HighPart = ft.dwHighDateTime; + long long milliseconds = li.QuadPart / 10000LL; + return milliseconds; +} + +char ob_smpl_wait_for_key_press(uint32_t timeout_ms) { + HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); + if(hStdin == INVALID_HANDLE_VALUE) { + return 0; + } + DWORD mode = 0; + if(!GetConsoleMode(hStdin, &mode)) { + return 0; + } + mode &= ~ENABLE_ECHO_INPUT; + if(!SetConsoleMode(hStdin, mode)) { + return 0; + } + DWORD start_time = GetTickCount(); + while(true) { + if(_kbhit()) { + char ch = (char)_getch(); + SetConsoleMode(hStdin, mode); + return ch; + } + if(timeout_ms > 0 && GetTickCount() - start_time > timeout_ms) { + SetConsoleMode(hStdin, mode); + return 0; + } + Sleep(1); + } +} +#endif + +#ifdef __cplusplus +} +#endif + diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils_c.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils_c.h new file mode 100644 index 0000000..5c6aac2 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils_c.h @@ -0,0 +1,40 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get the current system timestamp in milliseconds. + * + */ +uint64_t ob_smpl_get_current_timestamp_ms(); + +/** + * @brief Wait for key press. + * + * @param[in] timeout_ms The maximum time to wait for a key press in milliseconds. Set to 0 to wait indefinitely. + * + * @return char The key that was pressed. + */ +char ob_smpl_wait_for_key_press(uint32_t timeout_ms); + +// Macro to check for error and exit program if there is one. +#define CHECK_OB_ERROR_EXIT(error) \ + if(*error) { \ + const char *error_message = ob_error_get_message(*error); \ + fprintf(stderr, "Error: %s\n", error_message); \ + ob_delete_error(*error); \ + *error = NULL; \ + exit(-1); \ + } \ + *error = NULL; + +#ifdef __cplusplus +} +#endif diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils_opencv.cpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils_opencv.cpp new file mode 100644 index 0000000..dce5695 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils_opencv.cpp @@ -0,0 +1,585 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +#include "utils_opencv.hpp" +#include "utils.hpp" +#include "utils_types.h" + +#if defined(__has_include) +#if __has_include() +#include +#define TO_DISABLE_OPENCV_LOG +#endif +#endif + +namespace ob_smpl { + +const std::string defaultKeyMapPrompt = "'Esc': Exit Window, '?': Show Key Map"; +CVWindow::CVWindow(std::string name, uint32_t width, uint32_t height, ArrangeMode arrangeMode) + : name_(std::move(name)), + arrangeMode_(arrangeMode), + width_(width), + height_(height), + closed_(false), + showInfo_(true), + showSyncTimeInfo_(false), + isWindowDestroyed_(false), + alpha_(0.6f), + showPrompt_(false) { + +#if defined(TO_DISABLE_OPENCV_LOG) + cv::utils::logging::setLogLevel(cv::utils::logging::LogLevel::LOG_LEVEL_SILENT); +#endif + + prompt_ = defaultKeyMapPrompt; + + cv::namedWindow(name_, cv::WINDOW_NORMAL); + cv::resizeWindow(name_, width_, height_); + + renderMat_ = cv::Mat::zeros(height_, width_, CV_8UC3); + cv::putText(renderMat_, "Waiting for streams...", cv::Point(8, 16), cv::FONT_HERSHEY_DUPLEX, 0.5, cv::Scalar(255, 255, 255), 1, cv::LINE_AA); + cv::imshow(name_, renderMat_); + + // start processing thread + processThread_ = std::thread(&CVWindow::processFrames, this); + + winCreatedTime_ = getNowTimesMs(); +} + +CVWindow::~CVWindow() noexcept { + close(); + destroyWindow(); +} + +void CVWindow::setKeyPressedCallback(std::function callback) { + keyPressedCallback_ = callback; +} + +// if window is closed +bool CVWindow::run() { + + { + // show render mat + std::lock_guard lock(renderMatsMtx_); + cv::imshow(name_, renderMat_); + } + + int key = cv::waitKey(1); + if(key != -1) { + if(key == ESC_KEY) { + closed_ = true; + srcFrameGroupsCv_.notify_all(); + } + else if(key == '1') { + arrangeMode_ = ARRANGE_SINGLE; + addLog("Switch to SINGLE arrange mode"); + } + else if(key == '2') { + arrangeMode_ = ARRANGE_ONE_ROW; + addLog("Switch to ONE_ROW arrange mode"); + } + else if(key == '3') { + arrangeMode_ = ARRANGE_ONE_COLUMN; + addLog("Switch to ONE_COLUMN arrange mode"); + } + else if(key == '4') { + arrangeMode_ = ARRANGE_GRID; + addLog("Switch to GRID arrange mode"); + } + else if(key == '5') { + arrangeMode_ = ARRANGE_OVERLAY; + addLog("Switch to OVERLAY arrange mode"); + } + else if(key == '?' || key == '/') { + showPrompt_ = !showPrompt_; + } + else if(key == '+' || key == '=') { + alpha_ += 0.1f; + if(alpha_ > 1) { + alpha_ = 1; + } + addLog("Adjust alpha to " + ob_smpl::toString(alpha_, 1) + " (Only valid in OVERLAY arrange mode)"); + } + else if(key == '-' || key == '_') { + alpha_ -= 0.1f; + if(alpha_ < 0) { + alpha_ = 0; + } + addLog("Adjust alpha to " + ob_smpl::toString(alpha_, 1) + " (Only valid in OVERLAY arrange mode)"); + } + if(keyPressedCallback_) { + keyPressedCallback_(key); + } + } + return !closed_; +} + +// close window +void CVWindow::close() { + { + std::lock_guard lock(renderMatsMtx_); + closed_ = true; + srcFrameGroupsCv_.notify_all(); + } + + if(processThread_.joinable()) { + processThread_.join(); + } + + matGroups_.clear(); + srcFrameGroups_.clear(); +} + +void CVWindow::destroyWindow() { + if(!isWindowDestroyed_) { + cv::destroyWindow(name_); + cv::waitKey(1); + isWindowDestroyed_ = true; + } + else { + std::cout << "CVWindows has been destroyed!" << std::endl; + } +} + +void CVWindow::reset() { + // close thread and clear cache + close(); + + // restart thread + closed_ = false; + processThread_ = std::thread(&CVWindow::processFrames, this); +} + +// set the window size +void CVWindow::resize(int width, int height) { + width_ = width; + height_ = height; + cv::resizeWindow(name_, width_, height_); +} + +void CVWindow::setKeyPrompt(const std::string &prompt) { + prompt_ = defaultKeyMapPrompt + ", " + prompt; +} + +void CVWindow::addLog(const std::string &log) { + log_ = log; + logCreatedTime_ = getNowTimesMs(); +} + +// add frames to the show +void CVWindow::pushFramesToView(std::vector> frames, int groupId) { + if(frames.empty()) { + return; + } + + std::vector> singleFrames; + for(auto &frame: frames) { + if(frame == nullptr) { + continue; + } + + if(!frame->is()) { + // single frame, add to the list + singleFrames.push_back(frame); + continue; + } + + // FrameSet contains multiple frames + auto frameSet = frame->as(); + for(uint32_t index = 0; index < frameSet->getCount(); index++) { + auto subFrame = frameSet->getFrameByIndex(index); + singleFrames.push_back(subFrame); + } + } + + std::lock_guard lk(srcFrameGroupsMtx_); + srcFrameGroups_[groupId] = singleFrames; + srcFrameGroupsCv_.notify_one(); +} + +void CVWindow::pushFramesToView(std::shared_ptr currentFrame, int groupId) { + pushFramesToView(std::vector>{ currentFrame }, groupId); +} + +// set show frame info +void CVWindow::setShowInfo(bool show) { + showInfo_ = show; +} + +// set show frame synctime info +void CVWindow::setShowSyncTimeInfo(bool show) { + showSyncTimeInfo_ = show; +} +// set alpha for OVERLAY render mode +void CVWindow::setAlpha(float alpha) { + alpha_ = alpha; + if(alpha_ < 0) { + alpha_ = 0; + } + else if(alpha_ > 1) { + alpha_ = 1; + } +} + +// frames processing thread +void CVWindow::processFrames() { + std::map>> frameGroups; + while(!closed_) { + if(closed_) { + break; + } + { + std::unique_lock lk(srcFrameGroupsMtx_); + srcFrameGroupsCv_.wait(lk); + frameGroups = srcFrameGroups_; + } + + if(frameGroups.empty()) { + continue; + } + + for(const auto &framesItem: frameGroups) { + int groupId = framesItem.first; + const auto &frames = framesItem.second; + for(const auto &frame: frames) { + auto rstMat = visualize(frame); + if(!rstMat.empty()) { + int uid = groupId * OB_FRAME_TYPE_COUNT + static_cast(frame->getType()); + matGroups_[uid] = { frame, rstMat }; + } + } + } + + if(matGroups_.empty()) { + continue; + } + + arrangeFrames(); + } +} + +void CVWindow::arrangeFrames() { + cv::Mat renderMat; + try { + if(arrangeMode_ == ARRANGE_SINGLE || matGroups_.size() == 1) { + auto &mat = matGroups_.begin()->second.second; + renderMat = resizeMatKeepAspectRatio(mat, width_, height_); + } + else if(arrangeMode_ == ARRANGE_ONE_ROW) { + for(auto &item: matGroups_) { + auto &mat = item.second.second; + cv::Mat resizeMat = resizeMatKeepAspectRatio(mat, static_cast(width_ / matGroups_.size()), height_); + if(renderMat.dims > 0 && renderMat.cols > 0 && renderMat.rows > 0) { + cv::hconcat(renderMat, resizeMat, renderMat); + } + else { + renderMat = resizeMat; + } + } + } + else if(arrangeMode_ == ARRANGE_ONE_COLUMN) { + for(auto &item: matGroups_) { + auto &mat = item.second.second; + cv::Mat resizeMat = resizeMatKeepAspectRatio(mat, width_, static_cast(height_ / matGroups_.size())); + if(renderMat.dims > 0 && renderMat.cols > 0 && renderMat.rows > 0) { + cv::vconcat(renderMat, resizeMat, renderMat); + } + else { + renderMat = resizeMat; + } + } + } + else if(arrangeMode_ == ARRANGE_GRID) { + int count = static_cast(matGroups_.size()); + int idealSide = static_cast(std::sqrt(count)); + int rows = idealSide; + int cols = idealSide; + while(rows * cols < count) { // find the best row and column count + cols++; + if(rows * cols < count) { + rows++; + } + } + + std::vector gridImages; // store all images in grid + auto it = matGroups_.begin(); + for(int i = 0; i < rows; i++) { + std::vector rowImages; // store images in the same row + for(int j = 0; j < cols; j++) { + int index = i * cols + j; + cv::Mat resizeMat; + if(index < count) { + auto mat = it->second.second; + resizeMat = resizeMatKeepAspectRatio(mat, width_ / cols, height_ / rows); + it++; + } + else { + resizeMat = cv::Mat::zeros(height_ / rows, width_ / cols, CV_8UC3); // fill with black + } + rowImages.push_back(resizeMat); + } + cv::Mat lineMat; + cv::hconcat(rowImages, lineMat); // horizontal concat all images in the same row + gridImages.push_back(lineMat); + } + + cv::vconcat(gridImages, renderMat); // vertical concat all images in the grid + } + else if(arrangeMode_ == ARRANGE_OVERLAY && matGroups_.size() >= 2) { + cv::Mat overlayMat; + const auto &mat1 = matGroups_.begin()->second.second; + const auto &mat2 = matGroups_.rbegin()->second.second; + renderMat = resizeMatKeepAspectRatio(mat1, width_, height_); + overlayMat = resizeMatKeepAspectRatio(mat2, width_, height_); + + float alpha = alpha_; + for(int i = 0; i < renderMat.rows; i++) { + for(int j = 0; j < renderMat.cols; j++) { + cv::Vec3b &outRgb = renderMat.at(i, j); + cv::Vec3b &overlayRgb = overlayMat.at(i, j); + + outRgb[0] = (uint8_t)(outRgb[0] * (1.0f - alpha) + overlayRgb[0] * alpha); + outRgb[1] = (uint8_t)(outRgb[1] * (1.0f - alpha) + overlayRgb[1] * alpha); + outRgb[2] = (uint8_t)(outRgb[2] * (1.0f - alpha) + overlayRgb[2] * alpha); + } + } + } + } + catch(std::exception &e) { + std::cerr << e.what() << std::endl; + } + + if(renderMat.empty()) { + return; + } + + if(showPrompt_ || getNowTimesMs() - winCreatedTime_ < 5000) { + cv::putText(renderMat, prompt_, cv::Point(8, 16), cv::FONT_HERSHEY_DUPLEX, 0.5, cv::Scalar(255, 255, 255), 1, cv::LINE_AA); + } + + if(!log_.empty() && getNowTimesMs() - logCreatedTime_ < 3000) { + cv::putText(renderMat, log_, cv::Point(8, height_ - 16), cv::FONT_HERSHEY_DUPLEX, 0.5, cv::Scalar(255, 255, 255), 1, cv::LINE_AA); + } + + std::lock_guard lock(renderMatsMtx_); + renderMat_ = renderMat; +} + +cv::Mat CVWindow::visualize(std::shared_ptr frame) { + if(frame == nullptr) { + return cv::Mat(); + } + + cv::Mat rstMat; + if(frame->getType() == OB_FRAME_COLOR) { + auto videoFrame = frame->as(); + switch(videoFrame->getFormat()) { + case OB_FORMAT_MJPG: { + cv::Mat rawMat(1, videoFrame->getDataSize(), CV_8UC1, videoFrame->getData()); + rstMat = cv::imdecode(rawMat, 1); + } break; + case OB_FORMAT_NV21: { + cv::Mat rawMat(videoFrame->getHeight() * 3 / 2, videoFrame->getWidth(), CV_8UC1, videoFrame->getData()); + cv::cvtColor(rawMat, rstMat, cv::COLOR_YUV2BGR_NV21); + } break; + case OB_FORMAT_YUYV: + case OB_FORMAT_YUY2: { + cv::Mat rawMat(videoFrame->getHeight(), videoFrame->getWidth(), CV_8UC2, videoFrame->getData()); + cv::cvtColor(rawMat, rstMat, cv::COLOR_YUV2BGR_YUY2); + } break; + case OB_FORMAT_BGR: { + cv::Mat rawMat(videoFrame->getHeight(), videoFrame->getWidth(), CV_8UC3, videoFrame->getData()); + cv::cvtColor(rawMat, rstMat, cv::COLOR_BGR2RGB); + } break; + case OB_FORMAT_RGB: { + cv::Mat rawMat(videoFrame->getHeight(), videoFrame->getWidth(), CV_8UC3, videoFrame->getData()); + cv::cvtColor(rawMat, rstMat, cv::COLOR_RGB2BGR); + } break; + case OB_FORMAT_RGBA: { + cv::Mat rawMat(videoFrame->getHeight(), videoFrame->getWidth(), CV_8UC4, videoFrame->getData()); + cv::cvtColor(rawMat, rstMat, cv::COLOR_RGBA2BGR); + } break; + case OB_FORMAT_BGRA: { + cv::Mat rawMat(videoFrame->getHeight(), videoFrame->getWidth(), CV_8UC4, videoFrame->getData()); + cv::cvtColor(rawMat, rstMat, cv::COLOR_BGRA2BGR); + } break; + case OB_FORMAT_UYVY: { + cv::Mat rawMat(videoFrame->getHeight(), videoFrame->getWidth(), CV_8UC2, videoFrame->getData()); + cv::cvtColor(rawMat, rstMat, cv::COLOR_YUV2BGR_UYVY); + } break; + case OB_FORMAT_I420: { + cv::Mat rawMat(videoFrame->getHeight() * 3 / 2, videoFrame->getWidth(), CV_8UC1, videoFrame->getData()); + cv::cvtColor(rawMat, rstMat, cv::COLOR_YUV2BGR_I420); + } break; + case OB_FORMAT_Y8: { + cv::Mat rawMat(videoFrame->getHeight(), videoFrame->getWidth(), CV_8UC1, videoFrame->getData()); + cv::cvtColor(rawMat, rstMat, cv::COLOR_GRAY2BGR); + } break; + case OB_FORMAT_Y16: { + cv::Mat rawMat(videoFrame->getHeight(), videoFrame->getWidth(), CV_16UC1, videoFrame->getData()); + cv::Mat gray8; + rawMat.convertTo(gray8, CV_8UC1, 255.0 / 65535.0); + cv::cvtColor(gray8, rstMat, cv::COLOR_GRAY2BGR); + } break; + default: + break; + } + if(showSyncTimeInfo_ && !rstMat.empty()) { + drawInfo(rstMat, videoFrame); + } + } + else if(frame->getType() == OB_FRAME_DEPTH) { + auto videoFrame = frame->as(); + if(videoFrame->getFormat() == OB_FORMAT_Y16 || videoFrame->getFormat() == OB_FORMAT_Z16 ) { + cv::Mat rawMat = cv::Mat(videoFrame->getHeight(), videoFrame->getWidth(), CV_16UC1, videoFrame->getData()); + // depth frame pixel value multiply scale to get distance in millimeter + float scale = videoFrame->as()->getValueScale(); + + cv::Mat cvtMat; + // normalization to 0-255. 0.032f is 256/8000, to limit the range of depth to 8000mm + rawMat.convertTo(cvtMat, CV_32F, scale * 0.032f); + + // apply gamma correction to enhance the contrast for near objects + cv::pow(cvtMat, 0.6f, cvtMat); + + // convert to 8-bit + cvtMat.convertTo(cvtMat, CV_8UC1, 10); // multiplier 10 is to normalize to 0-255 (nearly) after applying gamma correction + + // apply colormap + cv::applyColorMap(cvtMat, rstMat, cv::COLORMAP_JET); + } + if(showSyncTimeInfo_ && !rstMat.empty()) { + drawInfo(rstMat, videoFrame); + } + } + else if(frame->getType() == OB_FRAME_IR || frame->getType() == OB_FRAME_IR_LEFT || frame->getType() == OB_FRAME_IR_RIGHT) { + auto videoFrame = frame->as(); + if(videoFrame->getFormat() == OB_FORMAT_Y16) { + cv::Mat cvtMat; + cv::Mat rawMat = cv::Mat(videoFrame->getHeight(), videoFrame->getWidth(), CV_16UC1, videoFrame->getData()); + rawMat.convertTo(cvtMat, CV_8UC1, 1.0 / 16.0f); + cv::cvtColor(cvtMat, rstMat, cv::COLOR_GRAY2RGB); + } + else if(videoFrame->getFormat() == OB_FORMAT_Y8) { + cv::Mat rawMat = cv::Mat(videoFrame->getHeight(), videoFrame->getWidth(), CV_8UC1, videoFrame->getData()); + cv::cvtColor(rawMat, rstMat, cv::COLOR_GRAY2RGB); + } + else if(videoFrame->getFormat() == OB_FORMAT_MJPG) { + cv::Mat rawMat(1, videoFrame->getDataSize(), CV_8UC1, videoFrame->getData()); + rstMat = cv::imdecode(rawMat, 1); + cv::cvtColor(rstMat, rstMat, cv::COLOR_GRAY2RGB); + } + if(showSyncTimeInfo_ && !rstMat.empty()) { + drawInfo(rstMat, videoFrame); + } + } + else if(frame->getType() == OB_FRAME_ACCEL) { + rstMat = cv::Mat::zeros(320, 300, CV_8UC3); + auto accelFrame = frame->as(); + auto value = accelFrame->getValue(); + std::string str = "Accel:"; + cv::putText(rstMat, str.c_str(), cv::Point(8, 60), cv::FONT_HERSHEY_DUPLEX, 0.5, cv::Scalar(255, 255, 255), 1, cv::LINE_AA); + str = std::string(" timestamp=") + std::to_string(accelFrame->getTimeStampUs()) + "us"; + cv::putText(rstMat, str.c_str(), cv::Point(8, 100), cv::FONT_HERSHEY_DUPLEX, 0.5, cv::Scalar(255, 255, 255), 1, cv::LINE_AA); + str = std::string(" x=") + std::to_string(value.x) + "m/s^2"; + cv::putText(rstMat, str.c_str(), cv::Point(8, 140), cv::FONT_HERSHEY_DUPLEX, 0.5, cv::Scalar(255, 255, 255), 1, cv::LINE_AA); + str = std::string(" y=") + std::to_string(value.y) + "m/s^2"; + cv::putText(rstMat, str.c_str(), cv::Point(8, 180), cv::FONT_HERSHEY_DUPLEX, 0.5, cv::Scalar(255, 255, 255), 1, cv::LINE_AA); + str = std::string(" z=") + std::to_string(value.z) + "m/s^2"; + cv::putText(rstMat, str.c_str(), cv::Point(8, 220), cv::FONT_HERSHEY_DUPLEX, 0.5, cv::Scalar(255, 255, 255), 1, cv::LINE_AA); + } + else if(frame->getType() == OB_FRAME_GYRO) { + rstMat = cv::Mat::zeros(320, 300, CV_8UC3); + auto gyroFrame = frame->as(); + auto value = gyroFrame->getValue(); + std::string str = "Gyro:"; + cv::putText(rstMat, str.c_str(), cv::Point(8, 60), cv::FONT_HERSHEY_DUPLEX, 0.5, cv::Scalar(255, 255, 255), 1, cv::LINE_AA); + str = std::string(" timestamp=") + std::to_string(gyroFrame->getTimeStampUs()) + "us"; + cv::putText(rstMat, str.c_str(), cv::Point(8, 100), cv::FONT_HERSHEY_DUPLEX, 0.5, cv::Scalar(255, 255, 255), 1, cv::LINE_AA); + str = std::string(" x=") + std::to_string(value.x) + "rad/s"; + cv::putText(rstMat, str.c_str(), cv::Point(8, 140), cv::FONT_HERSHEY_DUPLEX, 0.5, cv::Scalar(255, 255, 255), 1, cv::LINE_AA); + str = std::string(" y=") + std::to_string(value.y) + "rad/s"; + cv::putText(rstMat, str.c_str(), cv::Point(8, 180), cv::FONT_HERSHEY_DUPLEX, 0.5, cv::Scalar(255, 255, 255), 1, cv::LINE_AA); + str = std::string(" z=") + std::to_string(value.z) + "rad/s"; + cv::putText(rstMat, str.c_str(), cv::Point(8, 220), cv::FONT_HERSHEY_DUPLEX, 0.5, cv::Scalar(255, 255, 255), 1, cv::LINE_AA); + } + return rstMat; +} + +// add frame info to mat +void CVWindow::drawInfo(cv::Mat &imageMat, std::shared_ptr &frame) { + int baseline = 0; // Used to calculate text size and baseline + cv::Size textSize; // Size of the text to be drawn + int padding = 5; // Padding around the text for the background + + // Helper lambda function to draw text with background + auto putTextWithBackground = [&](const std::string &text, cv::Point origin) { + // Getting text size for background + textSize = cv::getTextSize(text, cv::FONT_HERSHEY_SIMPLEX, 0.6, 1, &baseline); + + // Drawing the white background + cv::rectangle(imageMat, origin + cv::Point(0, baseline), origin + cv::Point(textSize.width, -textSize.height) - cv::Point(0, padding), + cv::Scalar(255, 255, 255), cv::FILLED); + + // Putting black text on the white background + cv::putText(imageMat, text, origin, cv::FONT_HERSHEY_SIMPLEX, 0.6, cv::Scalar(0, 0, 0), 1); + }; + + // Drawing text with background based on frame type + if(frame->getType() == OB_FRAME_COLOR && frame->getFormat() == OB_FORMAT_NV21) { + putTextWithBackground("Color-NV21", cv::Point(8, 16)); + } + else if(frame->getType() == OB_FRAME_COLOR && frame->getFormat() == OB_FORMAT_MJPG) { + putTextWithBackground("Color-MJPG", cv::Point(8, 16)); + } + else if(frame->getType() == OB_FRAME_COLOR && ((frame->getFormat() == OB_FORMAT_YUYV) || (frame->getFormat() == OB_FORMAT_YUY2))) { + putTextWithBackground("Color-YUYV", cv::Point(8, 16)); + } + else if(frame->getType() == OB_FRAME_DEPTH) { + putTextWithBackground("Depth", cv::Point(8, 16)); + } + else if(frame->getType() == OB_FRAME_IR) { + putTextWithBackground("IR", cv::Point(8, 16)); + } + else if(frame->getType() == OB_FRAME_IR_LEFT) { + putTextWithBackground("LeftIR", cv::Point(8, 16)); + } + else if(frame->getType() == OB_FRAME_IR_RIGHT) { + putTextWithBackground("RightIR", cv::Point(8, 16)); + } + + // Timestamp information with background + putTextWithBackground("frame timestamp(us): " + std::to_string(frame->getTimeStampUs()), cv::Point(8, 40)); + putTextWithBackground("system timestamp(us): " + std::to_string(frame->getSystemTimeStampUs()), cv::Point(8, 64)); +} + +cv::Mat CVWindow::resizeMatKeepAspectRatio(const cv::Mat &mat, int width, int height) { + auto hScale = static_cast(width) / mat.cols; + auto vScale = static_cast(height) / mat.rows; + auto scale = std::min(hScale, vScale); + auto newWidth = static_cast(mat.cols * scale); + auto newHeight = static_cast(mat.rows * scale); + cv::Mat resizeMat; + cv::resize(mat, resizeMat, cv::Size(newWidth, newHeight)); + + if(newWidth == width && newHeight == height) { + return resizeMat; + } + + // padding the resized mat to target width and height + cv::Mat paddedMat; + if(newWidth < width) { + auto paddingLeft = (width - newWidth) / 2; + auto paddingRight = width - newWidth - paddingLeft; + cv::copyMakeBorder(resizeMat, paddedMat, 0, 0, paddingLeft, paddingRight, cv::BORDER_CONSTANT, cv::Scalar(0, 0, 0)); + } + + if(newHeight < height) { + auto paddingTop = (height - newHeight) / 2; + auto paddingBottom = height - newHeight - paddingTop; + cv::copyMakeBorder(resizeMat, paddedMat, paddingTop, paddingBottom, 0, 0, cv::BORDER_CONSTANT, cv::Scalar(0, 0, 0)); + } + return paddedMat; +} + +} // namespace ob_smpl diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils_opencv.hpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils_opencv.hpp new file mode 100644 index 0000000..ea20787 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils_opencv.hpp @@ -0,0 +1,117 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include + +#include "utils_types.h" +#include "utils.hpp" + +namespace ob_smpl { + +// arrange type +typedef enum { + ARRANGE_SINGLE, // Only show the first frame + ARRANGE_ONE_ROW, // Arrange the frames in the array as a row + ARRANGE_ONE_COLUMN, // Arrange the frames in the array as a column + ARRANGE_GRID, // Arrange the frames in the array as a grid + ARRANGE_OVERLAY // Overlay the first two frames in the array +} ArrangeMode; + +class CVWindow { +public: + // create a window with the specified name, width and height + CVWindow(std::string name, uint32_t width = 1280, uint32_t height = 720, ArrangeMode arrangeMode = ARRANGE_SINGLE); + ~CVWindow() noexcept; + + // run the window loop + bool run(); + + // close window + void close(); + + // clear cached frames and mats + void reset(); + + // add frames to view + void pushFramesToView(std::vector> frames, int groupId = 0); + void pushFramesToView(std::shared_ptr currentFrame, int groupId = 0); + + // set show frame info + void setShowInfo(bool show); + + // set show frame syncTime info + void setShowSyncTimeInfo(bool show); + + // set alpha, only valid when arrangeMode_ is ARRANGE_OVERLAY + void setAlpha(float alpha); + + // set the window size + void resize(int width, int height); + + // set the key pressed callback + void setKeyPressedCallback(std::function callback); + + // set the key prompt + void setKeyPrompt(const std::string &prompt); + + // set the log message + void addLog(const std::string &log); + + // destroyWindow + void destroyWindow(); + +private: + // frames processing thread function + void processFrames(); + + // arrange frames in the renderMat_ according to the arrangeMode_ + void arrangeFrames(); + + // add info to mat + cv::Mat visualize(std::shared_ptr frame); + + // draw info to mat + void drawInfo(cv::Mat &imageMat, std::shared_ptr &frame); + + cv::Mat resizeMatKeepAspectRatio(const cv::Mat &mat, int width, int height); + +private: + std::string name_; + ArrangeMode arrangeMode_; + uint32_t width_; + uint32_t height_; + bool closed_; + bool showInfo_; + bool showSyncTimeInfo_; + bool isWindowDestroyed_; + float alpha_; + + std::thread processThread_; + std::map>> srcFrameGroups_; + std::mutex srcFrameGroupsMtx_; + std::condition_variable srcFrameGroupsCv_; + + using StreamsMatMap = std::map, cv::Mat>>; + StreamsMatMap matGroups_; + std::mutex renderMatsMtx_; + cv::Mat renderMat_; + + std::string prompt_; + bool showPrompt_; + uint64 winCreatedTime_; + + std::string log_; + uint64 logCreatedTime_; + + std::function keyPressedCallback_; +}; + +} // namespace ob_smpl diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils_types.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils_types.h new file mode 100644 index 0000000..cd1e09d --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/utils/utils_types.h @@ -0,0 +1,12 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +#ifdef __cplusplus +extern "C" { +#endif + +#define ESC_KEY 27 + +#ifdef __cplusplus +} +#endif diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/ObSensor.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/ObSensor.h new file mode 100644 index 0000000..0eb17e7 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/ObSensor.h @@ -0,0 +1,23 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * \file ObSensor.h + * \brief This file serves as the C entrance for the OrbbecSDK library. + * It includes all necessary header files for OrbbecSDK usage. + */ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/ObSensor.hpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/ObSensor.hpp new file mode 100644 index 0000000..23da2ff --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/ObSensor.hpp @@ -0,0 +1,21 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * \file ObSensor.hpp + * \brief This is the main entry point for the OrbbecSDK C++ library. + * It includes all necessary header files for using the library. + */ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Advanced.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Advanced.h new file mode 100644 index 0000000..bf5365a --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Advanced.h @@ -0,0 +1,278 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ObTypes.h" + +/** + * @brief Get the current depth work mode. + * + * @param[in] device The device object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return ob_depth_work_mode The current depth work mode. + */ +OB_EXPORT ob_depth_work_mode ob_device_get_current_depth_work_mode(const ob_device *device, ob_error **error); + +/** + * @brief Get current depth mode name + * @brief According the current preset name to return current depth mode name + * @return const char* return the current depth mode name. + */ +OB_EXPORT const char *ob_device_get_current_depth_work_mode_name(const ob_device *device, ob_error **error); + +/** + * @brief Switch the depth work mode by ob_depth_work_mode. + * Prefer to use ob_device_switch_depth_work_mode_by_name to switch depth mode when the complete name of the depth work mode is known. + * + * @param[in] device The device object. + * @param[in] work_mode The depth work mode from ob_depth_work_mode_list which is returned by ob_device_get_depth_work_mode_list. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return ob_status The switch result. OB_STATUS_OK: success, other failed. + */ +OB_EXPORT ob_status ob_device_switch_depth_work_mode(ob_device *device, const ob_depth_work_mode *work_mode, ob_error **error); + +/** + * @brief Switch the depth work mode by work mode name. + * + * @param[in] device The device object. + * @param[in] mode_name The depth work mode name which is equal to ob_depth_work_mode.name. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return ob_status The switch result. OB_STATUS_OK: success, other failed. + */ +OB_EXPORT ob_status ob_device_switch_depth_work_mode_by_name(ob_device *device, const char *mode_name, ob_error **error); + +/** + * @brief Request the list of supported depth work modes. + * + * @param[in] device The device object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return ob_depth_work_mode_list The list of ob_depth_work_mode. + */ +OB_EXPORT ob_depth_work_mode_list *ob_device_get_depth_work_mode_list(const ob_device *device, ob_error **error); + +/** + * \if English + * @brief Get the depth work mode count that ob_depth_work_mode_list hold + * @param[in] work_mode_list data struct contain list of ob_depth_work_mode + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The total number contained in ob_depth_work_mode_list + * + */ +OB_EXPORT uint32_t ob_depth_work_mode_list_get_count(const ob_depth_work_mode_list *work_mode_list, ob_error **error); + +/** + * @brief Get the index target of ob_depth_work_mode from work_mode_list + * + * @param[in] work_mode_list Data structure containing a list of ob_depth_work_mode + * @param[in] index Index of the target ob_depth_work_mode + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_depth_work_mode + * + */ +OB_EXPORT ob_depth_work_mode ob_depth_work_mode_list_get_item(const ob_depth_work_mode_list *work_mode_list, uint32_t index, ob_error **error); + +/** + * @brief Free the resources of ob_depth_work_mode_list + * + * @param[in] work_mode_list Data structure containing a list of ob_depth_work_mode + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + */ +OB_EXPORT void ob_delete_depth_work_mode_list(ob_depth_work_mode_list *work_mode_list, ob_error **error); + +/** + * @breif Get the current preset name. + * @brief The preset mean a set of parameters or configurations that can be applied to the device to achieve a specific effect or function. + * + * @param device The device object. + * @param error Pointer to an error object that will be set if an error occurs. + * @return The current preset name, it should be one of the preset names returned by @ref ob_device_get_available_preset_list. + */ +OB_EXPORT const char *ob_device_get_current_preset_name(const ob_device *device, ob_error **error); + +/** + * @brief Get the available preset list. + * @attention After loading the preset, the settings in the preset will set to the device immediately. Therefore, it is recommended to re-read the device + * settings to update the user program temporarily. + * + * @param device The device object. + * @param preset_name Pointer to an error object that will be set if an error occurs. The name should be one of the preset names returned by @ref + * ob_device_get_available_preset_list. + * @param error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_load_preset(ob_device *device, const char *preset_name, ob_error **error); + +/** + * @brief Load preset from json string. + * @brief After loading the custom preset, the settings in the custom preset will set to the device immediately. + * @brief After loading the custom preset, the available preset list will be appended with the custom preset and named as the file name. + * + * @param device The device object. + * @param json_file_path The json file path. + * @param error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_load_preset_from_json_file(ob_device *device, const char *json_file_path, ob_error **error); + +/** + * @brief Load custom preset from data. + * @brief After loading the custom preset, the settings in the custom preset will set to the device immediately. + * @brief After loading the custom preset, the available preset list will be appended with the custom preset and named as the @ref presetName. + * + * @attention The user should ensure that the custom preset data is adapted to the device and the settings in the data are valid. + * @attention It is recommended to re-read the device settings to update the user program temporarily after successfully loading the custom preset. + * + * @param data The custom preset data. + * @param size The size of the custom preset data. + */ +OB_EXPORT void ob_device_load_preset_from_json_data(ob_device *device, const char *presetName, const uint8_t *data, uint32_t size, ob_error **error); + +/** + * @brief Export current settings as a preset json file. + * @brief After exporting the custom preset, the available preset list will be appended with the custom preset and named as the file name. + * + * @param device The device object. + * @param json_file_path The json file path. + * @param error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_export_current_settings_as_preset_json_file(ob_device *device, const char *json_file_path, ob_error **error); + +/** + * @brief Export current device settings as a preset json data. + * @brief After exporting the preset, a new preset named as the @ref presetName will be added to the available preset list. + * + * @attention The memory of the data is allocated by the SDK, and will automatically be released by the SDK. + * @attention The memory of the data will be reused by the SDK on the next call, so the user should copy the data to a new buffer if it needs to be + * preserved. + * + * @param[out] data return the preset json data. + * @param[out] dataSize return the size of the preset json data. + */ +OB_EXPORT void ob_device_export_current_settings_as_preset_json_data(ob_device *device, const char *presetName, const uint8_t **data, uint32_t *dataSize, + ob_error **error); + +/** + * @brief Get the available preset list. + * + * @param device The device object. + * @param error Pointer to an error object that will be set if an error occurs. + * @return The available preset list. + */ +OB_EXPORT ob_device_preset_list *ob_device_get_available_preset_list(const ob_device *device, ob_error **error); + +/** + * @brief Delete the available preset list. + * + * @param preset_list The available preset list. + * @param error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_delete_preset_list(ob_device_preset_list *preset_list, ob_error **error); + +/** + * @brief Get the number of preset in the preset list. + * + * @param preset_list The available preset list. + * @param error Pointer to an error object that will be set if an error occurs. + * @return The number of preset in the preset list. + */ +OB_EXPORT uint32_t ob_device_preset_list_get_count(const ob_device_preset_list *preset_list, ob_error **error); + +/** + * @brief Get the name of the preset in the preset list. + * + * @param preset_list The available preset list. + * @param index The index of the preset in the preset list. + * @param error Pointer to an error object that will be set if an error occurs. + * @return The name of the preset in the preset list. + */ +OB_EXPORT const char *ob_device_preset_list_get_name(const ob_device_preset_list *preset_list, uint32_t index, ob_error **error); + +/** + * @brief Check if the preset list has the preset. + * + * @param preset_list The available preset list. + * @param preset_name The name of the preset. + * @param error Pointer to an error object that will be set if an error occurs. + * @return Whether the preset list has the preset. If true, the preset list has the preset. If false, the preset list does not have the preset. + */ +OB_EXPORT bool ob_device_preset_list_has_preset(const ob_device_preset_list *preset_list, const char *preset_name, ob_error **error); + +/** + * @brief Check if the device supports the frame interleave feature. + * + * @param device The device object. + * @param error Pointer to an error object that will be set if an error occurs. + * @return bool Returns true if the device supports the frame interleave feature. + */ +OB_EXPORT bool ob_device_is_frame_interleave_supported(const ob_device *device, ob_error **error); +/** + * + * @brief load the frame interleave mode according to frame interleavee name. + * + * @param device The device object. + * @param frame_interleave_name The name should be one of the frame interleave names returned by @ref ob_device_get_available_frame_interleave_list. + * @param error Log error messages. + */ +OB_EXPORT void ob_device_load_frame_interleave(ob_device *device, const char *frame_interleave_name, ob_error **error); + +/** + * @brief Get the available frame interleave list. + * + * @param device The device object. + * @param error Log error messages. + * @return The available frame interleave list. + */ +OB_EXPORT ob_device_frame_interleave_list *ob_device_get_available_frame_interleave_list(ob_device *device, ob_error **error); + +/** + * @brief Delete the available frame interleave list. + * + * @param frame_interleave_list The available frame interleave list. + * @param error Log error messages. + */ +OB_EXPORT void ob_delete_frame_interleave_list(ob_device_frame_interleave_list *frame_interleave_list, ob_error **error); + +/** + * @brief Get the number of frame interleave in the frame interleave list. + * + * @param frame_interleave_list The available frame interleave list. + * @param error Log error messages. + * @return The number of frame interleave in the frame interleave list. + */ +OB_EXPORT uint32_t ob_device_frame_interleave_list_get_count(ob_device_frame_interleave_list *frame_interleave_list, ob_error **error); + +/** + * @brief Get the name of frame interleave in the frame interleave list. + * + * @param frame_interleave_list The available frame interleave list. + * @param index The index of frame interleave in the frame interleave list. + * @param error Log error messages. + * @return The name of frame interleave in the frame interleave list.. + */ +OB_EXPORT const char *ob_device_frame_interleave_list_get_name(ob_device_frame_interleave_list *frame_interleave_list, uint32_t index, ob_error **error); + +/** + * @brief Check if the interleave ae list has the interleave ae. + * + * @param frame_interleave_list The available interleave ae list. + * @param frame_interleave_name The name of the interleave ae. + * @param error Log error messages. + * @return Whether the interleave ae list has the interleave ae. If true, the interleave ae list has the interleave ae. If false, the interleave ae list does + * not have the interleave ae. + */ +OB_EXPORT bool ob_device_frame_interleave_list_has_frame_interleave(ob_device_frame_interleave_list *frame_interleave_list, const char *frame_interleave_name, + ob_error **error); + +// The following interfaces are deprecated and are retained here for compatibility purposes. +#define ob_depth_work_mode_list_count ob_depth_work_mode_list_get_count +#define ob_device_preset_list_count ob_device_preset_list_get_count + +#ifdef __cplusplus +} +#endif diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Context.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Context.h new file mode 100644 index 0000000..e0c0535 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Context.h @@ -0,0 +1,173 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Context.h + * @brief Context is a management class that describes the runtime of the SDK and is responsible for resource allocation and release of the SDK. + * Context has the ability to manage multiple devices. It is responsible for enumerating devices, monitoring device callbacks, and enabling multi-device + * synchronization. + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ObTypes.h" + +/** + * @brief Create a context object with the default configuration file + * + * @param[out] error Pointer to an error object that will be populated if an error occurs during context creation + * @return Pointer to the created context object + */ +OB_EXPORT ob_context *ob_create_context(ob_error **error); + +/** + * @brief Create a context object with a specified configuration file + * + * @param[in] config_file_path Path to the configuration file. If NULL, the default configuration file will be used. + * @param[out] error Pointer to an error object that will be populated if an error occurs during context creation + * @return Pointer to the created context object + */ +OB_EXPORT ob_context *ob_create_context_with_config(const char *config_file_path, ob_error **error); + +/** + * @brief Delete a context object + * + * @param[in] context Pointer to the context object to be deleted + * @param[out] error Pointer to an error object that will be populated if an error occurs during context deletion + */ +OB_EXPORT void ob_delete_context(ob_context *context, ob_error **error); + +/** + * @brief Get a list of enumerated devices + * + * @param[in] context Pointer to the context object + * @param[out] error Pointer to an error object that will be populated if an error occurs during device enumeration + * @return Pointer to the device list object + */ +OB_EXPORT ob_device_list *ob_query_device_list(ob_context *context, ob_error **error); + +/** + * @brief Enable or disable network device enumeration + * @brief After enabling, the network device will be automatically discovered and can be retrieved through @ref ob_query_device_list. The default state can be + * set in the configuration file. + * + * @attention Network device enumeration is performed through the GVCP protocol. If the device is not in the same subnet as the host, it will be discovered but + * cannot be connected. + * + * @param[in] context Pointer to the context object + * @param[in] enable true to enable, false to disable + * @param[out] error Pointer to an error object that will be populated if an error occurs. + */ +OB_EXPORT void ob_enable_net_device_enumeration(ob_context *context, bool enable, ob_error **error); + +/** + * @brief Create a network device object + * + * @param[in] context Pointer to the context object + * @param[in] address IP address of the device + * @param[in] port Port number of the device + * @param[out] error Pointer to an error object that will be populated if an error occurs during device creation + * @return Pointer to the created device object + */ +OB_EXPORT ob_device *ob_create_net_device(ob_context *context, const char *address, uint16_t port, ob_error **error); + +/** + * @brief Set a device plug-in callback function + * @attention The added and removed device lists returned through the callback interface need to be released manually + * @attention This function supports multiple callbacks. Each call to this function adds a new callback to an internal list. + * + * @param[in] context Pointer to the context object + * @param[in] callback Pointer to the callback function triggered when a device is plugged or unplugged + * @param[in] user_data Pointer to user data that can be passed to and retrieved from the callback function + * @param[out] error Pointer to an error object that will be populated if an error occurs during callback function setting + */ +OB_EXPORT void ob_set_device_changed_callback(ob_context *context, ob_device_changed_callback callback, void *user_data, ob_error **error); + +/** + * @brief Activates device clock synchronization to synchronize the clock of the host and all created devices (if supported). + * + * @param[in] context Pointer to the context object + * @param[in] repeat_interval_msec The interval for auto-repeated synchronization, in milliseconds. If the value is 0, synchronization is performed only once. + * @param[out] error Pointer to an error object that will be populated if an error occurs during execution + */ +OB_EXPORT void ob_enable_device_clock_sync(ob_context *context, uint64_t repeat_interval_msec, ob_error **error); + +/** + * @brief Free idle memory from the internal frame memory pool + * + * @param[in] context Pointer to the context object + * @param[out] error Pointer to an error object that will be populated if an error occurs during memory freeing + */ +OB_EXPORT void ob_free_idle_memory(ob_context *context, ob_error **error); + +/** + * @brief For linux, there are two ways to enable the UVC backend: libuvc and v4l2. This function is used to set the backend type. + * @brief It is effective when the new device is created. + * + * @attention This interface is only available for Linux. + * + * @param[in] context Pointer to the context object + * @param[in] backend_type The backend type to be used. + * @param[out] error Pointer to an error object that will be populated if an error occurs during backend type setting + */ +OB_EXPORT void ob_set_uvc_backend_type(ob_context *context, ob_uvc_backend_type backend_type, ob_error **error); + +/** + * @brief Set the global log level + * + * @attention This interface setting will affect the output level of all logs (terminal, file, callback) + * + * @param[in] severity Log level to set + * @param[out] error Pointer to an error object that will be populated if an error occurs during log level setting + */ +OB_EXPORT void ob_set_logger_severity(ob_log_severity severity, ob_error **error); + +/** + * @brief Set the log output to a file + * + * @param[in] severity Log level to output to file + * @param[in] directory Path to the log file output directory. If the path is empty, the existing settings will continue to be used (if the existing + * configuration is also empty, the log will not be output to the file) + * @param[out] error Pointer to an error object that will be populated if an error occurs during log output setting + */ +OB_EXPORT void ob_set_logger_to_file(ob_log_severity severity, const char *directory, ob_error **error); + +/** + * @brief Set the log callback function + * + * @param[in] severity Log level to set for the callback function + * @param[in] callback Pointer to the callback function + * @param[in] user_data Pointer to user data that can be passed to and retrieved from the callback function + * @param[out] error Pointer to an error object that will be populated if an error occurs during log callback function setting + */ +OB_EXPORT void ob_set_logger_to_callback(ob_log_severity severity, ob_log_callback callback, void *user_data, ob_error **error); + +/** + * @brief Set the log output to the console + * + * @param[in] severity Log level to output to the console + * @param[out] error Pointer to an error object that will be populated if an error occurs during log output setting + */ +OB_EXPORT void ob_set_logger_to_console(ob_log_severity severity, ob_error **error); + +/** + * @brief Set the extensions directory + * @brief The extensions directory is used to search for dynamic libraries that provide additional functionality to the SDK, such as the Frame filters. + * + * @attention Should be called before creating the context and pipeline, otherwise the default extensions directory (./extensions) will be used. + * + * @param directory Path to the extensions directory. If the path is empty, extensions path will be set to the current working directory. + * @param error Pointer to an error object that will be populated if an error occurs during extensions directory setting + */ +OB_EXPORT void ob_set_extensions_directory(const char *directory, ob_error **error); + +// The following interfaces are deprecated and are retained here for compatibility purposes. +#define ob_enable_multi_device_sync ob_enable_device_clock_sync +#define ob_set_logger_callback ob_set_logger_to_callback + +#ifdef __cplusplus +} +#endif diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Device.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Device.h new file mode 100644 index 0000000..1c14efb --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Device.h @@ -0,0 +1,691 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Device.h + * @brief Device-related functions, including operations such as obtaining and creating a device, setting and obtaining device property, and obtaining sensors + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ObTypes.h" +#include "Property.h" +#include "MultipleDevices.h" +#include "Advanced.h" + +/** + * @brief Delete a device. + * + * @param[in] device The device to be deleted. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_delete_device(ob_device *device, ob_error **error); + +/** + * @brief List all sensors. + * + * @param[in] device The device object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_sensor_list* The list of all sensors. + */ +OB_EXPORT ob_sensor_list *ob_device_get_sensor_list(const ob_device *device, ob_error **error); + +/** + * @brief Get a device's sensor. + * + * @param[in] device The device object. + * @param[in] type The type of sensor to get. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_sensor* The acquired sensor. + */ +OB_EXPORT ob_sensor *ob_device_get_sensor(ob_device *device, ob_sensor_type type, ob_error **error); + +/** + * @brief Set an integer type of device property. + * + * @param[in] device The device object. + * @param[in] property_id The ID of the property to be set. + * @param[in] value The property value to be set. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_set_int_property(ob_device *device, ob_property_id property_id, int32_t value, ob_error **error); + +/** + * @brief Get an integer type of device property. + * + * @param[in] device The device object. + * @param[in] property_id The property ID. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return int32_t The property value. + */ +OB_EXPORT int32_t ob_device_get_int_property(ob_device *device, ob_property_id property_id, ob_error **error); + +/** + * @brief Get the integer type of device property range. + * + * @param[in] device The device object. + * @param[in] property_id The property id. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The property range. + */ +OB_EXPORT ob_int_property_range ob_device_get_int_property_range(ob_device *device, ob_property_id property_id, ob_error **error); + +/** + * @brief Set a float type of device property. + * + * @param[in] device The device object. + * @param[in] property_id The ID of the property to be set. + * @param[in] value The property value to be set. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_set_float_property(ob_device *device, ob_property_id property_id, float value, ob_error **error); + +/** + * @brief Get a float type of device property. + * + * @param[in] device The device object. + * @param[in] property_id The property ID. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return float The property value. + */ +OB_EXPORT float ob_device_get_float_property(ob_device *device, ob_property_id property_id, ob_error **error); + +/** + * @brief Get the float type of device property range. + * + * @param[in] device The device object. + * @param[in] property_id The property id. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The property range. + */ +OB_EXPORT ob_float_property_range ob_device_get_float_property_range(ob_device *device, ob_property_id property_id, ob_error **error); + +/** + * @brief Set a boolean type of device property. + * + * @param[in] device The device object. + * @param[in] property_id The ID of the property to be set. + * @param[in] value The property value to be set. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_set_bool_property(ob_device *device, ob_property_id property_id, bool value, ob_error **error); + +/** + * @brief Get a boolean type of device property. + * + * @param[in] device The device object. + * @param[in] property_id The property ID. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return bool The property value. + */ +OB_EXPORT bool ob_device_get_bool_property(ob_device *device, ob_property_id property_id, ob_error **error); + +/** + * @brief Get the boolean type of device property range. + * + * @param[in] device The device object. + * @param[in] property_id The property id. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The property range. + */ +OB_EXPORT ob_bool_property_range ob_device_get_bool_property_range(ob_device *device, ob_property_id property_id, ob_error **error); + +/** + * @brief Set structured data. + * + * @param[in] device The device object. + * @param[in] property_id The ID of the property to be set. + * @param[in] data The property data to be set. + * @param[in] data_size The size of the property to be set. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_set_structured_data(ob_device *device, ob_property_id property_id, const uint8_t *data, uint32_t data_size, ob_error **error); + +/** + * @brief Get structured data of a device property. + * + * @param[in] device The device object. + * @param[in] property_id The ID of the property. + * @param[out] data The obtained property data. + * @param[out] data_size The size of the obtained property data. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_get_structured_data(ob_device *device, ob_property_id property_id, uint8_t *data, uint32_t *data_size, ob_error **error); + +/** + * @brief Get raw data of a device property. + * + * @param[in] device The device object. + * @param[in] property_id The ID of the property. + * @param[out] cb The get data callback. + * @param[out] user_data User-defined data that will be returned in the callback. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_get_raw_data(ob_device *device, ob_property_id property_id, ob_get_data_callback cb, void *user_data, ob_error **error); + +/** + * @brief Set customer data. + * + * @param[in] device The device object. + * @param[in] data The property data to be set. + * @param[in] data_size The size of the property to be set,the maximum length cannot exceed 65532 bytes. + * @param[out] error Log error messages. + */ +OB_EXPORT void ob_device_write_customer_data(ob_device *device, const void *data, uint32_t data_size, ob_error **error); + +/** + * @brief Get customer data of a device property. + * + * @param[in] device The device object. + * @param[out] data The obtained property data. + * @param[out] data_size The size of the obtained property data. + * @param[out] error Log error messages. + */ +OB_EXPORT void ob_device_read_customer_data(ob_device *device, void *data, uint32_t *data_size, ob_error **error); + +/** + * @brief Get the number of properties supported by the device. + * + * @param[in] device The device object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The number of properties supported by the device. + */ +OB_EXPORT uint32_t ob_device_get_supported_property_count(const ob_device *device, ob_error **error); + +/** + * @brief Get the type of property supported by the device. + * + * @param[in] device The device object. + * @param[in] index The property index. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The type of property supported by the device. + */ +OB_EXPORT ob_property_item ob_device_get_supported_property_item(const ob_device *device, uint32_t index, ob_error **error); + +/** + * @brief Check if a device property permission is supported. + * + * @param[in] device The device object. + * @param[in] property_id The property id. + * @param[in] permission The type of permission that needs to be interpreted. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return Whether the property permission is supported. + */ +OB_EXPORT bool ob_device_is_property_supported(const ob_device *device, ob_property_id property_id, ob_permission_type permission, ob_error **error); + +/** + * @brief Check if the device supports global timestamp. + * + * @param[in] device The device object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return bool Whether the device supports global timestamp. + */ +OB_EXPORT bool ob_device_is_global_timestamp_supported(const ob_device *device, ob_error **error); + +/** + * @brief Enable or disable global timestamp. + * + * @param device The device object. + * @param enable Whether to enable global timestamp. + * @param error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_enable_global_timestamp(ob_device *device, bool enable, ob_error **error); + +/** + * @brief Update the device firmware. + * + * @param[in] device The device object. + * @param[in] path The firmware path. + * @param[in] callback The firmware upgrade progress callback. + * @param[in] async Whether to execute asynchronously. + * @param[in] user_data User-defined data that will be returned in the callback. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_update_firmware(ob_device *device, const char *path, ob_device_fw_update_callback callback, bool async, void *user_data, + ob_error **error); + +/** + * @brief Update the device firmware from data. + * + * @param[in] device The device object. + * @param[in] data The firmware file data. + * @param[in] data_size The firmware file size. + * @param[in] callback The firmware upgrade progress callback. + * @param[in] async Whether to execute asynchronously. + * @param[in] user_data User-defined data that will be returned in the callback. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_update_firmware_from_data(ob_device *device, const uint8_t *data, uint32_t data_size, ob_device_fw_update_callback callback, + bool async, void *user_data, ob_error **error); + +/** + * @brief Update the device optional depth presets. + * + * @param[in] device The device object. + * @param[in] file_path_list A list(2D array) of preset file paths, each up to OB_PATH_MAX characters. + * @param[in] path_count The number of the preset file paths. + * @param[in] callback The preset upgrade progress callback. + * @param[in] user_data User-defined data that will be returned in the callback. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_update_optional_depth_presets(ob_device *device, const char file_path_list[][OB_PATH_MAX], uint8_t path_count, + ob_device_fw_update_callback callback, void *user_data, ob_error **error); + +/** + * @brief Device reboot + * @attention The device will be disconnected and reconnected. After the device is disconnected, the interface access to the device handle may be abnormal. + * Please use the ob_delete_device interface to delete the handle directly. After the device is reconnected, it can be obtained again. + * + * @param[in] device Device object + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_reboot(ob_device *device, ob_error **error); + +/** + * @brief Get the current device status. + * + * @param[in] device The device object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return ob_device_state The device state information. + */ +OB_EXPORT ob_device_state ob_device_get_device_state(const ob_device *device, ob_error **error); + +/** + * @brief Set the device state changed callback. + * + * @param[in] device The device object. + * @param[in] callback The callback function to be called when the device status changes. + * @param[in] user_data User-defined data that will be returned in the callback. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_set_state_changed_callback(ob_device *device, ob_device_state_callback callback, void *user_data, ob_error **error); + +/** + * @brief Enable or disable the device heartbeat. + * @brief After enable the device heartbeat, the sdk will start a thread to send heartbeat signal to the device error every 3 seconds. + + * @attention If the device does not receive the heartbeat signal for a long time, it will be disconnected and rebooted. + * + * @param[in] device The device object. + * @param[in] enable Whether to enable the device heartbeat. + * @param error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_enable_heartbeat(ob_device *device, bool enable, ob_error **error); + +/** + * @brief Send data to the device and receive data from the device. + * @brief This is a factory and debug function, which can be used to send and receive data from the device. The data format is secret and belongs to the device + * vendor. + * + * @param[in] device The device object. + * @param[in] send_data The data to be sent to the device. + * @param[in] send_data_size The size of the data to be sent to the device. + * @param[out] receive_data The data received from the device. + * @param[in,out] receive_data_size Pass in the expected size of the receive data, and return the actual size of the received data. + * @param error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_send_and_receive_data(ob_device *device, const uint8_t *send_data, uint32_t send_data_size, uint8_t *receive_data, + uint32_t *receive_data_size, ob_error **error); + +/** + * @brief Get device information. + * + * @param[in] device The device to obtain information from. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_device_info* The device information. + */ +OB_EXPORT ob_device_info *ob_device_get_device_info(const ob_device *device, ob_error **error); + +/** + * @brief Delete device information. + * + * @param[in] info The device information to be deleted. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_delete_device_info(ob_device_info *info, ob_error **error); + +/** + * @brief Get device name + * + * @param[in] info Device Information + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return const char* return the device name + */ +OB_EXPORT const char *ob_device_info_get_name(const ob_device_info *info, ob_error **error); + +/** +* @brief Get device pid + + * @param[in] info Device Information + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return int return the device pid +*/ +OB_EXPORT int ob_device_info_get_pid(const ob_device_info *info, ob_error **error); + +/** + * @brief Get device vid + * + * @param[in] info Device Information + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return int return device vid + */ +OB_EXPORT int ob_device_info_get_vid(const ob_device_info *info, ob_error **error); + +/** + * @brief Get device uid + * + * @param[in] info Device Information + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return const char* return device uid + */ +OB_EXPORT const char *ob_device_info_get_uid(const ob_device_info *info, ob_error **error); + +/** + * @brief Get device serial number + * + * @param[in] info Device Information + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return const char* return device serial number + */ +OB_EXPORT const char *ob_device_info_get_serial_number(const ob_device_info *info, ob_error **error); + +/** + * @brief Get the firmware version number + * + * @param[in] info Device Information + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return int return the firmware version number + */ +OB_EXPORT const char *ob_device_info_get_firmware_version(const ob_device_info *info, ob_error **error); + +/** + * @brief Get the device connection type + * + * @param[in] info Device Information + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return const char* The connection type, currently supports: "USB", "USB1.0", "USB1.1", "USB2.0", "USB2.1", "USB3.0", "USB3.1", "USB3.2", "Ethernet" + */ +OB_EXPORT const char *ob_device_info_get_connection_type(const ob_device_info *info, ob_error **error); + +/** + * @brief Get the device IP address + * + * @attention Only valid for network devices, otherwise it will return "0.0.0.0" + * + * @param info Device Information + * @param error Pointer to an error object that will be set if an error occurs. + * @return const char* The IP address, such as "192.168.1.10" + */ +OB_EXPORT const char *ob_device_info_get_ip_address(const ob_device_info *info, ob_error **error); + +/** + * @brief Get the hardware version number + * + * @param[in] info Device Information + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return const char* The hardware version number + */ +OB_EXPORT const char *ob_device_info_get_hardware_version(const ob_device_info *info, ob_error **error); + +/** + * @brief Check if the device extension information exists. + * + * @param device The device object. + * @param info_key The key of the device extension information. + * @param error Pointer to an error object that will be set if an error occurs. + * @return bool Whether the device extension information exists. + */ +OB_EXPORT bool ob_device_is_extension_info_exist(const ob_device *device, const char *info_key, ob_error **error); + +/** + * @brief Get the device extension information. + * @brief Extension information is a set of key-value pair of string, user cat get the information by the key. + * + * @param[in] device The device object. + * @param[in] info_key The key of the device extension information. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return const char* The device extension information + */ +OB_EXPORT const char *ob_device_get_extension_info(const ob_device *device, const char *info_key, ob_error **error); + +/** + * @brief Get the minimum SDK version number supported by the device + * + * @param[in] info Device Information + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return const char* The minimum SDK version number supported by the device + */ +OB_EXPORT const char *ob_device_info_get_supported_min_sdk_version(const ob_device_info *info, ob_error **error); + +/** + * @brief Get the chip name + * + * @param[in] info Device Information + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return const char* The ASIC name + */ +OB_EXPORT const char *ob_device_info_get_asicName(const ob_device_info *info, ob_error **error); + +/** + * @brief Get the device type + * + * @param[in] info Device Information + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_device_type The device type + */ +OB_EXPORT ob_device_type ob_device_info_get_device_type(const ob_device_info *info, ob_error **error); + +/** + * @brief Delete a device list. + * + * @param[in] list The device list object to be deleted. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_delete_device_list(ob_device_list *list, ob_error **error); + +/** + * @brief Get the number of devices + * + * @param[in] list Device list object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint32_t return the number of devices + */ +OB_EXPORT uint32_t ob_device_list_get_count(const ob_device_list *list, ob_error **error); + +/** + * @brief Get device name + * + * @param[in] list Device list object + * @param[in] index Device index + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return const char* return device name + */ +OB_EXPORT const char *ob_device_list_get_device_name(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Get the pid of the specified device + * + * @param[in] list Device list object + * @param[in] index Device index + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return int return the device pid + */ +OB_EXPORT int ob_device_list_get_device_pid(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Get the vid of the specified device + * + * @param[in] list Device list object + * @param[in] index Device index + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return int return device vid + */ +OB_EXPORT int ob_device_list_get_device_vid(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Get the uid of the specified device + * + * @param[in] list Device list object + * @param[in] index Device index + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return const char* return the device uid + */ +OB_EXPORT const char *ob_device_list_get_device_uid(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Get the serial number of the specified device. + * + * @param[in] list Device list object. + * @param[in] index Device index. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return const char* The device UID. + */ +OB_EXPORT const char *ob_device_list_get_device_serial_number(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Get device connection type + * + * @param[in] list Device list object + * @param[in] index Device index + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return const char* returns the device connection type, currently supports: "USB", "USB1.0", "USB1.1", "USB2.0", "USB2.1", "USB3.0", "USB3.1", "USB3.2", + * "Ethernet" + */ +OB_EXPORT const char *ob_device_list_get_device_connection_type(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Get device ip address + * + * @attention Only valid for network devices, otherwise it will return "0.0.0.0". + * + * @param list Device list object + * @param index Device index + * @param error Pointer to an error object that will be set if an error occurs. + * @return const char* returns the device ip address, such as "192.168.1.10" + */ +OB_EXPORT const char *ob_device_list_get_device_ip_address(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Get device local mac address + * + * @attention Only valid for network devices, otherwise it will return "0:0:0:0:0:0". + * + * @param list Device list object + * @param index Device index + * @param error Pointer to an error object that will be set if an error occurs. + * @return const char* returns the device mac address + */ +OB_EXPORT const char *ob_device_list_get_device_local_mac(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Create a device. + * + * @attention If the device has already been acquired and created elsewhere, repeated acquisitions will return an error. + * + * @param[in] list Device list object. + * @param[in] index The index of the device to create. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_device* The created device. + * + */ +OB_EXPORT ob_device *ob_device_list_get_device(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Create a device. + * + * @attention If the device has already been acquired and created elsewhere, repeated acquisitions will return an error. + * + * @param[in] list Device list object. + * @param[in] serial_number The serial number of the device to create. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_device* The created device. + */ +OB_EXPORT ob_device *ob_device_list_get_device_by_serial_number(const ob_device_list *list, const char *serial_number, ob_error **error); + +/** + * @brief Create device by uid + * @brief On Linux platform, for usb device, the uid of the device is composed of bus-port-dev, for example 1-1.2-1. But the SDK will remove the dev number and + * only keep the bus-port as the uid to create the device, for example 1-1.2, so that we can create a device connected to the specified USB port. Similarly, + * users can also directly pass in bus-port as uid to create device. + * @brief For GMSL device, the uid is GMSL port with "gmsl2-" prefix, for example gmsl2-1. + * + * @attention If the device has already been acquired and created elsewhere, repeated acquisitions will return an error. + * + * @param[in] list Device list object. + * @param[in] uid The UID of the device to create. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_device* The created device. + */ +OB_EXPORT ob_device *ob_device_list_get_device_by_uid(const ob_device_list *list, const char *uid, ob_error **error); + +/** + * @brief Get the original parameter list of camera calibration saved on the device. + * + * @attention The parameters in the list do not correspond to the current open-stream configuration.You need to select the parameters according to the actual + * situation, and may need to do scaling, mirroring and other processing. Non-professional users are recommended to use the ob_pipeline_get_camera_param() + * interface. + * + * @param[in] device The device object. + * @param[out] error Log error messages. + * + * @return ob_camera_param_list The camera parameter list. + */ +OB_EXPORT ob_camera_param_list *ob_device_get_calibration_camera_param_list(ob_device *device, ob_error **error); + +/** + * @brief Get the number of camera parameter lists + * + * @param[in] param_list Camera parameter list + * @param[out] error Log error messages + * @return uint32_t The number of lists + */ +OB_EXPORT uint32_t ob_camera_param_list_get_count(ob_camera_param_list *param_list, ob_error **error); + +/** + * @brief Get camera parameters from the camera parameter list + * + * @param[in] param_list Camera parameter list + * @param[in] index Parameter index + * @param[out] error Log error messages + * @return ob_camera_param The camera parameters. Since it returns the structure object directly, there is no need to provide a delete interface. + */ +OB_EXPORT ob_camera_param ob_camera_param_list_get_param(ob_camera_param_list *param_list, uint32_t index, ob_error **error); + +/** + * @brief Delete the camera parameter list + * + * @param[in] param_list Camera parameter list + * @param[out] error Log error messages + */ +OB_EXPORT void ob_delete_camera_param_list(ob_camera_param_list *param_list, ob_error **error); + +// The following interfaces are deprecated and are retained here for compatibility purposes. +#define ob_device_list_device_count ob_device_list_get_count +#define ob_device_list_get_extension_info ob_device_info_get_extension_info +#define ob_device_upgrade ob_device_update_firmware +#define ob_device_upgrade_from_data ob_device_update_firmware_from_data +#define ob_device_get_supported_property ob_device_get_supported_property_item +#define ob_device_state_changed ob_device_set_state_changed_callback +#define ob_device_info_name ob_device_info_get_name +#define ob_device_info_pid ob_device_info_get_pid +#define ob_device_info_vid ob_device_info_get_vid +#define ob_device_info_uid ob_device_info_get_uid +#define ob_device_info_serial_number ob_device_info_get_serial_number +#define ob_device_info_firmware_version ob_device_info_get_firmware_version +#define ob_device_info_connection_type ob_device_info_get_connection_type +#define ob_device_info_ip_address ob_device_info_get_ip_address +#define ob_device_info_hardware_version ob_device_info_get_hardware_version +#define ob_device_info_supported_min_sdk_version ob_device_info_get_supported_min_sdk_version +#define ob_device_info_asicName ob_device_info_get_asicName +#define ob_device_info_device_type ob_device_info_get_device_type +#define ob_device_list_get_device_count ob_device_list_get_count +#define ob_camera_param_list_count ob_camera_param_list_get_count + +#ifdef __cplusplus +} +#endif + diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Error.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Error.h new file mode 100644 index 0000000..b9aec31 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Error.h @@ -0,0 +1,84 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Error.h + * @brief Functions for handling errors, mainly used for obtaining error messages. + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ObTypes.h" + +/** + * @brief Create a new error object. + * + * @param status The error status. + * @param message The error message. + * @param function The name of the API function that caused the error. + * @param args The error parameters. + * @param exception_type The type of exception that caused the error. + * @return ob_error* The new error object. + */ +OB_EXPORT ob_error *ob_create_error(ob_status status, const char *message, const char *function, const char *args, ob_exception_type exception_type); + +/** + * @brief Get the error status. + * + * @param[in] error The error object. + * @return The error status. + */ +OB_EXPORT ob_status ob_error_get_status(const ob_error *error); + +/** + * @brief Get the error message. + * + * @param[in] error The error object. + * @return The error message. + */ +OB_EXPORT const char *ob_error_get_message(const ob_error *error); + +/** + * @brief Get the name of the API function that caused the error. + * + * @param[in] error The error object. + * @return The name of the API function. + */ +OB_EXPORT const char *ob_error_get_function(const ob_error *error); + +/** + * @brief Get the error parameters. + * + * @param[in] error The error object. + * @return The error parameters. + */ +OB_EXPORT const char *ob_error_get_args(const ob_error *error); + +/** + * @brief Get the type of exception that caused the error. + * + * @param[in] error The error object. + * @return The type of exception. + */ +OB_EXPORT ob_exception_type ob_error_get_exception_type(const ob_error *error); + +/** + * @brief Delete the error object. + * + * @param[in] error The error object to delete, you should set the pointer to NULL after calling this function. + */ +OB_EXPORT void ob_delete_error(ob_error *error); + +// The following interfaces are deprecated and are retained here for compatibility purposes. +#define ob_error_status ob_error_get_status +#define ob_error_message ob_error_get_message +#define ob_error_function ob_error_get_function +#define ob_error_args ob_error_get_args +#define ob_error_exception_type ob_error_get_exception_type + +#ifdef __cplusplus +} +#endif diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Export.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Export.h new file mode 100644 index 0000000..a8fb41f --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Export.h @@ -0,0 +1,43 @@ + +#ifndef OB_EXPORT_H +#define OB_EXPORT_H + +#ifdef OB_STATIC_DEFINE +# define OB_EXPORT +# define OB_NO_EXPORT +#else +# ifndef OB_EXPORT +# ifdef OrbbecSDK_EXPORTS + /* We are building this library */ +# define OB_EXPORT __attribute__((visibility("default"))) +# else + /* We are using this library */ +# define OB_EXPORT __attribute__((visibility("default"))) +# endif +# endif + +# ifndef OB_NO_EXPORT +# define OB_NO_EXPORT __attribute__((visibility("hidden"))) +# endif +#endif + +#ifndef OB_DEPRECATED +# define OB_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef OB_DEPRECATED_EXPORT +# define OB_DEPRECATED_EXPORT OB_EXPORT OB_DEPRECATED +#endif + +#ifndef OB_DEPRECATED_NO_EXPORT +# define OB_DEPRECATED_NO_EXPORT OB_NO_EXPORT OB_DEPRECATED +#endif + +/* NOLINTNEXTLINE(readability-avoid-unconditional-preprocessor-if) */ +#if 0 /* DEFINE_NO_DEPRECATED */ +# ifndef OB_NO_DEPRECATED +# define OB_NO_DEPRECATED +# endif +#endif + +#endif /* OB_EXPORT_H */ diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Filter.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Filter.h new file mode 100644 index 0000000..a03f857 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Filter.h @@ -0,0 +1,265 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Filter.h + * @brief The processing unit of the SDK can perform point cloud generation, format conversion and other functions. + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ObTypes.h" + +/** + * @brief Create a Filter object. + * + * @attention If the filter of the specified name is a private filter, and the creator of the filter have not been activated, the function will return NULL. + * + * @param name The name of the filter. + * @param error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT ob_filter *ob_create_filter(const char *name, ob_error **error); + +/** + * @brief Get the name of ob_filter + * + * @param filter ob_filter object + * @param error Pointer to an error object that will be set if an error occurs. + * @return char The filter of name + */ +OB_EXPORT const char *ob_filter_get_name(const ob_filter *filter, ob_error **error); + +/** + * @brief Get the vendor specific code of a filter by filter name. + * @brief A private filter can define its own vendor specific code for specific purposes. + * + * @param name The name of the filter. + * @param error Pointer to an error object that will be set if an error occurs. + * @return const char* Return the vendor specific code of the filter. + */ +OB_EXPORT const char *ob_filter_get_vendor_specific_code(const char *name, ob_error **error); + +/** + * @brief Create a private Filter object with activation key. + * @brief Some private filters require an activation key to be activated, its depends on the vendor of the filter. + * + * @param name The name of the filter. + * @param activation_key The activation key of the filter. + * @param error Pointer to an error object that will be set if an error occurs. + * + * @return ob_filter* Return the private filter object. + */ +OB_EXPORT ob_filter *ob_create_private_filter(const char *name, const char *activation_key, ob_error **error); + +/** + * @brief Delete the filter. + * + * @param[in] filter The filter object to be deleted. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_delete_filter(ob_filter *filter, ob_error **error); + +/** + * @brief Get config schema of the filter + * @brief The returned string is a csv format string representing the configuration schema of the filter. The format of the string is: + * , , , , , , + * + * @param[in] filter The filter object to get the configuration schema for + * @param[out] error Pointer to an error object that will be set if an error occurs + * + * @return A csv format string representing the configuration schema of the filter + */ +OB_EXPORT const char *ob_filter_get_config_schema(const ob_filter *filter, ob_error **error); + +/** + * @brief Get the filter config schema list of the filter + * @brief The returned string is a list of ob_config_schema_item representing the configuration schema of the filter. + * + * @attention The returned list should be deleted by calling @ref ob_delete_filter_config_schema_list when it is no longer needed. + * + * @param filter The filter object to get the configuration schema for + * @param error Pointer to an error object that will be set if an error occurs + * @return ob_filter_config_schema_list* Return the filter config schema list of the filter + */ +OB_EXPORT ob_filter_config_schema_list *ob_filter_get_config_schema_list(const ob_filter *filter, ob_error **error); + +/** + * @brief Delete a list of filter config schema items. + * + * @param config_schema_list The list of filter config schema items to delete. + * @param error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_delete_filter_config_schema_list(ob_filter_config_schema_list *config_schema_list, ob_error **error); + +/** + * @brief Update config of the filter + * + * @attention The passed in argc and argv must match the configuration schema returned by the @ref ob_filter_get_config_schema function. + * + * @param[in] filter The filter object to update the configuration for + * @param[in] argc The number of arguments in the argv array + * @param[in] argv An array of strings representing the configuration values + * @param[out] error Pointer to an error object that will be set if an error occurs + */ +OB_EXPORT void ob_filter_update_config(ob_filter *filter, uint8_t argc, const char **argv, ob_error **error); + +/** + * @brief Get the filter config value by name and cast to double. + * + * @attention The returned value is cast to double, the actual type of the value depends on the filter config schema returned by @ref + * ob_filter_get_config_schema. + * + * @param[in] filter A filter object. + * @param[in] config_name config name + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return double The value of the config. + */ +OB_EXPORT double ob_filter_get_config_value(const ob_filter *filter, const char *config_name, ob_error **error); + +/** + * @brief Set the filter config value by name. + * + * @attention The pass into value type is double, witch will be cast to the actual type inside the filter. The actual type can be queried by the filter config + * schema returned by @ref ob_filter_get_config_schema. + * + * @param[in] filter A filter object. + * @param[in] config_name config name + * @param[in] value The value to set. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_filter_set_config_value(ob_filter *filter, const char *config_name, double value, ob_error **error); + +/** + * @brief Reset the filter, clears the cache, and resets the state. If the asynchronous interface is used, the processing thread will also be stopped and the + * pending cache frames will be cleared. + * + * @param[in] filter A filter object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_filter_reset(ob_filter *filter, ob_error **error); + +/** + * @brief Enable the frame post processing + * @brief The filter default is enable. + * + * @attention If the filter has been disabled by calling this function, processing will directly output a clone of the input frame. + * + * @param[in] filter A filter object. + * @param[in] enable enable status, true: enable; false: disable. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_filter_enable(ob_filter *filter, bool enable, ob_error **error); + +/** + * @brief Get the enable status of the frame post processing + * + * @attention If the filter is disabled, the processing will directly output a clone of the input frame. + * + * @param[in] filter A filter object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return The post processing filter status. True: enable; False: disable. + */ +OB_EXPORT bool ob_filter_is_enabled(const ob_filter *filter, ob_error **error); + +/** + * @brief Process the frame (synchronous interface). + * + * @param[in] filter A filter object. + * @param[in] frame Pointer to the frame object to be processed. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return The frame object processed by the filter. + */ +OB_EXPORT ob_frame *ob_filter_process(ob_filter *filter, const ob_frame *frame, ob_error **error); + +/** + * @brief Set the processing result callback function for the filter (asynchronous callback interface). + * + * @param[in] filter A filter object. + * @param[in] callback Callback function. + * @param[in] user_data Arbitrary user data pointer can be passed in and returned from the callback. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_filter_set_callback(ob_filter *filter, ob_filter_callback callback, void *user_data, ob_error **error); + +/** + * @brief Push the frame into the pending cache for the filter (asynchronous callback interface). + * @brief The frame will be processed by the filter when the processing thread is available and return a new processed frame to the callback function. + * + * @attention The frame object will be add reference count, so the user still need call @ref ob_delete_frame to release the frame after calling this function. + * + * @param[in] filter A filter object. + * @param[in] frame Pointer to the frame object to be processed. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_filter_push_frame(ob_filter *filter, const ob_frame *frame, ob_error **error); + +/** + * @brief Get the number of filter in the list + * + * @param[in] filter_list filter list + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint32_t The number of list + */ +OB_EXPORT uint32_t ob_filter_list_get_count(const ob_filter_list *filter_list, ob_error **error); + +/** + * @brief Get the filter by index + * + * @param[in] filter_list Filter list + * @param[in] index Filter index + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_filter The index of ob_filter + */ +OB_EXPORT ob_filter *ob_filter_list_get_filter(const ob_filter_list *filter_list, uint32_t index, ob_error **error); + +/** + * @brief Delete a list of ob_filter objects. + * + * @param[in] filter_list The list of ob_filter objects to delete. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_delete_filter_list(ob_filter_list *filter_list, ob_error **error); + +/** + * @brief Get the number of config schema items in the config schema list + * + * @param config_schema_list Filter config schema list + * @param error Pointer to an error object that will be set if an error occurs. + * @return uint32_t The number of config schema items in the filter list + */ +OB_EXPORT uint32_t ob_filter_config_schema_list_get_count(const ob_filter_config_schema_list *config_schema_list, ob_error **error); + +/** + * @brief Get the config schema item by index + * + * @param config_schema_list Filter config schema list + * @param index Config schema item index + * @param error Pointer to an error object that will be set if an error occurs. + * @return ob_filter_config_schema_item* The config schema item by index + */ +OB_EXPORT ob_filter_config_schema_item ob_filter_config_schema_list_get_item(const ob_filter_config_schema_list *config_schema_list, uint32_t index, + ob_error **error); + +/** + * @brief Set the align to stream profile for the align filter. + * @breif It is useful when the align target stream dose not started (without any frame to get intrinsics and extrinsics). + * + * @param filter A filter object. + * @param align_to_stream_profile The align target stream profile. + * @param error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_align_filter_set_align_to_stream_profile(ob_filter *filter, const ob_stream_profile *align_to_stream_profile, ob_error **error); + +// The following interfaces are deprecated and are retained here for compatibility purposes. +#define ob_get_filter ob_filter_list_get_filter +#define ob_get_filter_name ob_filter_get_name + +#ifdef __cplusplus +} +#endif + diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Frame.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Frame.h new file mode 100644 index 0000000..923e252 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Frame.h @@ -0,0 +1,657 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Frame.h + * @brief Frame related function is mainly used to obtain frame data and frame information + * + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ObTypes.h" + +/** + * @brief Crate a frame object based on the specified parameters. + * + * @attention The frame object is created with a reference count of 1, and the reference count should be decreased by calling @ref ob_delete_frame() when it is + * no longer needed. + * + * @param frame_type The frame object type. + * @param format The frame object format. + * @param data_size The size of the frame object data. + * @param error Pointer to an error object that will be set if an error occurs. + * @return ob_frame* Return the frame object. + */ +OB_EXPORT ob_frame *ob_create_frame(ob_frame_type frame_type, ob_format format, uint32_t data_size, ob_error **error); + +/** + * @brief Create (clone) a frame object based on the specified other frame object. + * @brief The new frame object will have the same properties as the other frame object, but the data buffer is newly allocated. + * + * @attention The frame object is created with a reference count of 1, and the reference count should be decreased by calling @ref ob_delete_frame() when it is + * no longer needed. + * + * @param[in] other_frame The frame object to create the new frame object according to. + * @param[in] should_copy_data If true, the data of the source frame object will be copied to the new frame object. If false, the new frame object will + * have a data buffer with random data. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_frame* Return the new frame object. + */ +OB_EXPORT ob_frame *ob_create_frame_from_other_frame(const ob_frame *other_frame, bool should_copy_data, ob_error **error); + +/** + * @brief Create a frame object according to the specified stream profile. + * + * @attention The frame object is created with a reference count of 1, and the reference count should be decreased by calling @ref ob_delete_frame() when it is + * no logger needed. + * + * @param stream_profile The stream profile to create the new frame object according to. + * @param error Pointer to an error object that will be set if an error occurs. + * @return ob_frame* Return the new frame object. + */ +OB_EXPORT ob_frame *ob_create_frame_from_stream_profile(const ob_stream_profile *stream_profile, ob_error **error); + +/** + * @brief Create an video frame object based on the specified parameters. + * + * @attention The frame object is created with a reference count of 1, and the reference count should be decreased by calling @ref ob_delete_frame() when it is + * no longer needed. + * + * @param[in] frame_type Frame object type. + * @param[in] format Frame object format. + * @param[in] width Frame object width. + * @param[in] height Frame object height. + * @param[in] stride_bytes Row span in bytes. If 0, the stride is calculated based on the width and format. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_frame* Return an empty frame object. + */ +OB_EXPORT ob_frame *ob_create_video_frame(ob_frame_type frame_type, ob_format format, uint32_t width, uint32_t height, uint32_t stride_bytes, ob_error **error); + +/** + * @brief Create a frame object based on an externally created buffer. + * + * @attention The buffer is owned by the user and will not be destroyed by the frame object. The user should ensure that the buffer is valid and not modified. + * @attention The frame object is created with a reference count of 1, and the reference count should be decreased by calling @ref ob_delete_frame() when it is + * no longer needed. + * + * @param[in] frame_type Frame object type. + * @param[in] format Frame object format. + * @param[in] buffer Frame object buffer. + * @param[in] buffer_size Frame object buffer size. + * @param[in] buffer_destroy_cb Destroy callback, will be called when the frame object is destroyed. + * @param[in] buffer_destroy_context Destroy context, user-defined context to be passed to the destroy callback. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_frame* Return the frame object. + */ +OB_EXPORT ob_frame *ob_create_frame_from_buffer(ob_frame_type frame_type, ob_format format, uint8_t *buffer, uint32_t buffer_size, + ob_frame_destroy_callback *buffer_destroy_cb, void *buffer_destroy_context, ob_error **error); + +/** + * @brief Create a video frame object based on an externally created buffer. + * + * @attention The buffer is owned by the user and will not be destroyed by the frame object. The user should ensure that the buffer is valid and not modified. + * @attention The frame object is created with a reference count of 1, and the reference count should be decreased by calling @ref ob_delete_frame() when it is + * no longer needed. + * + * @param[in] frame_type Frame object type. + * @param[in] format Frame object format. + * @param[in] width Frame object width. + * @param[in] height Frame object height. + * @param[in] stride_bytes Row span in bytes. If 0, the stride is calculated based on the width and format. + * @param[in] buffer Frame object buffer. + * @param[in] buffer_size Frame object buffer size. + * @param[in] buffer_destroy_cb Destroy callback, user-defined function to destroy the buffer. + * @param[in] buffer_destroy_context Destroy context, user-defined context to be passed to the destroy callback. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_frame* Return the frame object. + */ +OB_EXPORT ob_frame *ob_create_video_frame_from_buffer(ob_frame_type frame_type, ob_format format, uint32_t width, uint32_t height, uint32_t stride_bytes, + uint8_t *buffer, uint32_t buffer_size, ob_frame_destroy_callback *buffer_destroy_cb, + void *buffer_destroy_context, ob_error **error); + +/** + * @brief Create an empty frameset object. + * @brief A frameset object is a special type of frame object that can be used to store multiple frames. + * + * @attention The frameset object is created with a reference count of 1, and the reference count should be decreased by calling @ref ob_delete_frame() when it + * is no longer needed. + * + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_frame* Return the frameset object. + */ +OB_EXPORT ob_frame *ob_create_frameset(ob_error **error); + +/** + * @brief Increase the reference count of a frame object. + * @brief The reference count is used to manage the lifetime of the frame object. + * + * @attention When calling this function, the reference count of the frame object is + * increased and requires to be decreased by calling @ref ob_delete_frame(). + * + * @param[in] frame Frame object to increase the reference count. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_frame_add_ref(const ob_frame *frame, ob_error **error); + +/** + * @brief Delete a frame object + * @brief This function will decrease the reference count of the frame object and release the memory if the reference count becomes 0. + * + * @param[in] frame The frame object to delete. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_delete_frame(const ob_frame *frame, ob_error **error); + +/** + * @brief Copy the information of the source frame object to the destination frame object. + * @brief Including the index, timestamp, system timestamp, global timestamp and metadata will be copied. + * + * @param[in] src_frame Source frame object to copy the information from. + * @param[in] dst_frame Destination frame object to copy the information to. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_frame_copy_info(const ob_frame *src_frame, ob_frame *dst_frame, ob_error **error); + +/** + * @brief Get the frame index + * + * @param[in] frame Frame object + * @param[out] error Log wrong message + * @return uint64_t return the frame index + */ +OB_EXPORT uint64_t ob_frame_get_index(const ob_frame *frame, ob_error **error); + +/** + * @brief Get the frame format + * + * @param[in] frame Frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_format return the frame format + */ +OB_EXPORT ob_format ob_frame_get_format(const ob_frame *frame, ob_error **error); + +/** + * @brief Get the frame type + * + * @param[in] frame Frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_frame_type return the frame type + */ +OB_EXPORT ob_frame_type ob_frame_get_type(const ob_frame *frame, ob_error **error); + +/** + * @brief Get the frame timestamp (also known as device timestamp, hardware timestamp) of the frame in microseconds. + * @brief The hardware timestamp is the time point when the frame was captured by the device (Typically in the mid-exposure, unless otherwise stated), on device + * clock domain. + * + * @param[in] frame Frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint64_t return the frame hardware timestamp in microseconds + */ +OB_EXPORT uint64_t ob_frame_get_timestamp_us(const ob_frame *frame, ob_error **error); + +/** + * @brief Set the frame timestamp (also known as the device timestamp, hardware timestamp) of a frame object. + * + * @param[in] frame Frame object to set the timestamp. + * @param[in] timestamp_us frame timestamp to set in microseconds. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_frame_set_timestamp_us(ob_frame *frame, uint64_t timestamp_us, ob_error **error); + +/** + * @brief Get the system timestamp of the frame in microseconds. + * @brief The system timestamp is the time point when the frame was received by the host, on host clock domain. + * + * @param[in] frame Frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint64_t return the frame system timestamp in microseconds + */ +OB_EXPORT uint64_t ob_frame_get_system_timestamp_us(const ob_frame *frame, ob_error **error); + +/** + * @brief Set the system timestamp of the frame in microseconds. + * + * @param frame Frame object + * @param system_timestamp_us frame system timestamp to set in microseconds. + * @param error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_frame_set_system_timestamp_us(ob_frame *frame, uint64_t system_timestamp_us, ob_error **error); + +/** + * @brief Get the global timestamp of the frame in microseconds. + * @brief The global timestamp is the time point when the frame was captured by the device, and has been converted to the host clock domain. The + * conversion process base on the frame timestamp and can eliminate the timer drift of the device + * + * @attention The global timestamp is disabled by default. If global timestamp is not enabled, the function will return 0. To enable it, call @ref + * ob_device_enable_global_timestamp() function. + * @attention Only some models of device support getting the global timestamp. Check the device support status by @ref + * ob_device_is_global_timestamp_supported() function. + * + * @param[in] frame Frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint64_t The global timestamp of the frame in microseconds. + */ +OB_EXPORT uint64_t ob_frame_get_global_timestamp_us(const ob_frame *frame, ob_error **error); + +/** + * @brief Get the data buffer of a frame. + * + * @attention The returned data buffer is mutable, but it is not recommended to modify it directly. Modifying the data directly may cause issues if the frame is + * being used in other threads or future use. If you need to modify the data, it is recommended to create a new frame object. + * + * @param[in] frame The frame object from which to retrieve the data. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint8_t* Pointer to the frame data buffer. + */ +OB_EXPORT uint8_t *ob_frame_get_data(const ob_frame *frame, ob_error **error); + +/** + * @brief Update the data of a frame. + * @brief The data will be memcpy to the frame data buffer. + * @brief The frame data size will be also updated as the input data size. + * + * @attention It is not recommended to update the frame data if the frame was not created by the user. If you must update it, ensure that the frame is not being + * used in other threads. + * @attention The size of the new data should be equal to or less than the current data size of the frame. Exceeding the original size may cause memory + * exceptions. + * + * @param[in] frame The frame object to update. + * @param[in] data The new data to update the frame with. + * @param[in] data_size The size of the new data. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_frame_update_data(ob_frame *frame, const uint8_t *data, uint32_t data_size, ob_error **error); + +/** + * @brief Get the frame data size + * + * @param[in] frame Frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint32_t return the frame data size + * If it is point cloud data, it return the number of bytes occupied by all point sets. If you need to find the number of points, you need to divide dataSize + * by the structure size of the corresponding point type. + */ +OB_EXPORT uint32_t ob_frame_get_data_size(const ob_frame *frame, ob_error **error); + +/** + * @brief Get the metadata of the frame + * + * @attention The returned metadata is mutable, but it is not recommended to modify it directly. Modifying the metadata directly may cause issues if the frame + * is being used in other threads or future use. If you need to modify the metadata, it is recommended to create a new frame object. + * + * @param[in] frame frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return const uint8_t * return the metadata pointer of the frame + */ +OB_EXPORT uint8_t *ob_frame_get_metadata(const ob_frame *frame, ob_error **error); +#define ob_video_frame_metadata ob_frame_get_metadata // for compatibility + +/** + * @brief Get the metadata size of the frame + * + * @param[in] frame frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint32_t return the metadata size of the frame + */ +OB_EXPORT uint32_t ob_frame_get_metadata_size(const ob_frame *frame, ob_error **error); +#define ob_video_frame_metadata_size ob_frame_get_metadata_size // for compatibility + +/** + * @brief Update the metadata of the frame + * @brief The metadata will be memcpy to the frame metadata buffer. + * @brief The frame metadata size will be also updated as the input metadata size. + * + * @attention It is not recommended to update the frame metadata if the frame was not created by the user. If you must update it, ensure that the frame is not + * being used in other threads or future use. + * @attention The metadata size should be equal to or less than 256 bytes, otherwise it will cause memory exception. + * + * @param[in] frame frame object + * @param[in] metadata The new metadata to update. + * @param[in] metadata_size The size of the new metadata. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_frame_update_metadata(ob_frame *frame, const uint8_t *metadata, uint32_t metadata_size, ob_error **error); + +/** + * @brief check if the frame contains the specified metadata + * + * @param[in] frame frame object + * @param[in] type metadata type, refer to @ref ob_frame_metadata_type + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT bool ob_frame_has_metadata(const ob_frame *frame, ob_frame_metadata_type type, ob_error **error); + +/** + * @brief Get the metadata value of the frame + * + * @param[in] frame frame object + * @param[in] type metadata type, refer to @ref ob_frame_metadata_type + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return int64_t return the metadata value of the frame + */ +OB_EXPORT int64_t ob_frame_get_metadata_value(const ob_frame *frame, ob_frame_metadata_type type, ob_error **error); + +/** + * @brief Get the stream profile of the frame + * + * @attention Require @ref ob_delete_stream_profile() to release the return stream profile. + * + * @param frame frame object + * @param error Pointer to an error object that will be set if an error occurs. + * @return ob_stream_profile* Return the stream profile of the frame, if the frame is not captured by a sensor stream, it will return NULL + */ +OB_EXPORT ob_stream_profile *ob_frame_get_stream_profile(const ob_frame *frame, ob_error **error); + +/** + * @brief Set (override) the stream profile of the frame + * + * @param frame frame object + * @param stream_profile The stream profile to set for the frame. + * @param error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_frame_set_stream_profile(ob_frame *frame, const ob_stream_profile *stream_profile, ob_error **error); + +/** + * @brief Get the sensor of the frame + * + * @attention Require @ref ob_delete_sensor() to release the return sensor. + * + * @param[in] frame frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_sensor* return the sensor of the frame, if the frame is not captured by a sensor or the sensor stream has been destroyed, it will return NULL + */ +OB_EXPORT ob_sensor *ob_frame_get_sensor(const ob_frame *frame, ob_error **error); + +/** + * @brief Get the device of the frame + * + * @attention Require @ref ob_delete_device() to release the return device. + * + * @param frame frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_device* return the device of the frame, if the frame is not captured by a sensor stream or the device has been destroyed, it will return NULL + */ +OB_EXPORT ob_device *ob_frame_get_device(const ob_frame *frame, ob_error **error); + +/** + * @brief Get video frame width + * + * @param[in] frame Frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint32_t return the frame width + */ +OB_EXPORT uint32_t ob_video_frame_get_width(const ob_frame *frame, ob_error **error); + +/** + * @brief Get video frame height + * + * @param[in] frame Frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint32_t return the frame height + */ +OB_EXPORT uint32_t ob_video_frame_get_height(const ob_frame *frame, ob_error **error); + +/** + * @brief Get video frame pixel format + * @brief Usually used to determine the pixel type of depth frame (depth, disparity, raw phase, etc.) + * + * @attention Always return OB_PIXEL_UNKNOWN for non-depth frame currently if user has not set the pixel type by @ref ob_video_frame_set_pixel_type() + * + * @param frame Frame object + * @param error Pointer to an error object that will be set if an error occurs. + * @return ob_pixel_type return the pixel format of the frame. + */ +OB_EXPORT ob_pixel_type ob_video_frame_get_pixel_type(const ob_frame *frame, ob_error **error); + +/** + * @brief Set video frame pixel format + * + * @param frame Frame object + * @param pixel_type the pixel format of the frame + * @param error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_video_frame_set_pixel_type(ob_frame *frame, ob_pixel_type pixel_type, ob_error **error); + +/** + * @brief Get the effective number of pixels (such as Y16 format frame, but only the lower 10 bits are effective bits, and the upper 6 bits are filled with 0) + * @attention Only valid for Y8/Y10/Y11/Y12/Y14/Y16 format + * + * @param[in] frame video frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint8_t return the effective number of pixels in the pixel, or 0 if it is an unsupported format + */ +OB_EXPORT uint8_t ob_video_frame_get_pixel_available_bit_size(const ob_frame *frame, ob_error **error); + +/** + * @brief Set the effective number of pixels (such as Y16 format frame, but only the lower 10 bits are effective bits, and the upper 6 bits are filled with 0) + * @attention Only valid for Y8/Y10/Y11/Y12/Y14/Y16 format + * + * @param[in] frame video frame object + * @param[in] bit_size the effective number of pixels in the pixel, or 0 if it is an unsupported format + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_video_frame_set_pixel_available_bit_size(ob_frame *frame, uint8_t bit_size, ob_error **error); + +/** + * @brief Get the source sensor type of the ir frame (left or right for dual camera) + * + * @param frame Frame object + * @param ob_error Pointer to an error object that will be set if an error occurs. + * @return ob_sensor_type return the source sensor type of the ir frame + */ +OB_EXPORT ob_sensor_type ob_ir_frame_get_source_sensor_type(const ob_frame *frame, ob_error **ob_error); + +/** + * @brief Get the value scale of the depth frame. The pixel value of the depth frame is multiplied by the scale to give a depth value in millimeters. + * For example, if valueScale=0.1 and a certain coordinate pixel value is pixelValue=10000, then the depth value = pixelValue*valueScale = 10000*0.1=1000mm. + * + * @param[in] frame Frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return float The value scale of the depth frame + */ +OB_EXPORT float ob_depth_frame_get_value_scale(const ob_frame *frame, ob_error **error); + +/** + * @brief Set the value scale of the depth frame. The pixel value of the depth frame is multiplied by the scale to give a depth value in millimeters. + * For example, if valueScale=0.1 and a certain coordinate pixel value is pixelValue=10000, then the depth value = pixelValue*valueScale = 10000*0.1=1000mm. + * + * @param[in] frame Frame object + * @param[in] value_scale The value scale of the depth frame + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_depth_frame_set_value_scale(ob_frame *frame, float value_scale, ob_error **error); + +/** + * @brief Get the point coordinate value scale of the points frame. The point position value of the points frame is multiplied by the scale to give a position + * value in millimeters. For example, if scale=0.1, the x-coordinate value of a point is x = 10000, which means that the actual x-coordinate value = x*scale = + * 10000*0.1 = 1000mm. + * + * @param[in] frame Frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return float The coordinate value scale of the points frame + */ +OB_EXPORT float ob_points_frame_get_coordinate_value_scale(const ob_frame *frame, ob_error **error); + +/** + * @brief Get accelerometer frame data. + * + * @param[in] frame Accelerometer frame. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_accel_value Return the accelerometer data. + */ +OB_EXPORT ob_accel_value ob_accel_frame_get_value(const ob_frame *frame, ob_error **error); + +/** + * @brief Get the temperature when acquiring the accelerometer frame. + * + * @param[in] frame Accelerometer frame. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return float Return the temperature value. + */ +OB_EXPORT float ob_accel_frame_get_temperature(const ob_frame *frame, ob_error **error); + +/** + * @brief Get gyroscope frame data. + * + * @param[in] frame Gyroscope frame. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_gyro_value Return the gyroscope data. + */ +OB_EXPORT ob_gyro_value ob_gyro_frame_get_value(const ob_frame *frame, ob_error **error); + +/** + * @brief Get the temperature when acquiring the gyroscope frame. + * + * @param[in] frame Gyroscope frame. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return float Return the temperature value. + */ +OB_EXPORT float ob_gyro_frame_get_temperature(const ob_frame *frame, ob_error **error); + +/** + * @brief Get the number of frames contained in the frameset + * + * @attention The frame returned by this function should call @ref ob_delete_frame() to decrease the reference count when it is no longer needed. + * + * @param[in] frameset frameset object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint32_t return the number of frames + */ +OB_EXPORT uint32_t ob_frameset_get_count(const ob_frame *frameset, ob_error **error); + +/** + * @brief Get the depth frame from the frameset. + * + * @attention The frame returned by this function should call @ref ob_delete_frame() to decrease the reference count when it is no longer needed. + * + * @param[in] frameset Frameset object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_frame* Return the depth frame. + */ +OB_EXPORT ob_frame *ob_frameset_get_depth_frame(const ob_frame *frameset, ob_error **error); + +/** + * @brief Get the color frame from the frameset. + * + * @attention The frame returned by this function should call @ref ob_delete_frame() to decrease the reference count when it is no longer needed. + * + * @param[in] frameset Frameset object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_frame* Return the color frame. + */ +OB_EXPORT ob_frame *ob_frameset_get_color_frame(const ob_frame *frameset, ob_error **error); + +/** + * @brief Get the infrared frame from the frameset. + * + * @attention The frame returned by this function should call @ref ob_delete_frame() to decrease the reference count when it is no longer needed. + * + * @param[in] frameset Frameset object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_frame* Return the infrared frame. + */ +OB_EXPORT ob_frame *ob_frameset_get_ir_frame(const ob_frame *frameset, ob_error **error); + +/** + * @brief Get point cloud frame from the frameset. + * + * @attention The frame returned by this function should call @ref ob_delete_frame() to decrease the reference count when it is no longer needed. + * + * @param[in] frameset Frameset object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_frame* Return the point cloud frame. + */ +OB_EXPORT ob_frame *ob_frameset_get_points_frame(const ob_frame *frameset, ob_error **error); + +/** + * @brief Get a frame of a specific type from the frameset. + * + * @attention The frame returned by this function should call @ref ob_delete_frame() to decrease the reference count when it is no longer needed. + * + * @param[in] frameset Frameset object. + * @param[in] frame_type Frame type. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_frame* Return the frame of the specified type, or nullptr if it does not exist. + */ +OB_EXPORT ob_frame *ob_frameset_get_frame(const ob_frame *frameset, ob_frame_type frame_type, ob_error **error); + +/** + * @brief Get a frame at a specific index from the FrameSet + * + * @param[in] frameset Frameset object. + * @param[in] index The index of the frame. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_frame* Return the frame at the specified index, or nullptr if it does not exist. + */ +OB_EXPORT ob_frame *ob_frameset_get_frame_by_index(const ob_frame *frameset, uint32_t index, ob_error **error); + +/** + * @brief Push a frame to the frameset + * + * @attention If a frame with same type already exists in the frameset, it will be replaced by the new frame. + * @attention The frame push to the frameset will be add reference count, so you still need to call @ref ob_delete_frame() to decrease the reference count when + * it is no longer needed. + * + * @param[in] frameset Frameset object. + * @param[in] frame Frame object to push. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_frameset_push_frame(ob_frame *frameset, const ob_frame *frame, ob_error **error); + +/** + * @brief Get point cloud frame width + * + * @param[in] frame point cloud Frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint32_t return the point cloud frame width + */ +OB_EXPORT uint32_t ob_point_cloud_frame_get_width(const ob_frame *frame, ob_error **error); + +/** + * @brief Get point cloud frame height + * + * @param[in] frame point cloud Frame object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint32_t return the point cloud frame height + */ +OB_EXPORT uint32_t ob_point_cloud_frame_get_height(const ob_frame *frame, ob_error **error); + +// The following interfaces are deprecated and are retained here for compatibility purposes. +#define ob_frame_index ob_frame_get_index +#define ob_frame_format ob_frame_get_format +#define ob_frame_time_stamp_us ob_frame_get_timestamp_us +#define ob_frame_set_device_time_stamp_us ob_frame_set_timestamp_us +#define ob_frame_system_time_stamp_us ob_frame_get_system_timestamp_us +#define ob_frame_global_time_stamp_us ob_frame_get_global_timestamp_us +#define ob_frame_data ob_frame_get_data +#define ob_frame_data_size ob_frame_get_data_size +#define ob_frame_metadata ob_frame_get_metadata +#define ob_frame_metadata_size ob_frame_get_metadata_size +#define ob_video_frame_width ob_video_frame_get_width +#define ob_video_frame_height ob_video_frame_get_height +#define ob_video_frame_pixel_available_bit_size ob_video_frame_get_pixel_available_bit_size +#define ob_points_frame_get_position_value_scale ob_points_frame_get_coordinate_value_scale +#define ob_frameset_frame_count ob_frameset_get_count +#define ob_frameset_depth_frame ob_frameset_get_depth_frame +#define ob_frameset_color_frame ob_frameset_get_color_frame +#define ob_frameset_ir_frame ob_frameset_get_ir_frame +#define ob_frameset_points_frame ob_frameset_get_points_frame +#define ob_accel_frame_value ob_accel_frame_get_value +#define ob_accel_frame_temperature ob_accel_frame_get_temperature +#define ob_gyro_frame_value ob_gyro_frame_get_value +#define ob_gyro_frame_temperature ob_gyro_frame_get_temperature +#define ob_frameset_get_frame_count ob_frameset_get_count + +#define ob_frame_time_stamp(frame, err) (ob_frame_get_timestamp_us(frame, err) / 1000) +#define ob_frame_system_time_stamp(frame, err) (ob_frame_get_system_timestamp_us(frame, err)) +#define ob_frame_set_system_time_stamp(frame, system_timestamp, err) (ob_frame_set_system_timestamp_us(frame, system_timestamp * 1000, err)) +#define ob_frame_set_device_time_stamp(frame, device_timestamp, err) (ob_frame_set_timestamp_us(frame, device_timestamp * 1000, err)) + +#ifdef __cplusplus +} +#endif diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/MultipleDevices.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/MultipleDevices.h new file mode 100644 index 0000000..adb0947 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/MultipleDevices.h @@ -0,0 +1,128 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file MultipleDevices.h + * @brief This file contains the multiple devices related API witch is used to control the synchronization between multiple devices and the synchronization + * between different sensor within single device. + * @brief The synchronization between multiple devices is complex, and different models have different synchronization modes and limitations. please refer to + * the product manual for details. + * @brief As the Depth and Infrared are the same sensor physically, the behavior of the Infrared is same as the Depth in the synchronization mode. + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ObTypes.h" +#include "Device.h" + +/** + * @brief Get the supported multi device sync mode bitmap of the device. + * @brief For example, if the return value is 0b00001100, it means the device supports @ref OB_MULTI_DEVICE_SYNC_MODE_PRIMARY and @ref + * OB_MULTI_DEVICE_SYNC_MODE_SECONDARY. User can check the supported mode by the code: + * ```c + * if(supported_mode_bitmap & OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN){ + * //support OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN + * } + * if(supported_mode_bitmap & OB_MULTI_DEVICE_SYNC_MODE_STANDALONE){ + * //support OB_MULTI_DEVICE_SYNC_MODE_STANDALONE + * } + * // and so on + * ``` + * @param[in] device The device handle. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint16_t return the supported multi device sync mode bitmap of the device. + */ +OB_EXPORT uint16_t ob_device_get_supported_multi_device_sync_mode_bitmap(const ob_device *device, ob_error **error); + +/** + * @brief set the multi device sync configuration of the device. + * + * @param[in] device The device handle. + * @param[in] config The multi device sync configuration. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_set_multi_device_sync_config(ob_device *device, const ob_multi_device_sync_config *config, ob_error **error); + +/** + * @brief get the current multi device sync configuration of the device. + * + * @param[in] device The device handle. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_multi_device_sync_config return the multi device sync configuration of the device. + */ +OB_EXPORT ob_multi_device_sync_config ob_device_get_multi_device_sync_config(const ob_device *device, ob_error **error); + +/** + * @brief send the capture command to the device to trigger the capture. + * @brief The device will start one time capture after receiving the capture command when it is in the @ref OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING + * + * @attention The frequency of the user call this function multiplied by the number of frames per trigger should be less than the frame rate of the stream. The + * number of frames per trigger can be set by @ref framesPerTrigger. + * @attention For some models, receive and execute the capture command will have a certain delay and performance consumption, so the frequency of calling this + * function should not be too high, please refer to the product manual for the specific supported frequency. + * @attention If the device is not in the @ref OB_MULTI_DEVICE_SYNC_MODE_HARDWARE_TRIGGERING mode, device will ignore the capture command. + * + * @param[in] device The device handle. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_trigger_capture(ob_device *device, ob_error **error); + +/** + * @brief set the timestamp reset configuration of the device. + * + * @param[in] device The device handle. + * @param[in] config The timestamp reset configuration. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_set_timestamp_reset_config(ob_device *device, const ob_device_timestamp_reset_config *config, ob_error **error); + +/** + * @brief get the timestamp reset configuration of the device. + * + * @param[in] device The device handle. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_device_timestamp_reset_config return the timestamp reset configuration of the device. + */ +OB_EXPORT ob_device_timestamp_reset_config ob_device_get_timestamp_reset_config(ob_device *device, ob_error **error); + +/** + * @brief send the timestamp reset command to the device. + * @brief The device will reset the timer for calculating the timestamp for output frames to 0 after receiving the timestamp reset command when the timestamp + * reset function is enabled. The timestamp reset function can be enabled by call @ref ob_device_set_timestamp_reset_config. + * + * @attention If the stream of the device is started, the timestamp of the continuous frames output by the stream will jump once after the timestamp reset. + * @attention Due to the timer of device is not high-accuracy, the timestamp of the continuous frames output by the stream will drift after a long time. User + * can call this function periodically to reset the timer to avoid the timestamp drift, the recommended interval time is 60 minutes. + * + * @param[in] device The device handle. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_timestamp_reset(ob_device *device, ob_error **error); + +/** + * @brief Alias for @ref ob_device_timestamp_reset since it is more accurate. + */ +#define ob_device_timer_reset ob_device_timestamp_reset + +/** + * @brief synchronize the timer of the device with the host. + * @brief After calling this function, the timer of the device will be synchronized with the host. User can call this function to multiple devices to + * synchronize all timers of the devices. + * + * @attention If the stream of the device is started, the timestamp of the continuous frames output by the stream will may jump once after the timer sync. + * @attention Due to the timer of device is not high-accuracy, the timestamp of the continuous frames output by the stream will drift after a long time. User + * can call this function periodically to synchronize the timer to avoid the timestamp drift, the recommended interval time is 60 minutes. + * + * @param[in] device The device handle. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_timer_sync_with_host(ob_device *device, ob_error **error); + +#ifdef __cplusplus +} // extern "C" +#endif + diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/ObTypes.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/ObTypes.h new file mode 100644 index 0000000..ab6ae32 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/ObTypes.h @@ -0,0 +1,1880 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file ObTypes.h + * @brief Provide structs commonly used in the SDK, enumerating constant definitions. + */ + +#pragma once + +#include "Export.h" + +#include +#include + +#pragma pack(push, 1) // struct 1-byte align + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ob_context_t ob_context; +typedef struct ob_device_t ob_device; +typedef struct ob_device_info_t ob_device_info; +typedef struct ob_device_list_t ob_device_list; +typedef struct ob_record_device_t ob_record_device; +typedef struct ob_playback_device_t ob_playback_device; +typedef struct ob_camera_param_list_t ob_camera_param_list; +typedef struct ob_sensor_t ob_sensor; +typedef struct ob_sensor_list_t ob_sensor_list; +typedef struct ob_stream_profile_t ob_stream_profile; +typedef struct ob_stream_profile_list_t ob_stream_profile_list; +typedef struct ob_frame_t ob_frame; +typedef struct ob_filter_t ob_filter; +typedef struct ob_filter_list_t ob_filter_list; +typedef struct ob_pipeline_t ob_pipeline; +typedef struct ob_config_t ob_config; +typedef struct ob_depth_work_mode_list_t ob_depth_work_mode_list; +typedef struct ob_device_preset_list_t ob_device_preset_list; +typedef struct ob_filter_config_schema_list_t ob_filter_config_schema_list; +typedef struct ob_device_frame_interleave_list_t ob_device_frame_interleave_list; + +#define OB_WIDTH_ANY 0 +#define OB_HEIGHT_ANY 0 +#define OB_FPS_ANY 0 +#define OB_FORMAT_ANY OB_FORMAT_UNKNOWN +#define OB_PROFILE_DEFAULT 0 +#define OB_DEFAULT_STRIDE_BYTES 0 +#define OB_ACCEL_FULL_SCALE_RANGE_ANY OB_ACCEL_FS_UNKNOWN +#define OB_ACCEL_SAMPLE_RATE_ANY OB_SAMPLE_RATE_UNKNOWN +#define OB_GYRO_FULL_SCALE_RANGE_ANY OB_GYRO_FS_UNKNOWN +#define OB_GYRO_SAMPLE_RATE_ANY OB_SAMPLE_RATE_UNKNOWN + +/** + * @brief maximum path length + */ +#define OB_PATH_MAX (1024) + +/** + * @brief the permission type of api or property + */ +typedef enum { + OB_PERMISSION_DENY = 0, /**< no permission */ + OB_PERMISSION_READ = 1, /**< can read */ + OB_PERMISSION_WRITE = 2, /**< can write */ + OB_PERMISSION_READ_WRITE = 3, /**< can read and write */ + OB_PERMISSION_ANY = 255, /**< any situation above */ +} OBPermissionType, + ob_permission_type; + +/** + * @brief error code + */ +typedef enum { + OB_STATUS_OK = 0, /**< status ok */ + OB_STATUS_ERROR = 1, /**< status error */ +} OBStatus, + ob_status; + +/** + * @brief log level, the higher the level, the stronger the log filter + */ +typedef enum { + OB_LOG_SEVERITY_DEBUG, /**< debug */ + OB_LOG_SEVERITY_INFO, /**< information */ + OB_LOG_SEVERITY_WARN, /**< warning */ + OB_LOG_SEVERITY_ERROR, /**< error */ + OB_LOG_SEVERITY_FATAL, /**< fatal error */ + OB_LOG_SEVERITY_OFF /**< off (close LOG) */ +} OBLogSeverity, + ob_log_severity, DEVICE_LOG_SEVERITY_LEVEL, OBDeviceLogSeverityLevel, ob_device_log_severity_level; +#define OB_LOG_SEVERITY_NONE OB_LOG_SEVERITY_OFF + +/** + * @brief The exception types in the SDK, through the exception type, you can easily determine the specific type of error. + * For detailed error API interface functions and error logs, please refer to the information of ob_error + */ +typedef enum { + OB_EXCEPTION_TYPE_UNKNOWN, /**< Unknown error, an error not clearly defined by the SDK */ + OB_EXCEPTION_STD_EXCEPTION, /** < Standard exception, an error caused by the standard library */ + OB_EXCEPTION_TYPE_CAMERA_DISCONNECTED, /**< Camera/Device has been disconnected, the camera/device is not available */ + OB_EXCEPTION_TYPE_PLATFORM, /**< An error in the SDK adaptation platform layer, which means an error in the implementation of a specific system + platform */ + OB_EXCEPTION_TYPE_INVALID_VALUE, /**< Invalid parameter type exception, need to check input parameter */ + OB_EXCEPTION_TYPE_WRONG_API_CALL_SEQUENCE, /**< Wrong API call sequence, the API is called in the wrong order or the wrong parameter is passed */ + OB_EXCEPTION_TYPE_NOT_IMPLEMENTED, /**< SDK and firmware have not yet implemented this function or feature */ + OB_EXCEPTION_TYPE_IO, /**< SDK access IO exception error */ + OB_EXCEPTION_TYPE_MEMORY, /**< SDK access and use memory errors. For example, the frame fails to allocate memory */ + OB_EXCEPTION_TYPE_UNSUPPORTED_OPERATION, /**< Unsupported operation type error by SDK or device */ +} OBExceptionType, + ob_exception_type; + +/** + * @brief The error class exposed by the SDK, users can get detailed error information according to the error + */ +typedef struct ob_error { + ob_status status; ///< Describe the status code of the error, as compatible with previous customer status code requirements + char message[256]; ///< Describe the detailed error log + char function[256]; ///< Describe the name of the function where the error occurred + char args[256]; ///< Describes the parameters passed to the function when an error occurs. Used to check whether the parameter is wrong + ob_exception_type exception_type; ///< The description is the specific error type of the SDK +} ob_error; + +/** + * @brief Enumeration value describing the sensor type + */ +typedef enum { + OB_SENSOR_UNKNOWN = 0, /**< Unknown type sensor */ + OB_SENSOR_IR = 1, /**< IR */ + OB_SENSOR_COLOR = 2, /**< Color */ + OB_SENSOR_DEPTH = 3, /**< Depth */ + OB_SENSOR_ACCEL = 4, /**< Accel */ + OB_SENSOR_GYRO = 5, /**< Gyro */ + OB_SENSOR_IR_LEFT = 6, /**< left IR for stereo camera*/ + OB_SENSOR_IR_RIGHT = 7, /**< Right IR for stereo camera*/ + OB_SENSOR_RAW_PHASE = 8, /**< Raw Phase */ + OB_SENSOR_TYPE_COUNT, /**The total number of sensor types, is not a valid sensor type */ +} OBSensorType, + ob_sensor_type; + +/** + * @brief Enumeration value describing the type of data stream + */ +typedef enum { + OB_STREAM_UNKNOWN = -1, /**< Unknown type stream */ + OB_STREAM_VIDEO = 0, /**< Video stream (infrared, color, depth streams are all video streams) */ + OB_STREAM_IR = 1, /**< IR stream */ + OB_STREAM_COLOR = 2, /**< color stream */ + OB_STREAM_DEPTH = 3, /**< depth stream */ + OB_STREAM_ACCEL = 4, /**< Accelerometer data stream */ + OB_STREAM_GYRO = 5, /**< Gyroscope data stream */ + OB_STREAM_IR_LEFT = 6, /**< Left IR stream for stereo camera */ + OB_STREAM_IR_RIGHT = 7, /**< Right IR stream for stereo camera */ + OB_STREAM_RAW_PHASE = 8, /**< RawPhase Stream */ + OB_STREAM_TYPE_COUNT, /**< The total number of stream type,is not a valid stream type */ +} OBStreamType, + ob_stream_type; + +/** + * @brief Enumeration value describing the type of frame + */ +typedef enum { + OB_FRAME_UNKNOWN = -1, /**< Unknown frame type */ + OB_FRAME_VIDEO = 0, /**< Video frame */ + OB_FRAME_IR = 1, /**< IR frame */ + OB_FRAME_COLOR = 2, /**< Color frame */ + OB_FRAME_DEPTH = 3, /**< Depth frame */ + OB_FRAME_ACCEL = 4, /**< Accelerometer data frame */ + OB_FRAME_SET = 5, /**< Frame collection (internally contains a variety of data frames) */ + OB_FRAME_POINTS = 6, /**< Point cloud frame */ + OB_FRAME_GYRO = 7, /**< Gyroscope data frame */ + OB_FRAME_IR_LEFT = 8, /**< Left IR frame for stereo camera */ + OB_FRAME_IR_RIGHT = 9, /**< Right IR frame for stereo camera */ + OB_FRAME_RAW_PHASE = 10, /**< Raw Phase frame*/ + OB_FRAME_TYPE_COUNT, /**< The total number of frame types, is not a valid frame type */ +} OBFrameType, + ob_frame_type; + +/** + * @brief Enumeration value describing the pixel type of frame (usually used for depth frame) + * + */ +typedef enum { + OB_PIXEL_UNKNOWN = -1, // Unknown pixel type, or undefined pixel type for current frame + OB_PIXEL_DEPTH = 0, // Depth pixel type, the value of the pixel is the distance from the camera to the object + OB_PIXEL_DISPARITY = 2, // Disparity for structured light camera + OB_PIXEL_RAW_PHASE = 3, // Raw phase for tof camera + OB_PIXEL_TOF_DEPTH = 4, // Depth for tof camera +} OBPixelType, + ob_pixel_type; + +/** + * @brief Enumeration value describing the pixel format + */ +typedef enum { + OB_FORMAT_UNKNOWN = -1, /**< unknown format */ + OB_FORMAT_YUYV = 0, /**< YUYV format */ + OB_FORMAT_YUY2 = 1, /**< YUY2 format (the actual format is the same as YUYV) */ + OB_FORMAT_UYVY = 2, /**< UYVY format */ + OB_FORMAT_NV12 = 3, /**< NV12 format */ + OB_FORMAT_NV21 = 4, /**< NV21 format */ + OB_FORMAT_MJPG = 5, /**< MJPEG encoding format */ + OB_FORMAT_H264 = 6, /**< H.264 encoding format */ + OB_FORMAT_H265 = 7, /**< H.265 encoding format */ + OB_FORMAT_Y16 = 8, /**< Y16 format, 16-bit per pixel, single-channel*/ + OB_FORMAT_Y8 = 9, /**< Y8 format, 8-bit per pixel, single-channel */ + OB_FORMAT_Y10 = 10, /**< Y10 format, 10-bit per pixel, single-channel(SDK will unpack into Y16 by default) */ + OB_FORMAT_Y11 = 11, /**< Y11 format, 11-bit per pixel, single-channel (SDK will unpack into Y16 by default) */ + OB_FORMAT_Y12 = 12, /**< Y12 format, 12-bit per pixel, single-channel(SDK will unpack into Y16 by default) */ + OB_FORMAT_GRAY = 13, /**< GRAY (the actual format is the same as YUYV) */ + OB_FORMAT_HEVC = 14, /**< HEVC encoding format (the actual format is the same as H265) */ + OB_FORMAT_I420 = 15, /**< I420 format */ + OB_FORMAT_ACCEL = 16, /**< Acceleration data format */ + OB_FORMAT_GYRO = 17, /**< Gyroscope data format */ + OB_FORMAT_POINT = 19, /**< XYZ 3D coordinate point format, @ref OBPoint */ + OB_FORMAT_RGB_POINT = 20, /**< XYZ 3D coordinate point format with RGB information, @ref OBColorPoint */ + OB_FORMAT_RLE = 21, /**< RLE pressure test format (SDK will be unpacked into Y16 by default) */ + OB_FORMAT_RGB = 22, /**< RGB format (actual RGB888) */ + OB_FORMAT_BGR = 23, /**< BGR format (actual BGR888) */ + OB_FORMAT_Y14 = 24, /**< Y14 format, 14-bit per pixel, single-channel (SDK will unpack into Y16 by default) */ + OB_FORMAT_BGRA = 25, /**< BGRA format */ + OB_FORMAT_COMPRESSED = 26, /**< Compression format */ + OB_FORMAT_RVL = 27, /**< RVL pressure test format (SDK will be unpacked into Y16 by default) */ + OB_FORMAT_Z16 = 28, /**< Is same as Y16*/ + OB_FORMAT_YV12 = 29, /**< Is same as Y12, using for right ir stream*/ + OB_FORMAT_BA81 = 30, /**< Is same as Y8, using for right ir stream*/ + OB_FORMAT_RGBA = 31, /**< RGBA format */ + OB_FORMAT_BYR2 = 32, /**< byr2 format */ + OB_FORMAT_RW16 = 33, /**< RAW16 format */ +} OBFormat, + ob_format; + +#define OB_FORMAT_RGB888 OB_FORMAT_RGB // Alias of OB_FORMAT_RGB for compatibility +#define OB_FORMAT_MJPEG OB_FORMAT_MJPG // Alias of OB_FORMAT_MJPG for compatibility + +// Check if the format is a fixed data size format +#define IS_FIXED_SIZE_FORMAT(format) \ + (format != OB_FORMAT_MJPG && format != OB_FORMAT_H264 && format != OB_FORMAT_H265 && format != OB_FORMAT_HEVC && format != OB_FORMAT_RLE \ + && format != OB_FORMAT_RVL) + +// Check if the format is a packed format, which means the data of pixels is not continuous or bytes aligned in memory +#define IS_PACKED_FORMAT(format) \ + (format == OB_FORMAT_Y10 || format == OB_FORMAT_Y11 || format == OB_FORMAT_Y12 || format == OB_FORMAT_Y14 || format == OB_FORMAT_RLE) + +/** + * @brief Enumeration value describing the firmware upgrade status + */ +typedef enum { + STAT_DONE_WITH_DUPLICATES = 6, /**< update completed, but some files were duplicated and ignored */ + STAT_VERIFY_SUCCESS = 5, /**< Image file verifify success */ + STAT_FILE_TRANSFER = 4, /**< file transfer */ + STAT_DONE = 3, /**< update completed */ + STAT_IN_PROGRESS = 2, /**< upgrade in process */ + STAT_START = 1, /**< start the upgrade */ + STAT_VERIFY_IMAGE = 0, /**< Image file verification */ + ERR_VERIFY = -1, /**< Verification failed */ + ERR_PROGRAM = -2, /**< Program execution failed */ + ERR_ERASE = -3, /**< Flash parameter failed */ + ERR_FLASH_TYPE = -4, /**< Flash type error */ + ERR_IMAGE_SIZE = -5, /**< Image file size error */ + ERR_OTHER = -6, /**< other errors */ + ERR_DDR = -7, /**< DDR access error */ + ERR_TIMEOUT = -8, /**< timeout error */ + ERR_MISMATCH = -9, /**< Mismatch firmware error */ + ERR_UNSUPPORT_DEV = -10, /**< Unsupported device error */ + ERR_INVALID_COUNT = -11, /**< invalid firmware/preset count */ +} OBUpgradeState, + OBFwUpdateState, ob_upgrade_state, ob_fw_update_state; + +/** + * @brief Enumeration value describing the file transfer status + */ +typedef enum { + FILE_TRAN_STAT_TRANSFER = 2, /**< File transfer */ + FILE_TRAN_STAT_DONE = 1, /**< File transfer succeeded */ + FILE_TRAN_STAT_PREPAR = 0, /**< Preparing */ + FILE_TRAN_ERR_DDR = -1, /**< DDR access failed */ + FILE_TRAN_ERR_NOT_ENOUGH_SPACE = -2, /**< Insufficient target space error */ + FILE_TRAN_ERR_PATH_NOT_WRITABLE = -3, /**< Destination path is not writable */ + FILE_TRAN_ERR_MD5_ERROR = -4, /**< MD5 checksum error */ + FILE_TRAN_ERR_WRITE_FLASH_ERROR = -5, /**< Write flash error */ + FILE_TRAN_ERR_TIMEOUT = -6 /**< Timeout error */ +} OBFileTranState, + ob_file_tran_state; + +/** + * @brief Enumeration value describing the data transfer status + */ +typedef enum { + DATA_TRAN_STAT_VERIFY_DONE = 4, /**< data verify done */ + DATA_TRAN_STAT_STOPPED = 3, /**< data transfer stoped */ + DATA_TRAN_STAT_DONE = 2, /**< data transfer completed */ + DATA_TRAN_STAT_VERIFYING = 1, /**< data verifying */ + DATA_TRAN_STAT_TRANSFERRING = 0, /**< data transferring */ + DATA_TRAN_ERR_BUSY = -1, /**< Transmission is busy */ + DATA_TRAN_ERR_UNSUPPORTED = -2, /**< Not supported */ + DATA_TRAN_ERR_TRAN_FAILED = -3, /**< Transfer failed */ + DATA_TRAN_ERR_VERIFY_FAILED = -4, /**< Test failed */ + DATA_TRAN_ERR_OTHER = -5 /**< Other errors */ +} OBDataTranState, + ob_data_tran_state; + +/** + * @brief Structure for transmitting data blocks + */ +typedef struct { + uint8_t *data; ///< Pointer to current block data + uint32_t size; ///< Length of current block data + uint32_t offset; ///< Offset of current data block relative to complete data + uint32_t fullDataSize; ///< Size of full data +} OBDataChunk, ob_data_chunk; + +/** + * @brief Structure for integer range + */ +typedef struct { + int32_t cur; ///< Current value + int32_t max; ///< Maximum value + int32_t min; ///< Minimum value + int32_t step; ///< Step value + int32_t def; ///< Default value +} OBIntPropertyRange, ob_int_property_range; + +/** + * @brief Structure for float range + */ +typedef struct { + float cur; ///< Current value + float max; ///< Maximum value + float min; ///< Minimum value + float step; ///< Step value + float def; ///< Default value +} OBFloatPropertyRange, ob_float_property_range; + +/** + * @brief Structure for float range + */ +typedef struct { + uint16_t cur; ///< Current value + uint16_t max; ///< Maximum value + uint16_t min; ///< Minimum value + uint16_t step; ///< Step value + uint16_t def; ///< Default value +} OBUint16PropertyRange, ob_uint16_property_range; + +/** + * @brief Structure for float range + */ +typedef struct { + uint8_t cur; ///< Current value + uint8_t max; ///< Maximum value + uint8_t min; ///< Minimum value + uint8_t step; ///< Step value + uint8_t def; ///< Default value +} OBUint8PropertyRange, ob_uint8_property_range; + +/** + * @brief Structure for boolean range + */ +typedef struct { + bool cur; ///< Current value + bool max; ///< Maximum value + bool min; ///< Minimum value + bool step; ///< Step value + bool def; ///< Default value +} OBBoolPropertyRange, ob_bool_property_range; + +/** \brief Distortion model: defines how pixel coordinates should be mapped to sensor coordinates. */ +typedef enum { + OB_DISTORTION_NONE, /**< Rectilinear images. No distortion compensation required. */ + OB_DISTORTION_MODIFIED_BROWN_CONRADY, /**< Equivalent to Brown-Conrady distortion, except that tangential distortion is applied to radially distorted points + */ + OB_DISTORTION_INVERSE_BROWN_CONRADY, /**< Equivalent to Brown-Conrady distortion, except undistorts image instead of distorting it */ + OB_DISTORTION_BROWN_CONRADY, /**< Unmodified Brown-Conrady distortion model */ + OB_DISTORTION_BROWN_CONRADY_K6, /**< Unmodified Brown-Conrady distortion model with k6 supported */ + OB_DISTORTION_KANNALA_BRANDT4, /**< Kannala-Brandt distortion model */ +} OBCameraDistortionModel, + ob_camera_distortion_model; + +/** + * @brief Structure for camera intrinsic parameters + */ +typedef struct { + float fx; ///< Focal length in x direction + float fy; ///< Focal length in y direction + float cx; ///< Optical center abscissa + float cy; ///< Optical center ordinate + int16_t width; ///< Image width + int16_t height; ///< Image height +} OBCameraIntrinsic, ob_camera_intrinsic; + +/** + * @brief Structure for accelerometer intrinsic parameters + */ +typedef struct { + double noiseDensity; ///< In-run bias instability + double randomWalk; ///< random walk + double referenceTemp; ///< reference temperature + double bias[3]; ///< bias for x, y, z axis + double gravity[3]; ///< gravity direction for x, y, z axis + double scaleMisalignment[9]; ///< scale factor and three-axis non-orthogonal error + double tempSlope[9]; ///< linear temperature drift coefficient +} OBAccelIntrinsic, ob_accel_intrinsic; + +/** + * @brief Structure for gyroscope intrinsic parameters + */ +typedef struct { + double noiseDensity; ///< In-run bias instability + double randomWalk; ///< random walk + double referenceTemp; ///< reference temperature + double bias[3]; ///< bias for x, y, z axis + double scaleMisalignment[9]; ///< scale factor and three-axis non-orthogonal error + double tempSlope[9]; ///< linear temperature drift coefficient +} OBGyroIntrinsic, ob_gyro_intrinsic; + +/** + * @brief Structure for distortion parameters + */ +typedef struct { + float k1; ///< Radial distortion factor 1 + float k2; ///< Radial distortion factor 2 + float k3; ///< Radial distortion factor 3 + float k4; ///< Radial distortion factor 4 + float k5; ///< Radial distortion factor 5 + float k6; ///< Radial distortion factor 6 + float p1; ///< Tangential distortion factor 1 + float p2; ///< Tangential distortion factor 2 + OBCameraDistortionModel model; +} OBCameraDistortion, ob_camera_distortion; + +/** + * @brief Structure for rotation/transformation + */ +typedef struct { + float rot[9]; ///< Rotation matrix + float trans[3]; ///< Transformation matrix in millimeters +} OBD2CTransform, ob_d2c_transform, OBTransform, ob_transform, OBExtrinsic, ob_extrinsic; + +/** + * @brief Structure for camera parameters + */ +typedef struct { + OBCameraIntrinsic depthIntrinsic; ///< Depth camera internal parameters + OBCameraIntrinsic rgbIntrinsic; ///< Color camera internal parameters + OBCameraDistortion depthDistortion; ///< Depth camera distortion parameters + OBCameraDistortion rgbDistortion; ///< Color camera distortion parameters + OBD2CTransform transform; ///< Rotation/transformation matrix + bool isMirrored; ///< Whether the image frame corresponding to this group of parameters is mirrored +} OBCameraParam, ob_camera_param; + +/** + * @brief calibration parameters + */ +typedef struct { + OBCameraIntrinsic intrinsics[OB_SENSOR_TYPE_COUNT]; ///< Sensor internal parameters + OBCameraDistortion distortion[OB_SENSOR_TYPE_COUNT]; ///< Sensor distortion + OBExtrinsic extrinsics[OB_SENSOR_TYPE_COUNT] + [OB_SENSOR_TYPE_COUNT]; ///< The extrinsic parameters allow 3D coordinate conversions between sensor.To transform from a + ///< source to a target 3D coordinate system,under extrinsics[source][target]. +} OBCalibrationParam, ob_calibration_param; + +/** + * @brief Configuration for depth margin filter + */ +typedef struct { + int margin_x_th; ///< Horizontal threshold settings + int margin_y_th; ///< Vertical threshold settings + int limit_x_th; ///< Maximum horizontal threshold + int limit_y_th; ///< Maximum vertical threshold + uint32_t width; ///< Image width + uint32_t height; ///< Image height + bool enable_direction; ///< Set to true for horizontal and vertical, false for horizontal only +} ob_margin_filter_config, OBMarginFilterConfig; + +/** + * @brief Configuration for mgc filter + */ +typedef struct { + uint32_t width; + uint32_t height; + int max_width_left; + int max_width_right; + int max_radius; + int margin_x_th; + int margin_y_th; + int limit_x_th; + int limit_y_th; +} OBMGCFilterConfig, ob_mgc_filter_config; + +/** + * @brief Alignment mode + */ +typedef enum { + ALIGN_DISABLE, /**< Turn off alignment */ + ALIGN_D2C_HW_MODE, /**< Hardware D2C alignment mode */ + ALIGN_D2C_SW_MODE, /**< Software D2C alignment mode */ +} OBAlignMode, + ob_align_mode; + +/** + * @brief Camera performance mode + */ +typedef enum { + ADAPTIVE_PERFORMANCE_MODE, /**< Camera adaptive mode */ + HIGH_PERFORMANCE_MODE, /**< High Performance Mode */ +} OBCameraPerformanceMode, + ob_camera_performance_mode; + +/** + * @brief Rectangle + */ +typedef struct { + uint32_t x; ///< Origin coordinate x + uint32_t y; ///< Origin coordinate y + uint32_t width; ///< Rectangle width + uint32_t height; ///< Rectangle height +} OBRect, ob_rect; + +/** + * @brief Enumeration of format conversion types + */ +typedef enum { + FORMAT_YUYV_TO_RGB = 0, /**< YUYV to RGB */ + FORMAT_I420_TO_RGB, /**< I420 to RGB */ + FORMAT_NV21_TO_RGB, /**< NV21 to RGB */ + FORMAT_NV12_TO_RGB, /**< NV12 to RGB */ + FORMAT_MJPG_TO_I420, /**< MJPG to I420 */ + FORMAT_RGB_TO_BGR, /**< RGB888 to BGR */ + FORMAT_MJPG_TO_NV21, /**< MJPG to NV21 */ + FORMAT_MJPG_TO_RGB, /**< MJPG to RGB */ + FORMAT_MJPG_TO_BGR, /**< MJPG to BGR */ + FORMAT_MJPG_TO_BGRA, /**< MJPG to BGRA */ + FORMAT_UYVY_TO_RGB, /**< UYVY to RGB */ + FORMAT_BGR_TO_RGB, /**< BGR to RGB */ + FORMAT_MJPG_TO_NV12, /**< MJPG to NV12 */ + FORMAT_YUYV_TO_BGR, /**< YUYV to BGR */ + FORMAT_YUYV_TO_RGBA, /**< YUYV to RGBA */ + FORMAT_YUYV_TO_BGRA, /**< YUYV to BGRA */ + FORMAT_YUYV_TO_Y16, /**< YUYV to Y16 */ + FORMAT_YUYV_TO_Y8, /**< YUYV to Y8 */ + FORMAT_RGBA_TO_RGB, /**< RGBA to RGB */ + FORMAT_BGRA_TO_BGR, /**< BGRA to BGR */ + FORMAT_Y16_TO_RGB, /**< Y16 to RGB */ + FORMAT_Y8_TO_RGB, /**< Y8 to RGB */ +} OBConvertFormat, + ob_convert_format; + +// DEPRECATED: Only used for old version program compatibility, will be completely deleted in subsequent iterative versions +#define FORMAT_MJPEG_TO_I420 FORMAT_MJPG_TO_I420 +#define FORMAT_MJPEG_TO_NV21 FORMAT_MJPG_TO_NV21 +#define FORMAT_MJPEG_TO_BGRA FORMAT_MJPG_TO_BGRA +#define FORMAT_YUYV_TO_RGB888 FORMAT_YUYV_TO_RGB +#define FORMAT_I420_TO_RGB888 FORMAT_I420_TO_RGB +#define FORMAT_NV21_TO_RGB888 FORMAT_NV21_TO_RGB +#define FORMAT_NV12_TO_RGB888 FORMAT_NV12_TO_RGB +#define FORMAT_UYVY_TO_RGB888 FORMAT_UYVY_TO_RGB +#define FORMAT_MJPG_TO_RGB888 FORMAT_MJPG_TO_RGB +#define FORMAT_MJPG_TO_BGR888 FORMAT_MJPG_TO_BGR +#define FORMAT_MJPEG_TO_RGB888 FORMAT_MJPG_TO_RGB +#define FORMAT_MJPEG_TO_BGR888 FORMAT_MJPG_TO_BGR +#define FORMAT_RGB888_TO_BGR FORMAT_RGB_TO_BGR + +/** + * @brief Enumeration of IMU sample rate values (gyroscope or accelerometer) + */ +typedef enum { + OB_SAMPLE_RATE_UNKNOWN = 0, + OB_SAMPLE_RATE_1_5625_HZ = 1, /**< 1.5625Hz */ + OB_SAMPLE_RATE_3_125_HZ = 2, /**< 3.125Hz */ + OB_SAMPLE_RATE_6_25_HZ = 3, /**< 6.25Hz */ + OB_SAMPLE_RATE_12_5_HZ = 4, /**< 12.5Hz */ + OB_SAMPLE_RATE_25_HZ = 5, /**< 25Hz */ + OB_SAMPLE_RATE_50_HZ = 6, /**< 50Hz */ + OB_SAMPLE_RATE_100_HZ = 7, /**< 100Hz */ + OB_SAMPLE_RATE_200_HZ = 8, /**< 200Hz */ + OB_SAMPLE_RATE_500_HZ = 9, /**< 500Hz */ + OB_SAMPLE_RATE_1_KHZ = 10, /**< 1KHz */ + OB_SAMPLE_RATE_2_KHZ = 11, /**< 2KHz */ + OB_SAMPLE_RATE_4_KHZ = 12, /**< 4KHz */ + OB_SAMPLE_RATE_8_KHZ = 13, /**< 8KHz */ + OB_SAMPLE_RATE_16_KHZ = 14, /**< 16KHz */ + OB_SAMPLE_RATE_32_KHZ = 15, /**< 32Hz */ + OB_SAMPLE_RATE_400_HZ = 16, /**< 400Hz*/ + OB_SAMPLE_RATE_800_HZ = 17, /**< 800Hz*/ +} OBIMUSampleRate, + OBGyroSampleRate, ob_gyro_sample_rate, OBAccelSampleRate, ob_accel_sample_rate, OB_SAMPLE_RATE; + +/** + * @brief Enumeration of gyroscope ranges + */ +typedef enum { + OB_GYRO_FS_UNKNOWN = -1, + OB_GYRO_FS_16dps = 1, /**< 16 degrees per second */ + OB_GYRO_FS_31dps = 2, /**< 31 degrees per second */ + OB_GYRO_FS_62dps = 3, /**< 62 degrees per second */ + OB_GYRO_FS_125dps = 4, /**< 125 degrees per second */ + OB_GYRO_FS_250dps = 5, /**< 250 degrees per second */ + OB_GYRO_FS_500dps = 6, /**< 500 degrees per second */ + OB_GYRO_FS_1000dps = 7, /**< 1000 degrees per second */ + OB_GYRO_FS_2000dps = 8, /**< 2000 degrees per second */ + OB_GYRO_FS_400dps = 9, /**< 400 degrees per second */ + OB_GYRO_FS_800dps = 10, /**< 800 degrees per second */ +} OBGyroFullScaleRange, + ob_gyro_full_scale_range, OB_GYRO_FULL_SCALE_RANGE; + +/** + * @brief Enumeration of accelerometer ranges + */ +typedef enum { + OB_ACCEL_FS_UNKNOWN = -1, + OB_ACCEL_FS_2g = 1, /**< 1x the acceleration of gravity */ + OB_ACCEL_FS_4g = 2, /**< 4x the acceleration of gravity */ + OB_ACCEL_FS_8g = 3, /**< 8x the acceleration of gravity */ + OB_ACCEL_FS_16g = 4, /**< 16x the acceleration of gravity */ + OB_ACCEL_FS_3g = 5, /**< 3x the acceleration of gravity */ + OB_ACCEL_FS_6g = 6, /**< 6x the acceleration of gravity */ + OB_ACCEL_FS_12g = 7, /**< 12x the acceleration of gravity */ + OB_ACCEL_FS_24g = 8, /**< 24x the acceleration of gravity */ +} OBAccelFullScaleRange, + ob_accel_full_scale_range, OB_ACCEL_FULL_SCALE_RANGE; + +/** + * @brief Data structures for accelerometers and gyroscopes + */ +typedef struct { + float x; ///< X-direction component + float y; ///< Y-direction component + float z; ///< Z-direction component +} OBAccelValue, OBGyroValue, OBFloat3D, ob_accel_value, ob_gyro_value, ob_float_3d; + +/** + * @brief Device state + */ +typedef uint64_t OBDeviceState, ob_device_state; + +/** + * @brief Temperature parameters of the device (unit: Celsius) + */ +typedef struct { + float cpuTemp; ///< CPU temperature + float irTemp; ///< IR temperature + float ldmTemp; ///< Laser temperature + float mainBoardTemp; ///< Motherboard temperature + float tecTemp; ///< TEC temperature + float imuTemp; ///< IMU temperature + float rgbTemp; ///< RGB temperature + float irLeftTemp; ///< Left IR temperature + float irRightTemp; ///< Right IR temperature + float chipTopTemp; ///< MX6600 top temperature + float chipBottomTemp; ///< MX6600 bottom temperature +} OBDeviceTemperature, ob_device_temperature, DEVICE_TEMPERATURE; + +/** + * @brief Enumeration for depth crop modes + */ +typedef enum { + DEPTH_CROPPING_MODE_AUTO = 0, /**< Automatic mode */ + DEPTH_CROPPING_MODE_CLOSE = 1, /**< Close crop */ + DEPTH_CROPPING_MODE_OPEN = 2, /**< Open crop */ +} OBDepthCroppingMode, + ob_depth_cropping_mode, OB_DEPTH_CROPPING_MODE; + +/** + * @brief Enumeration for device types + */ +typedef enum { + OB_DEVICE_TYPE_UNKNOWN = -1, /**< Unknown device type */ + OB_STRUCTURED_LIGHT_MONOCULAR_CAMERA = 0, /**< Monocular structured light camera */ + OB_STRUCTURED_LIGHT_BINOCULAR_CAMERA = 1, /**< Binocular structured light camera */ + OB_TOF_CAMERA = 2, /**< Time-of-flight camera */ +} OBDeviceType, + ob_device_type, OB_DEVICE_TYPE; + +/** + * @brief Enumeration for types of media to record or playback + */ +typedef enum { + OB_MEDIA_COLOR_STREAM = 1, /**< Color stream */ + OB_MEDIA_DEPTH_STREAM = 2, /**< Depth stream */ + OB_MEDIA_IR_STREAM = 4, /**< Infrared stream */ + OB_MEDIA_GYRO_STREAM = 8, /**< Gyroscope stream */ + OB_MEDIA_ACCEL_STREAM = 16, /**< Accelerometer stream */ + OB_MEDIA_CAMERA_PARAM = 32, /**< Camera parameter */ + OB_MEDIA_DEVICE_INFO = 64, /**< Device information */ + OB_MEDIA_STREAM_INFO = 128, /**< Stream information */ + OB_MEDIA_IR_LEFT_STREAM = 256, /**< Left infrared stream */ + OB_MEDIA_IR_RIGHT_STREAM = 512, /**< Right infrared stream */ + + OB_MEDIA_ALL = OB_MEDIA_COLOR_STREAM | OB_MEDIA_DEPTH_STREAM | OB_MEDIA_IR_STREAM | OB_MEDIA_GYRO_STREAM | OB_MEDIA_ACCEL_STREAM | OB_MEDIA_CAMERA_PARAM + | OB_MEDIA_DEVICE_INFO | OB_MEDIA_STREAM_INFO | OB_MEDIA_IR_LEFT_STREAM | OB_MEDIA_IR_RIGHT_STREAM, /**< All media data types */ +} OBMediaType, + ob_media_type, OB_MEDIA_TYPE; + +/** + * @brief Enumeration for record playback status + */ +typedef enum { + OB_MEDIA_BEGIN = 0, /**< Begin */ + OB_MEDIA_PAUSE, /**< Pause */ + OB_MEDIA_RESUME, /**< Resume */ + OB_MEDIA_END, /**< End */ +} OBMediaState, + ob_media_state, OB_MEDIA_STATE_EM; + +/** + * @brief Enumeration for depth precision levels + * @attention The depth precision level does not completely determine the depth unit and real precision, and the influence of the data packaging format needs to + * be considered. The specific unit can be obtained through getValueScale() of DepthFrame + */ +typedef enum { + OB_PRECISION_1MM, /**< 1mm */ + OB_PRECISION_0MM8, /**< 0.8mm */ + OB_PRECISION_0MM4, /**< 0.4mm */ + OB_PRECISION_0MM1, /**< 0.1mm */ + OB_PRECISION_0MM2, /**< 0.2mm */ + OB_PRECISION_0MM5, /**< 0.5mm */ + OB_PRECISION_0MM05, /**< 0.05mm */ + OB_PRECISION_UNKNOWN, + OB_PRECISION_COUNT, +} OBDepthPrecisionLevel, + ob_depth_precision_level, OB_DEPTH_PRECISION_LEVEL, OBDepthUnit, ob_depth_unit; + +/** + * @brief disparity parameters for disparity based camera + * + */ +typedef struct { + double zpd; // the distance to calib plane + double zpps; // zpps=z0/fx + float baseline; // baseline length, for monocular camera,it means the distance of laser to the center of IR-CMOS + double fx; // focus + uint8_t bitSize; // disparity bit size (raw disp bit size, for example: MX6000 is 12, MX6600 is 14) + float unit; // reference units: unit=10 denote 1cm; unit=1 denote 1mm; unit=0.5 denote 0.5mm; and so on + float minDisparity; // dual disparity coefficient + uint8_t packMode; // data pack mode + float dispOffset; // disparity offset, actual disp=chip disp + disp_offset + int32_t invalidDisp; // invalid disparity, usually is 0, dual IR add a auxiliary value. + int32_t dispIntPlace; // disp integer digits, default is 8, Gemini2 XL is 10 + uint8_t isDualCamera; // 0 monocular camera, 1 dual camera +} OBDisparityParam, ob_disparity_param; + +/** + * @brief Enumeration for TOF filter scene ranges + */ +typedef enum { + OB_TOF_FILTER_RANGE_CLOSE = 0, /**< Close range */ + OB_TOF_FILTER_RANGE_MIDDLE = 1, /**< Middle range */ + OB_TOF_FILTER_RANGE_LONG = 2, /**< Long range */ + OB_TOF_FILTER_RANGE_DEBUG = 100, /**< Debug range */ +} OBTofFilterRange, + ob_tof_filter_range, TOF_FILTER_RANGE; +/** + * @brief 3D point structure in the SDK + */ +typedef struct { + float x; ///< X coordinate + float y; ///< Y coordinate + float z; ///< Z coordinate +} OBPoint, ob_point, OBPoint3f, ob_point3f; + +/** + * @brief 2D point structure in the SDK + */ +typedef struct { + float x; ///< X coordinate + float y; ///< Y coordinate +} OBPoint2f, ob_point2f; + +typedef struct { + float *xTable; ///< table used to compute X coordinate + float *yTable; ///< table used to compute Y coordinate + int width; ///< width of x and y tables + int height; ///< height of x and y tables +} OBXYTables, ob_xy_tables; + +/** + * @brief 3D point structure with color information + */ +typedef struct { + float x; ///< X coordinate + float y; ///< Y coordinate + float z; ///< Z coordinate + float r; ///< Red channel component + float g; ///< Green channel component + float b; ///< Blue channel component +} OBColorPoint, ob_color_point; + +/** + * @brief Compression mode + */ +typedef enum { + OB_COMPRESSION_LOSSLESS = 0, /**< Lossless compression mode */ + OB_COMPRESSION_LOSSY = 1, /**< Lossy compression mode */ +} OBCompressionMode, + ob_compression_mode, OB_COMPRESSION_MODE; + +/** + * Compression Params + */ +typedef struct { + /** + * Lossy compression threshold, range [0~255], recommended value is 9, the higher the threshold, the higher the compression ratio. + */ + int threshold; +} OBCompressionParams, ob_compression_params, OB_COMPRESSION_PARAMS; + +/** + * @brief TOF Exposure Threshold + */ +typedef struct { + int32_t upper; ///< Upper threshold, unit: ms + int32_t lower; ///< Lower threshold, unit: ms +} OBTofExposureThresholdControl, ob_tof_exposure_threshold_control, TOF_EXPOSURE_THRESHOLD_CONTROL; + +/** + * @brief Sync mode + * @deprecated This define is deprecated, please use @ref ob_multi_device_sync_mode instead + */ +typedef enum { + /** + * @brief Close synchronize mode + * @brief Single device, neither process input trigger signal nor output trigger signal + * @brief Each Sensor in a single device automatically triggers + */ + OB_SYNC_MODE_CLOSE = 0x00, + + /** + * @brief Standalone synchronize mode + * @brief Single device, neither process input trigger signal nor output trigger signal + * @brief Inside single device, RGB as Major sensor: RGB -> IR/Depth/TOF + */ + OB_SYNC_MODE_STANDALONE = 0x01, + + /** + * @brief Primary synchronize mode + * @brief Primary device. Ignore process input trigger signal, only output trigger signal to secondary devices. + * @brief Inside single device, RGB as Major sensor: RGB -> IR/Depth/TOF + */ + OB_SYNC_MODE_PRIMARY = 0x02, + + /** + * @brief Secondary synchronize mode + * @brief Secondary device. Both process input trigger signal and output trigger signal to other devices. + * @brief Different sensors in a single devices receive trigger signals respectively: ext trigger -> RGB && ext trigger -> IR/Depth/TOF + * + * @attention With the current Gemini 2 device set to this mode, each Sensor receives the first external trigger signal + * after the stream is turned on and starts timing self-triggering at the set frame rate until the stream is turned off + */ + OB_SYNC_MODE_SECONDARY = 0x03, + + /** + * @brief MCU Primary synchronize mode + * @brief Primary device. Ignore process input trigger signal, only output trigger signal to secondary devices. + * @brief Inside device, MCU is the primary signal source: MCU -> RGB && MCU -> IR/Depth/TOF + */ + OB_SYNC_MODE_PRIMARY_MCU_TRIGGER = 0x04, + + /** + * @brief IR Primary synchronize mode + * @brief Primary device. Ignore process input trigger signal, only output trigger signal to secondary devices. + * @brief Inside device, IR is the primary signal source: IR/Depth/TOF -> RGB + */ + OB_SYNC_MODE_PRIMARY_IR_TRIGGER = 0x05, + + /** + * @brief Software trigger synchronize mode + * @brief Host, triggered by software control (receive the upper computer command trigger), at the same time to the trunk output trigger signal + * @brief Different sensors in a single machine receive trigger signals respectively: soft trigger -> RGB && soft trigger -> IR/Depth/TOF + * + * @attention Support product: Gemini2 + */ + OB_SYNC_MODE_PRIMARY_SOFT_TRIGGER = 0x06, + + /** + * @brief Software trigger synchronize mode as secondary device + * @brief The slave receives the external trigger signal (the external trigger signal comes from the soft trigger host) and outputs the trigger signal to + * the external relay. + * @brief Different sensors in a single machine receive trigger signals respectively: ext trigger -> RGB && ext trigger -> IR/Depth/TOF + */ + OB_SYNC_MODE_SECONDARY_SOFT_TRIGGER = 0x07, + + /** + * @brief IR and IMU sync signal + */ + OB_SYNC_MODE_IR_IMU_SYNC = 0x08, + + /** + * @brief Unknown type + */ + OB_SYNC_MODE_UNKNOWN = 0xff, + +} OBSyncMode, + ob_sync_mode, OB_SYNC_MODE; + +/** + * @brief Device synchronization configuration + * @deprecated This structure is deprecated, please use @ref ob_multi_device_sync_config instead + */ +typedef struct { + /** + * @brief Device synchronize mode + */ + OBSyncMode syncMode; + + /** + * @brief IR Trigger signal input delay: Used to configure the delay between the IR/Depth/TOF Sensor receiving the trigger signal and starting exposure, + * Unit: microsecond + * + * @attention This parameter is invalid when the synchronization MODE is set to @ref OB_SYNC_MODE_PRIMARY_IR_TRIGGER + */ + uint16_t irTriggerSignalInDelay; + + /** + * @brief RGB trigger signal input delay is used to configure the delay from the time when an RGB Sensor receives the trigger signal to the time when the + * exposure starts. Unit: microsecond + * + * @attention This parameter is invalid when the synchronization MODE is set to @ref OB_SYNC_MODE_PRIMARY + */ + uint16_t rgbTriggerSignalInDelay; + + /** + * @brief Device trigger signal output delay, used to control the delay configuration of the host device to output trigger signals or the slave device to + * output trigger signals. Unit: microsecond + * + * @attention This parameter is invalid when the synchronization MODE is set to @ref OB_SYNC_MODE_CLOSE or @ref OB_SYNC_MODE_STANDALONE + */ + uint16_t deviceTriggerSignalOutDelay; + + /** + * @brief The device trigger signal output polarity is used to control the polarity configuration of the trigger signal output from the host device or the + * trigger signal output from the slave device + * @brief 0: forward pulse; 1: negative pulse + * + * @attention This parameter is invalid when the synchronization MODE is set to @ref OB_SYNC_MODE_CLOSE or @ref OB_SYNC_MODE_STANDALONE + */ + uint16_t deviceTriggerSignalOutPolarity; + + /** + * @brief MCU trigger frequency, used to configure the output frequency of MCU trigger signal in MCU master mode, unit: Hz + * @brief This configuration will directly affect the image output frame rate of the Sensor. Unit: FPS (frames per second) + * + * @attention This parameter is invalid only when the synchronization MODE is set to @ref OB_SYNC_MODE_PRIMARY_MCU_TRIGGER + */ + uint16_t mcuTriggerFrequency; + + /** + * @brief Device number. Users can mark the device with this number + */ + uint16_t deviceId; + +} OBDeviceSyncConfig, ob_device_sync_config, OB_DEVICE_SYNC_CONFIG; + +/** + * @brief Preset tag + */ +typedef enum { + OB_DEVICE_DEPTH_WORK_MODE = 0, + OB_CUSTOM_DEPTH_WORK_MODE = 1, +} OBDepthWorkModeTag, + ob_depth_work_mode_tag; + +/** + * @brief Depth work mode + */ +typedef struct { + /** + * @brief Checksum of work mode + */ + uint8_t checksum[16]; + + /** + * @brief Name of work mode + */ + char name[32]; + /** + * @brief Preset tag + */ + OBDepthWorkModeTag tag; + +} OBDepthWorkMode, ob_depth_work_mode; + +/** + * @brief SequenceId fliter list item + */ +typedef struct { + int sequenceSelectId; + char name[8]; +} OBSequenceIdItem, ob_sequence_id_item; + +/** + * @brief Hole fillig mode + */ +typedef enum { + OB_HOLE_FILL_TOP = 0, + OB_HOLE_FILL_NEAREST = 1, // "max" means farest for depth, and nearest for disparity; FILL_NEAREST + OB_HOLE_FILL_FAREST = 2, // FILL_FAREST +} OBHoleFillingMode, + ob_hole_filling_mode; + +typedef struct { + uint8_t magnitude; // magnitude + float alpha; // smooth_alpha + uint16_t disp_diff; // smooth_delta + uint16_t radius; // hole_fill +} OBSpatialAdvancedFilterParams, ob_spatial_advanced_filter_params; + +typedef enum OB_EDGE_NOISE_REMOVAL_TYPE { + OB_MG_FILTER = 0, + OB_MGH_FILTER = 1, // horizontal MG + OB_MGA_FILTER = 2, // asym MG + OB_MGC_FILTER = 3, +} OBEdgeNoiseRemovalType, + ob_edge_noise_removal_type; + +typedef struct { + OBEdgeNoiseRemovalType type; + uint16_t marginLeftTh; + uint16_t marginRightTh; + uint16_t marginTopTh; + uint16_t marginBottomTh; +} OBEdgeNoiseRemovalFilterParams, ob_edge_noise_removal_filter_params; + +/** + * @brief Denoising method + */ +typedef enum OB_DDO_NOISE_REMOVAL_TYPE { + OB_NR_LUT = 0, // SPLIT + OB_NR_OVERALL = 1, // NON_SPLIT +} OBDDONoiseRemovalType, + ob_ddo_noise_removal_type; + +typedef struct { + uint16_t max_size; + uint16_t disp_diff; + OBDDONoiseRemovalType type; +} OBNoiseRemovalFilterParams, ob_noise_removal_filter_params; + +/** + * @brief Control command protocol version number + */ +typedef struct { + /** + * @brief Major version number + */ + uint8_t major; + + /** + * @brief Minor version number + */ + uint8_t minor; + + /** + * @brief Patch version number + */ + uint8_t patch; +} OBProtocolVersion, ob_protocol_version; + +/** + * @brief Command version associated with property id + */ +typedef enum { + OB_CMD_VERSION_V0 = (uint16_t)0, ///< Version 1.0 + OB_CMD_VERSION_V1 = (uint16_t)1, ///< Version 2.0 + OB_CMD_VERSION_V2 = (uint16_t)2, ///< Version 3.0 + OB_CMD_VERSION_V3 = (uint16_t)3, ///< Version 4.0 + + OB_CMD_VERSION_NOVERSION = (uint16_t)0xfffe, + OB_CMD_VERSION_INVALID = (uint16_t)0xffff, ///< Invalid version +} OB_CMD_VERSION, + OBCmdVersion, ob_cmd_version; + +/** + * @brief IP address configuration for network devices (IPv4) + */ +typedef struct { + /** + * @brief DHCP status + * + * @note 0: static IP; 1: DHCP + */ + uint16_t dhcp; + + /** + * @brief IP address (IPv4, big endian: 192.168.1.10, address[0] = 192, address[1] = 168, address[2] = 1, address[3] = 10) + */ + uint8_t address[4]; + + /** + * @brief Subnet mask (big endian) + */ + uint8_t mask[4]; + + /** + * @brief Gateway (big endian) + */ + uint8_t gateway[4]; +} OBNetIpConfig, ob_net_ip_config, DEVICE_IP_ADDR_CONFIG; + +#define OBDeviceIpAddrConfig OBNetIpConfig +#define ob_device_ip_addr_config OBNetIpConfig + +/** + * @brief Device communication mode + */ +typedef enum { + OB_COMM_USB = 0x00, ///< USB + OB_COMM_NET = 0x01, ///< Ethernet +} OBCommunicationType, + ob_communication_type, OB_COMMUNICATION_TYPE; + +/** + * @brief USB power status + */ +typedef enum { + OB_USB_POWER_NO_PLUGIN = 0, ///< No plugin + OB_USB_POWER_5V_0A9 = 1, ///< 5V/0.9A + OB_USB_POWER_5V_1A5 = 2, ///< 5V/1.5A + OB_USB_POWER_5V_3A0 = 3, ///< 5V/3.0A +} OBUSBPowerState, + ob_usb_power_state; + +/** + * @brief DC power status + */ +typedef enum { + OB_DC_POWER_NO_PLUGIN = 0, ///< No plugin + OB_DC_POWER_PLUGIN = 1, ///< Plugin +} OBDCPowerState, + ob_dc_power_state; + +/** + * @brief Rotate degree + */ +typedef enum { + OB_ROTATE_DEGREE_0 = 0, ///< Rotate 0 + OB_ROTATE_DEGREE_90 = 90, ///< Rotate 90 + OB_ROTATE_DEGREE_180 = 180, ///< Rotate 180 + OB_ROTATE_DEGREE_270 = 270, ///< Rotate 270 +} ob_rotate_degree_type, + OBRotateDegreeType; + +/** + * @brief Power line frequency mode, for color camera anti-flicker configuration + */ +typedef enum { + OB_POWER_LINE_FREQ_MODE_CLOSE = 0, ///< Close + OB_POWER_LINE_FREQ_MODE_50HZ = 1, ///< 50Hz + OB_POWER_LINE_FREQ_MODE_60HZ = 2, ///< 60Hz +} ob_power_line_freq_mode, + OBPowerLineFreqMode; + +/** + * @brief Frame aggregate output mode + */ +typedef enum { + /** + * @brief Only FrameSet that contains all types of data frames will be output + */ + OB_FRAME_AGGREGATE_OUTPUT_ALL_TYPE_FRAME_REQUIRE = 0, + + /** + * @brief Color Frame Require output mode + * @brief Suitable for Color using H264, H265 and other inter-frame encoding format open stream + * + * @attention In this mode, the user may return null when getting a non-Color type data frame from the acquired FrameSet + */ + OB_FRAME_AGGREGATE_OUTPUT_COLOR_FRAME_REQUIRE, + + /** + * @brief FrameSet for any case will be output + * + * @attention In this mode, the user may return null when getting the specified type of data frame from the acquired FrameSet + */ + OB_FRAME_AGGREGATE_OUTPUT_ANY_SITUATION, + /** + * @brief Disable Frame Aggreate + * + * @attention In this mode, All types of data frames will output independently. + */ + OB_FRAME_AGGREGATE_OUTPUT_DISABLE, +} OB_FRAME_AGGREGATE_OUTPUT_MODE, + OBFrameAggregateOutputMode, ob_frame_aggregate_output_mode; +#define OB_FRAME_AGGREGATE_OUTPUT_FULL_FRAME_REQUIRE OB_FRAME_AGGREGATE_OUTPUT_ALL_TYPE_FRAME_REQUIRE + +/** + * @brief Enumeration of point cloud coordinate system types + */ +typedef enum { + OB_LEFT_HAND_COORDINATE_SYSTEM = 0, + OB_RIGHT_HAND_COORDINATE_SYSTEM = 1, +} OB_COORDINATE_SYSTEM_TYPE, + OBCoordinateSystemType, ob_coordinate_system_type; + +/** + * @brief Enumeration of device development modes + */ +typedef enum { + /** + * @brief User mode (default mode), which provides full camera device functionality + */ + OB_USER_MODE = 0, + + /** + * @brief Developer mode, which allows developers to access the operating system and software/hardware resources on the device directly + */ + OB_DEVELOPER_MODE = 1, +} OB_DEVICE_DEVELOPMENT_MODE, + OBDeviceDevelopmentMode, ob_device_development_mode; + +/** + * @brief The synchronization mode of the device. + */ +typedef enum { + + /** + * @brief free run mode + * @brief The device does not synchronize with other devices, + * @brief The Color and Depth can be set to different frame rates. + */ + OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN = 1 << 0, + + /** + * @brief standalone mode + * @brief The device does not synchronize with other devices. + * @brief The Color and Depth should be set to same frame rates, the Color and Depth will be synchronized. + */ + OB_MULTI_DEVICE_SYNC_MODE_STANDALONE = 1 << 1, + + /** + * @brief primary mode + * @brief The device is the primary device in the multi-device system, it will output the trigger signal via VSYNC_OUT pin on synchronization port by + * default. + * @brief The Color and Depth should be set to same frame rates, the Color and Depth will be synchronized and can be adjusted by @ref colorDelayUs, @ref + * depthDelayUs or @ref trigger2ImageDelayUs. + */ + OB_MULTI_DEVICE_SYNC_MODE_PRIMARY = 1 << 2, + + /** + * @brief secondary mode + * @brief The device is the secondary device in the multi-device system, it will receive the trigger signal via VSYNC_IN pin on synchronization port. It + * will out the trigger signal via VSYNC_OUT pin on synchronization port by default. + * @brief The Color and Depth should be set to same frame rates, the Color and Depth will be synchronized and can be adjusted by @ref colorDelayUs, @ref + * depthDelayUs or @ref trigger2ImageDelayUs. + * @brief After starting the stream, the device will wait for the trigger signal to start capturing images, and will stop capturing images when the trigger + * signal is stopped. + * + * @attention The frequency of the trigger signal should be same as the frame rate of the stream profile which is set when starting the stream. + */ + OB_MULTI_DEVICE_SYNC_MODE_SECONDARY = 1 << 3, + + /** + * @brief secondary synced mode + * @brief The device is the secondary device in the multi-device system, it will receive the trigger signal via VSYNC_IN pin on synchronization port. It + * will out the trigger signal via VSYNC_OUT pin on synchronization port by default. + * @brief The Color and Depth should be set to same frame rates, the Color and Depth will be synchronized and can be adjusted by @ref colorDelayUs, @ref + * depthDelayUs or @ref trigger2ImageDelayUs. + * @brief After starting the stream, the device will be immediately start capturing images, and will adjust the capture time when the trigger signal is + * received to synchronize with the primary device. If the trigger signal is stopped, the device will still capture images. + * + * @attention The frequency of the trigger signal should be same as the frame rate of the stream profile which is set when starting the stream. + */ + OB_MULTI_DEVICE_SYNC_MODE_SECONDARY_SYNCED = 1 << 4, + + /** + * @brief software triggering mode + * @brief The device will start one time image capture after receiving the capture command and will output the trigger signal via VSYNC_OUT pin by default. + * The capture command can be sent form host by call @ref ob_device_trigger_capture. The number of images captured each time can be set by @ref + * framesPerTrigger. + * @brief The Color and Depth should be set to same frame rates, the Color and Depth will be synchronized and can be adjusted by @ref colorDelayUs, @ref + * depthDelayUs or @ref trigger2ImageDelayUs. + * + * @brief The frequency of the user call @ref ob_device_trigger_capture to send the capture command multiplied by the number of frames per trigger should be + * less than the frame rate of the stream profile which is set when starting the stream. + */ + OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING = 1 << 5, + + /** + * @brief hardware triggering mode + * @brief The device will start one time image capture after receiving the trigger signal via VSYNC_IN pin on synchronization port and will output the + * trigger signal via VSYNC_OUT pin by default. The number of images captured each time can be set by @ref framesPerTrigger. + * @brief The Color and Depth should be set to same frame rates, the Color and Depth will be synchronized and can be adjusted by @ref colorDelayUs, @ref + * depthDelayUs or @ref trigger2ImageDelayUs. + * + * @attention The frequency of the trigger signal multiplied by the number of frames per trigger should be less than the frame rate of the stream profile + * which is set when starting the stream. + * @attention The trigger signal input via VSYNC_IN pin on synchronization port should be ouput by other device via VSYNC_OUT pin in hardware triggering + * mode or software triggering mode. + * @attention Due to different models may have different signal input requirements, please do not use different models to output trigger + * signal as input-trigger signal. + */ + OB_MULTI_DEVICE_SYNC_MODE_HARDWARE_TRIGGERING = 1 << 6, + + /** + * @brief IR and IMU sync mode + */ + OB_MULTI_DEVICE_SYNC_MODE_IR_IMU_SYNC = 1 << 7, + +} ob_multi_device_sync_mode, + OBMultiDeviceSyncMode; + +/** + * @brief The synchronization configuration of the device. + */ +typedef struct { + /** + * @brief The sync mode of the device. + */ + OBMultiDeviceSyncMode syncMode; + + /** + * @brief The delay time of the depth image capture after receiving the capture command or trigger signal in microseconds. + * + * @attention This parameter is only valid for some models, please refer to the product manual for details. + */ + int depthDelayUs; + + /** + * @brief The delay time of the color image capture after receiving the capture command or trigger signal in microseconds. + * + * @attention This parameter is only valid for some models, please refer to the product manual for details. + */ + int colorDelayUs; + + /** + * @brief The delay time of the image capture after receiving the capture command or trigger signal in microseconds. + * @brief The depth and color images are captured synchronously as the product design and can not change the delay between the depth and color images. + * + * @attention For Orbbec Astra 2 device, this parameter is valid only when the @ref triggerOutDelayUs is set to 0. + * @attention This parameter is only valid for some models to replace @ref depthDelayUs and @ref colorDelayUs, please refer to the product manual for + * details. + */ + int trigger2ImageDelayUs; + + /** + * @brief Trigger signal output enable flag. + * @brief After the trigger signal output is enabled, the trigger signal will be output when the capture command or trigger signal is received. User can + * adjust the delay time of the trigger signal output by @ref triggerOutDelayUs. + * + * @attention For some models, the trigger signal output is always enabled and cannot be disabled. + * @attention If device is in the @ref OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN or @ref OB_MULTI_DEVICE_SYNC_MODE_STANDALONE mode, the trigger signal output is + * always disabled. Set this parameter to true will not take effect. + */ + bool triggerOutEnable; + + /** + * @brief The delay time of the trigger signal output after receiving the capture command or trigger signal in microseconds. + * + * @attention For Orbbec Astra 2 device, only supported -1 and 0. -1 means the trigger signal output delay is automatically adjusted by the device, 0 means + * the trigger signal output is disabled. + */ + int triggerOutDelayUs; + + /** + * @brief The frame number of each stream after each trigger in triggering mode. + * + * @attention This parameter is only valid when the triggering mode is set to @ref OB_MULTI_DEVICE_SYNC_MODE_HARDWARE_TRIGGERING or @ref + * OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING. + * @attention The trigger frequency multiplied by the number of frames per trigger cannot exceed the maximum frame rate of the stream profile which is set + * when starting the stream. + */ + int framesPerTrigger; +} ob_multi_device_sync_config, OBMultiDeviceSyncConfig; + +/** + * @brief The timestamp reset configuration of the device. + * + */ +typedef struct { + /** + * @brief Whether to enable the timestamp reset function. + * @brief If the timestamp reset function is enabled, the timer for calculating the timestamp for output frames will be reset to 0 when the timestamp reset + * command or timestamp reset signal is received, and one timestamp reset signal will be output via TIMER_SYNC_OUT pin on synchronization port by default. + * The timestamp reset signal is input via TIMER_SYNC_IN pin on the synchronization port. + * + * @attention For some models, the timestamp reset function is always enabled and cannot be disabled. + */ + bool enable; + + /** + * @brief The delay time of executing the timestamp reset function after receiving the command or signal in microseconds. + */ + int timestamp_reset_delay_us; + + /** + * @brief the timestamp reset signal output enable flag. + * + * @attention For some models, the timestamp reset signal output is always enabled and cannot be disabled. + */ + bool timestamp_reset_signal_output_enable; +} ob_device_timestamp_reset_config, OBDeviceTimestampResetConfig; + +/** + * @brief Baseline calibration parameters + */ +typedef struct { + /** + * @brief Baseline length + */ + float baseline; + /** + * @brief Calibration distance + */ + float zpd; +} BASELINE_CALIBRATION_PARAM, ob_baseline_calibration_param, OBBaselineCalibrationParam; + +/** + * @brief HDR Configuration + */ +typedef struct { + + /** + * @brief Enable/disable HDR, after enabling HDR, the exposure_1 and gain_1 will be used as the first exposure and gain, and the exposure_2 and gain_2 will + * be used as the second exposure and gain. The output image will be alternately exposed and gain between the first and second + * exposure and gain. + * + * @attention After enabling HDR, the auto exposure will be disabled. + */ + uint8_t enable; + uint8_t sequence_name; ///< Sequence name + uint32_t exposure_1; ///< Exposure time 1 + uint32_t gain_1; ///< Gain 1 + uint32_t exposure_2; ///< Exposure time 2 + uint32_t gain_2; ///< Gain 2 +} HDR_CONFIG, ob_hdr_config, OBHdrConfig; + +/** + * @brief The rect of the region of interest + */ +typedef struct { + int16_t x0_left; + int16_t y0_top; + int16_t x1_right; + int16_t y1_bottom; +} AE_ROI, ob_region_of_interest, OBRegionOfInterest; + +typedef enum { + OB_FILTER_CONFIG_VALUE_TYPE_INVALID = -1, + OB_FILTER_CONFIG_VALUE_TYPE_INT = 0, + OB_FILTER_CONFIG_VALUE_TYPE_FLOAT = 1, + OB_FILTER_CONFIG_VALUE_TYPE_BOOLEAN = 2, +} OBFilterConfigValueType, + ob_filter_config_value_type; +/** + * @brief Configuration Item for the filter + */ +typedef struct { + const char *name; ///< Name of the configuration item + OBFilterConfigValueType type; ///< Value type of the configuration item + double min; ///< Minimum value casted to double + double max; ///< Maximum value casted to double + double step; ///< Step value casted to double + double def; ///< Default value casted to double + const char *desc; ///< Description of the configuration item +} OBFilterConfigSchemaItem, ob_filter_config_schema_item; + +/** + * @brief struct of serial number + */ +typedef struct { + char numberStr[16]; +} OBDeviceSerialNumber, ob_device_serial_number, OBSerialNumber, ob_serial_number; + +/** + * @brief Disparity offset interleaving configuration + */ +typedef struct { + uint8_t enable; + uint8_t offset0; + uint8_t offset1; + uint8_t reserved; +} OBDispOffsetConfig, ob_disp_offset_config; + +/** + * @brief Frame metadata types + * @brief The frame metadata is a set of meta info generated by the device for current individual frame. + */ +typedef enum { + /** + * @brief Timestamp when the frame is captured. + * @attention Different device models may have different units. It is recommended to use the timestamp related functions to get the timestamp in the + * correct units. + */ + OB_FRAME_METADATA_TYPE_TIMESTAMP = 0, + + /** + * @brief Timestamp in the middle of the capture. + * @brief Usually is the middle of the exposure time. + * + * @attention Different device models may have different units. + */ + OB_FRAME_METADATA_TYPE_SENSOR_TIMESTAMP = 1, + + /** + * @brief The number of current frame. + */ + OB_FRAME_METADATA_TYPE_FRAME_NUMBER = 2, + + /** + * @brief Auto exposure status + * @brief If the value is 0, it means the auto exposure is disabled. Otherwise, it means the auto exposure is enabled. + */ + OB_FRAME_METADATA_TYPE_AUTO_EXPOSURE = 3, + + /** + * @brief Exposure time + * + * @attention Different sensor may have different units. Usually, it is 100us for color sensor and 1us for depth/infrared sensor. + */ + OB_FRAME_METADATA_TYPE_EXPOSURE = 4, + + /** + * @brief Gain + * + * @attention For some device models, the gain value represents the gain level, not the multiplier. + */ + OB_FRAME_METADATA_TYPE_GAIN = 5, + + /** + * @brief Auto white balance status + * @brief If the value is 0, it means the auto white balance is disabled. Otherwise, it means the auto white balance is enabled. + */ + OB_FRAME_METADATA_TYPE_AUTO_WHITE_BALANCE = 6, + + /** + * @brief White balance + */ + OB_FRAME_METADATA_TYPE_WHITE_BALANCE = 7, + + /** + * @brief Brightness + */ + OB_FRAME_METADATA_TYPE_BRIGHTNESS = 8, + + /** + * @brief Contrast + */ + OB_FRAME_METADATA_TYPE_CONTRAST = 9, + + /** + * @brief Saturation + */ + OB_FRAME_METADATA_TYPE_SATURATION = 10, + + /** + * @brief Sharpness + */ + OB_FRAME_METADATA_TYPE_SHARPNESS = 11, + + /** + * @brief Backlight compensation + */ + OB_FRAME_METADATA_TYPE_BACKLIGHT_COMPENSATION = 12, + + /** + * @brief Hue + */ + OB_FRAME_METADATA_TYPE_HUE = 13, + + /** + * @brief Gamma + */ + OB_FRAME_METADATA_TYPE_GAMMA = 14, + + /** + * @brief Power line frequency + * @brief For anti-flickering, 0: Close, 1: 50Hz, 2: 60Hz, 3: Auto + */ + OB_FRAME_METADATA_TYPE_POWER_LINE_FREQUENCY = 15, + + /** + * @brief Low light compensation + * + * @attention The low light compensation is a feature inside the device, and can not manually control it. + */ + OB_FRAME_METADATA_TYPE_LOW_LIGHT_COMPENSATION = 16, + + /** + * @brief Manual white balance setting + */ + OB_FRAME_METADATA_TYPE_MANUAL_WHITE_BALANCE = 17, + + /** + * @brief Actual frame rate + * @brief The actual frame rate will be calculated according to the exposure time and other parameters. + */ + OB_FRAME_METADATA_TYPE_ACTUAL_FRAME_RATE = 18, + + /** + * @brief Frame rate + */ + OB_FRAME_METADATA_TYPE_FRAME_RATE = 19, + + /** + * @brief Left region of interest for the auto exposure Algorithm. + */ + OB_FRAME_METADATA_TYPE_AE_ROI_LEFT = 20, + + /** + * @brief Top region of interest for the auto exposure Algorithm. + */ + OB_FRAME_METADATA_TYPE_AE_ROI_TOP = 21, + + /** + * @brief Right region of interest for the auto exposure Algorithm. + */ + OB_FRAME_METADATA_TYPE_AE_ROI_RIGHT = 22, + + /** + * @brief Bottom region of interest for the auto exposure Algorithm. + */ + OB_FRAME_METADATA_TYPE_AE_ROI_BOTTOM = 23, + + /** + * @brief Exposure priority + */ + OB_FRAME_METADATA_TYPE_EXPOSURE_PRIORITY = 24, + + /** + * @brief HDR sequence name + */ + OB_FRAME_METADATA_TYPE_HDR_SEQUENCE_NAME = 25, + + /** + * @brief HDR sequence size + */ + OB_FRAME_METADATA_TYPE_HDR_SEQUENCE_SIZE = 26, + + /** + * @brief HDR sequence index + */ + OB_FRAME_METADATA_TYPE_HDR_SEQUENCE_INDEX = 27, + + /** + * @brief Laser power value in mW + * + * @attention The laser power value is an approximate estimation. + */ + OB_FRAME_METADATA_TYPE_LASER_POWER = 28, + + /** + * @brief Laser power level + */ + OB_FRAME_METADATA_TYPE_LASER_POWER_LEVEL = 29, + + /** + * @brief Laser status + * @brief 0: Laser off, 1: Laser on + */ + OB_FRAME_METADATA_TYPE_LASER_STATUS = 30, + + /** + * @brief GPIO input data + */ + OB_FRAME_METADATA_TYPE_GPIO_INPUT_DATA = 31, + + /** + * @brief disparity search offset value + */ + OB_FRAME_METADATA_TYPE_DISPARITY_SEARCH_OFFSET = 32, + + /** + * @brief disparity search range + */ + OB_FRAME_METADATA_TYPE_DISPARITY_SEARCH_RANGE = 33, + + /** + * @brief The number of frame metadata types, using for types iterating + * @attention It is not a valid frame metadata type + */ + OB_FRAME_METADATA_TYPE_COUNT, +} ob_frame_metadata_type, + OBFrameMetadataType; + +/** + * @brief For Linux, there are two ways to access the UVC device, libuvc and v4l2. The backend type is used to select the backend to access the device. + * + */ +typedef enum { + /** + * @brief Auto detect system capabilities and device hint to select backend + * + */ + OB_UVC_BACKEND_TYPE_AUTO, + + /** + * @brief Use libuvc backend to access the UVC device + * + */ + OB_UVC_BACKEND_TYPE_LIBUVC, + + /** + * @brief Use v4l2 backend to access the UVC device + * + */ + OB_UVC_BACKEND_TYPE_V4L2, + + /** + * @brief Use MSMF backend to access the UVC device + */ + OB_UVC_BACKEND_TYPE_MSMF, +} ob_uvc_backend_type, + OBUvcBackendType; + +/** + * @brief The playback status of the media + */ +typedef enum { + OB_PLAYBACK_UNKNOWN, + OB_PLAYBACK_PLAYING, /**< The media is playing */ + OB_PLAYBACK_PAUSED, /**< The media is paused */ + OB_PLAYBACK_STOPPED, /**< The media is stopped */ + OB_PLAYBACK_COUNT, +} ob_playback_status, + OBPlaybackStatus; + +// For compatibility +#define OB_FRAME_METADATA_TYPE_LASER_POWER_MODE OB_FRAME_METADATA_TYPE_LASER_POWER_LEVEL +#define OB_FRAME_METADATA_TYPE_EMITTER_MODE OB_FRAME_METADATA_TYPE_LASER_STATUS + +/** + * @brief Callback for file transfer + * + * @param state Transmission status + * @param message Transfer status information + * @param percent Transfer progress percentage + * @param user_data User-defined data + */ +typedef void (*ob_file_send_callback)(ob_file_tran_state state, const char *message, uint8_t percent, void *user_data); + +/** + * @brief Callback for firmware upgrade + * + * @param state Upgrade status + * @param message Upgrade status information + * @param percent Upgrade progress percentage + * @param user_data User-defined data + */ +typedef void (*ob_device_fw_update_callback)(ob_fw_update_state state, const char *message, uint8_t percent, void *user_data); + +/** + * @brief Callback for device status + * + * @param state Device status + * @param message Device status information + * @param user_data User-defined data + */ +typedef void (*ob_device_state_callback)(ob_device_state state, const char *message, void *user_data); + +/** + * @brief Callback for writing data + * + * @param state Write data status + * @param percent Write data percentage + * @param user_data User-defined data + */ +typedef void (*ob_set_data_callback)(ob_data_tran_state state, uint8_t percent, void *user_data); + +/** + * @brief Callback for reading data + * + * @param state Read data status + * @param dataChunk Read the returned data block + * @param user_data User-defined data + */ +typedef void (*ob_get_data_callback)(ob_data_tran_state state, ob_data_chunk *dataChunk, void *user_data); + +/** + * @brief Callback for media status (recording and playback) + * + * @param state Condition + * @param user_data User-defined data + */ +typedef void (*ob_media_state_callback)(ob_media_state state, void *user_data); + +/** + * @brief Callback for device change + * + * @param removed List of deleted (dropped) devices + * @param added List of added (online) devices + * @param user_data User-defined data + */ +typedef void (*ob_device_changed_callback)(ob_device_list *removed, ob_device_list *added, void *user_data); + +// typedef void (*ob_net_device_added_callback)(const char *added, void *user_data); +// typedef void (*ob_net_device_removed_callback)(const char *removed, void *user_data); + +/** + * @brief Callback for frame + * + * @param frame Frame object + * @param user_data User-defined data + */ +typedef void (*ob_frame_callback)(ob_frame *frame, void *user_data); +#define ob_filter_callback ob_frame_callback +#define ob_playback_callback ob_frame_callback + +/** + * @brief Callback for frameset + * + * @param frameset Frameset object + * @param user_data User-defined data + */ +typedef void (*ob_frameset_callback)(ob_frame *frameset, void *user_data); + +/** + * @brief Customize the delete callback + * + * @param buffer Data that needs to be deleted + * @param user_data User-defined data + */ +typedef void(ob_frame_destroy_callback)(uint8_t *buffer, void *user_data); + +/** + * @brief Callback for receiving log + * + * @param severity Current log level + * @param message Log message + * @param user_data User-defined data + */ +typedef void(ob_log_callback)(ob_log_severity severity, const char *message, void *user_data); + +typedef void (*ob_playback_status_changed_callback)(ob_playback_status status, void *user_data); +/** + * @brief Check if the sensor_type is a video sensor + * + * @param sensor_type Sensor type to check + * @return True if sensor_type is a video sensor, false otherwise + */ +#define ob_is_video_sensor_type(sensor_type) \ + (sensor_type == OB_SENSOR_COLOR || sensor_type == OB_SENSOR_DEPTH || sensor_type == OB_SENSOR_IR || sensor_type == OB_SENSOR_IR_LEFT \ + || sensor_type == OB_SENSOR_IR_RIGHT) + +/** + * @brief check if the stream_type is a video stream + * + * @param stream_type Stream type to check + * @return True if stream_type is a video stream, false otherwise + */ +#define ob_is_video_stream_type(stream_type) \ + (stream_type == OB_STREAM_COLOR || stream_type == OB_STREAM_DEPTH || stream_type == OB_STREAM_IR || stream_type == OB_STREAM_IR_LEFT \ + || stream_type == OB_STREAM_IR_RIGHT || stream_type == OB_STREAM_VIDEO) + +/** + * @brief Check if sensor_type is an IR sensor + * + * @param sensor_type Sensor type to check + * @return True if sensor_type is an IR sensor, false otherwise + */ +#define is_ir_sensor(sensor_type) (sensor_type == OB_SENSOR_IR || sensor_type == OB_SENSOR_IR_LEFT || sensor_type == OB_SENSOR_IR_RIGHT) +#define isIRSensor is_ir_sensor + +/** + * @brief Check if stream_type is an IR stream + * + * @param stream_type Stream type to check + * @return True if stream_type is an IR stream, false otherwise + */ +#define is_ir_stream(stream_type) (stream_type == OB_STREAM_IR || stream_type == OB_STREAM_IR_LEFT || stream_type == OB_STREAM_IR_RIGHT) +#define isIRStream is_ir_stream + +/** + * @brief Check if frame_type is an IR frame + * + * @param frame_type Frame type to check + * @return True if frame_type is an IR frame, false otherwise + */ +#define is_ir_frame(frame_type) (frame_type == OB_FRAME_IR || frame_type == OB_FRAME_IR_LEFT || frame_type == OB_FRAME_IR_RIGHT) +#define isIRFrame is_ir_frame + +/** + * @brief The default Decrypt Key + */ +#define OB_DEFAULT_DECRYPT_KEY (nullptr) + +#ifdef __cplusplus +} +#endif + +#pragma pack(pop) diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Pipeline.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Pipeline.h new file mode 100644 index 0000000..c670748 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Pipeline.h @@ -0,0 +1,335 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Pipeline.h + * @brief The SDK's advanced API can quickly implement functions such as switching streaming, frame synchronization, software filtering, etc., suitable for + * applications, and the algorithm focuses on rgbd data stream scenarios. If you are on real-time or need to handle synchronization separately, align the scene. + * Please use the interface of Device's Lower API. + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ObTypes.h" + +/** + * @brief Create a pipeline object + * + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_pipeline* return the pipeline object + */ +OB_EXPORT ob_pipeline *ob_create_pipeline(ob_error **error); + +/** + * @brief Using device objects to create pipeline objects + * + * @param[in] dev Device object used to create pipeline + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_pipeline* return the pipeline object + */ +OB_EXPORT ob_pipeline *ob_create_pipeline_with_device(const ob_device *dev, ob_error **error); + +/** + * @brief Delete pipeline objects + * + * @param[in] pipeline The pipeline object to be deleted + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_delete_pipeline(ob_pipeline *pipeline, ob_error **error); + +/** + * @brief Start the pipeline with default parameters + * + * @param[in] pipeline pipeline object + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_pipeline_start(ob_pipeline *pipeline, ob_error **error); + +/** + * @brief Start the pipeline with configuration parameters + * + * @param[in] pipeline pipeline object + * @param[in] config Parameters to be configured + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_pipeline_start_with_config(ob_pipeline *pipeline, const ob_config *config, ob_error **error); + +/** + * @brief Start the pipeline and set the frame collection data callback + * + * @attention After start the pipeline with this interface, the frames will be output to the callback function and cannot be obtained frames by call + * @ob_pipeline_wait_for_frameset + * + * @param[in] pipeline pipeline object + * @param[in] config Parameters to be configured + * @param[in] callback Trigger a callback when all frame data in the frameset arrives + * @param[in] user_data Pass in any user data and get it from the callback + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_pipeline_start_with_callback(ob_pipeline *pipeline, const ob_config *config, ob_frameset_callback callback, void *user_data, + ob_error **error); + +/** + * @brief Stop pipeline + * + * @param[in] pipeline pipeline object + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_pipeline_stop(ob_pipeline *pipeline, ob_error **error); + +/** + * @brief Get the configuration object associated with the pipeline + * @brief Returns default configuration if the user has not configured + * + * @param[in] pipeline The pipeline object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_config* The configuration object + */ +OB_EXPORT ob_config *ob_pipeline_get_config(const ob_pipeline *pipeline, ob_error **error); + +/** + * @brief Switch the corresponding configuration + * + * @param[in] pipeline The pipeline object + * @param[in] config The pipeline configuration + * @param[out] error Log error messages + */ +OB_EXPORT void ob_pipeline_switch_config(ob_pipeline *pipeline, ob_config *config, ob_error **error); + +/** + * @brief Wait for a set of frames to be returned synchronously + * + * @param[in] pipeline The pipeline object + * @param[in] timeout_ms The timeout for waiting (in milliseconds) + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_frame* The frameset that was waited for. A frameset is a special frame that can be used to obtain independent frames from the set. + */ +OB_EXPORT ob_frame *ob_pipeline_wait_for_frameset(ob_pipeline *pipeline, uint32_t timeout_ms, ob_error **error); + +/** + * @brief Get the device object associated with the pipeline + * + * @param[in] pipeline The pipeline object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_device* The device object + */ +OB_EXPORT ob_device *ob_pipeline_get_device(const ob_pipeline *pipeline, ob_error **error); + +/** + * @brief Get the stream profile list associated with the pipeline + * + * @param[in] pipeline The pipeline object + * @param[in] sensorType The sensor type. The supported sensor types can be obtained through the ob_device_get_sensor_list() interface. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_stream_profile_list* The stream profile list + */ +OB_EXPORT ob_stream_profile_list *ob_pipeline_get_stream_profile_list(const ob_pipeline *pipeline, ob_sensor_type sensorType, ob_error **error); + +/** + * @brief Enable frame synchronization + * @brief Synchronize the frames of different streams by using the timestamp information of the frames. + * @brief Dynamically (when pipeline is started) enable/disable frame synchronization is allowed. + * + * @param[in] pipeline The pipeline object + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_pipeline_enable_frame_sync(ob_pipeline *pipeline, ob_error **error); + +/** + * @brief Disable frame synchronization + * + * @param[in] pipeline The pipeline object + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_pipeline_disable_frame_sync(ob_pipeline *pipeline, ob_error **error); + +/** + * @brief Return a list of D2C-enabled depth sensor resolutions corresponding to the input color sensor resolution + * + * @param[in] pipeline The pipeline object + * @param[in] color_profile The input profile of the color sensor + * @param[in] align_mode The input align mode + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_stream_profile_list* The list of D2C-enabled depth sensor resolutions + */ +OB_EXPORT ob_stream_profile_list *ob_get_d2c_depth_profile_list(const ob_pipeline *pipeline, const ob_stream_profile *color_profile, ob_align_mode align_mode, + ob_error **error); + +/** + * @brief Create the pipeline configuration + * + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_config* The configuration object + */ +OB_EXPORT ob_config *ob_create_config(ob_error **error); + +/** + * @brief Delete the pipeline configuration + * + * @param[in] config The configuration to be deleted + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_delete_config(ob_config *config, ob_error **error); + +/** + * @brief Enable a stream with default profile + * + * @param[in] config The pipeline configuration object + * @param[in] stream_type The type of the stream to be enabled + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_config_enable_stream(ob_config *config, ob_stream_type stream_type, ob_error **error); + +/** + * @brief Enable all streams in the pipeline configuration + * + * @param[in] config The pipeline configuration + * @param[out] error Log error messages + */ +OB_EXPORT void ob_config_enable_all_stream(ob_config *config, ob_error **error); + +/** + * @brief Enable a stream according to the stream profile + * + * @param[in] config The pipeline configuration object + * @param[in] profile The stream profile to be enabled + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_config_enable_stream_with_stream_profile(ob_config *config, const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Enable video stream with specified parameters + * + * @attention The stream_type should be a video stream type, such as OB_STREAM_IR, OB_STREAM_COLOR, OB_STREAM_DEPTH, etc. + * + * @param[in] config The pipeline configuration object + * @param[in] stream_type The type of the stream to be enabled + * @param[in] width The width of the video stream + * @param[in] height The height of the video stream + * @param[in] fps The frame rate of the video stream + * @param[in] format The format of the video stream + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_config_enable_video_stream(ob_config *config, ob_stream_type stream_type, uint32_t width, uint32_t height, uint32_t fps, ob_format format, + ob_error **error); + +/** + * @brief Enable accelerometer stream with specified parameters + * + * @param[in] config The pipeline configuration object + * @param[in] full_scale_range The full scale range of the accelerometer + * @param[in] sample_rate The sample rate of the accelerometer + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_config_enable_accel_stream(ob_config *config, ob_accel_full_scale_range full_scale_range, ob_accel_sample_rate sample_rate, ob_error **error); + +/** + * @brief Enable gyroscope stream with specified parameters + * + * @param[in] config The pipeline configuration object + * @param[in] full_scale_range The full scale range of the gyroscope + * @param[in] sample_rate The sample rate of the gyroscope + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_config_enable_gyro_stream(ob_config *config, ob_gyro_full_scale_range full_scale_range, ob_gyro_sample_rate sample_rate, ob_error **error); + +/** + * @brief Get the enabled stream profile list in the pipeline configuration + * + * @param config The pipeline configuration object + * @param error Pointer to an error object that will be set if an error occurs. + * @return ob_stream_profile_list* The enabled stream profile list, should be released by @ref ob_delete_stream_profile_list after use + */ +OB_EXPORT ob_stream_profile_list *ob_config_get_enabled_stream_profile_list(const ob_config *config, ob_error **error); + +/** + * @brief Disable a specific stream in the pipeline configuration + * + * @param[in] config The pipeline configuration object + * @param[in] type The type of stream to be disabled + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_config_disable_stream(ob_config *config, ob_stream_type type, ob_error **error); + +/** + * @brief Disable all streams in the pipeline configuration + * + * @param[in] config The pipeline configuration object + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_config_disable_all_stream(ob_config *config, ob_error **error); + +/** + * @brief Set the alignment mode for the pipeline configuration + * + * @param[in] config The pipeline configuration object + * @param[in] mode The alignment mode to be set + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_config_set_align_mode(ob_config *config, ob_align_mode mode, ob_error **error); + +/** + * @brief Set whether depth scaling is required after enable depth to color alignment + * @brief After enabling depth to color alignment, the depth image may need to be scaled to match the color image size. + * + * @param[in] config The pipeline configuration object + * @param[in] enable Whether scaling is required + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_config_set_depth_scale_after_align_require(ob_config *config, bool enable, ob_error **error); + +/** + * @brief Set the frame aggregation output mode for the pipeline configuration + * @brief The processing strategy when the FrameSet generated by the frame aggregation function does not contain the frames of all opened streams (which + * can be caused by different frame rates of each stream, or by the loss of frames of one stream): drop directly or output to the user. + * + * @param[in] config The pipeline configuration object + * @param[in] mode The frame aggregation output mode to be set (default mode is @ref OB_FRAME_AGGREGATE_OUTPUT_ANY_SITUATION) + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_config_set_frame_aggregate_output_mode(ob_config *config, ob_frame_aggregate_output_mode mode, ob_error **error); + +/** + * @brief Get current camera parameters + * @attention If D2C is enabled, it will return the camera parameters after D2C, if not, it will return to the default parameters + * + * @param[in] pipeline pipeline object + * @param[out] error Log error messages + * @return ob_camera_param The camera internal parameters + */ +OB_EXPORT ob_camera_param ob_pipeline_get_camera_param(ob_pipeline *pipeline, ob_error **error); + +/** + * @brief Get the current camera parameters + * + * @param[in] pipeline pipeline object + * @param[in] colorWidth color width + * @param[in] colorHeight color height + * @param[in] depthWidth depth width + * @param[in] depthHeight depth height + * @param[out] error Log error messages + * @return ob_camera_param returns camera internal parameters + */ +OB_EXPORT ob_camera_param ob_pipeline_get_camera_param_with_profile(ob_pipeline *pipeline, uint32_t colorWidth, uint32_t colorHeight, uint32_t depthWidth, + uint32_t depthHeight, ob_error **error); + +/** + * @brief Get device calibration parameters with the specified configuration + * + * @param[in] pipeline pipeline object + * @param[in] config The pipeline configuration + * @param[out] error Log error messages + * @return ob_calibration_param The calibration parameters + */ +OB_EXPORT ob_calibration_param ob_pipeline_get_calibration_param(ob_pipeline *pipeline, ob_config *config, ob_error **error); + +// The following interfaces are deprecated and are retained here for compatibility purposes. +#define ob_config_set_depth_scale_require ob_config_set_depth_scale_after_align_require + +#ifdef __cplusplus +} +#endif + diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Property.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Property.h new file mode 100644 index 0000000..bc0a671 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Property.h @@ -0,0 +1,867 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Property.h + * @brief Control command property list maintenance + */ + +#pragma once + +#include "ObTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumeration value describing all attribute control commands of the device + */ +typedef enum { + /** + * @brief LDP switch + */ + OB_PROP_LDP_BOOL = 2, + + /** + * @brief Laser switch + */ + OB_PROP_LASER_BOOL = 3, + + /** + * @brief laser pulse width + */ + OB_PROP_LASER_PULSE_WIDTH_INT = 4, + + /** + * @brief Laser current (uint: mA) + */ + OB_PROP_LASER_CURRENT_FLOAT = 5, + + /** + * @brief IR flood switch + */ + OB_PROP_FLOOD_BOOL = 6, + + /** + * @brief IR flood level + */ + OB_PROP_FLOOD_LEVEL_INT = 7, + + /** + * @brief Enable/disable temperature compensation + * + */ + OB_PROP_TEMPERATURE_COMPENSATION_BOOL = 8, + + /** + * @brief Depth mirror + */ + OB_PROP_DEPTH_MIRROR_BOOL = 14, + + /** + * @brief Depth flip + */ + OB_PROP_DEPTH_FLIP_BOOL = 15, + + /** + * @brief Depth Postfilter + */ + OB_PROP_DEPTH_POSTFILTER_BOOL = 16, + + /** + * @brief Depth Holefilter + */ + OB_PROP_DEPTH_HOLEFILTER_BOOL = 17, + + /** + * @brief IR mirror + */ + OB_PROP_IR_MIRROR_BOOL = 18, + + /** + * @brief IR flip + */ + OB_PROP_IR_FLIP_BOOL = 19, + + /** + * @brief Minimum depth threshold + */ + OB_PROP_MIN_DEPTH_INT = 22, + + /** + * @brief Maximum depth threshold + */ + OB_PROP_MAX_DEPTH_INT = 23, + + /** + * @brief Software filter switch + */ + OB_PROP_DEPTH_NOISE_REMOVAL_FILTER_BOOL = 24, + + /** + * @brief LDP status + */ + OB_PROP_LDP_STATUS_BOOL = 32, + + /** + * @brief maxdiff for depth noise removal filter + */ + OB_PROP_DEPTH_NOISE_REMOVAL_FILTER_MAX_DIFF_INT = 40, + + /** + * @brief maxSpeckleSize for depth noise removal filter + */ + OB_PROP_DEPTH_NOISE_REMOVAL_FILTER_MAX_SPECKLE_SIZE_INT = 41, + + /** + * @brief Hardware d2c is on + */ + OB_PROP_DEPTH_ALIGN_HARDWARE_BOOL = 42, + + /** + * @brief Timestamp adjustment + */ + OB_PROP_TIMESTAMP_OFFSET_INT = 43, + + /** + * @brief Hardware distortion switch Rectify + */ + OB_PROP_HARDWARE_DISTORTION_SWITCH_BOOL = 61, + + /** + * @brief Fan mode switch + */ + OB_PROP_FAN_WORK_MODE_INT = 62, + + /** + * @brief Multi-resolution D2C mode + */ + OB_PROP_DEPTH_ALIGN_HARDWARE_MODE_INT = 63, + + /** + * @brief Anti_collusion activation status + */ + OB_PROP_ANTI_COLLUSION_ACTIVATION_STATUS_BOOL = 64, + + /** + * @brief the depth precision level, which may change the depth frame data unit, needs to be confirmed through the ValueScale interface of + * DepthFrame + */ + OB_PROP_DEPTH_PRECISION_LEVEL_INT = 75, + + /** + * @brief tof filter range configuration + */ + OB_PROP_TOF_FILTER_RANGE_INT = 76, + + /** + * @brief laser mode, the firmware terminal currently only return 1: IR Drive, 2: Torch + */ + OB_PROP_LASER_MODE_INT = 79, + + /** + * @brief brt2r-rectify function switch (brt2r is a special module on mx6600), 0: Disable, 1: Rectify Enable + */ + OB_PROP_RECTIFY2_BOOL = 80, + + /** + * @brief Color mirror + */ + OB_PROP_COLOR_MIRROR_BOOL = 81, + + /** + * @brief Color flip + */ + OB_PROP_COLOR_FLIP_BOOL = 82, + + /** + * @brief Indicator switch, 0: Disable, 1: Enable + */ + OB_PROP_INDICATOR_LIGHT_BOOL = 83, + + /** + * @brief Disparity to depth switch, false: switch to software disparity convert to depth, true: switch to hardware disparity convert to depth + */ + OB_PROP_DISPARITY_TO_DEPTH_BOOL = 85, + + /** + * @brief BRT function switch (anti-background interference), 0: Disable, 1: Enable + */ + OB_PROP_BRT_BOOL = 86, + + /** + * @brief Watchdog function switch, 0: Disable, 1: Enable + */ + OB_PROP_WATCHDOG_BOOL = 87, + + /** + * @brief External signal trigger restart function switch, 0: Disable, 1: Enable + */ + OB_PROP_EXTERNAL_SIGNAL_RESET_BOOL = 88, + + /** + * @brief Heartbeat monitoring function switch, 0: Disable, 1: Enable + */ + OB_PROP_HEARTBEAT_BOOL = 89, + + /** + * @brief Depth cropping mode device: OB_DEPTH_CROPPING_MODE + */ + OB_PROP_DEPTH_CROPPING_MODE_INT = 90, + + /** + * @brief D2C preprocessing switch (such as RGB cropping), 0: off, 1: on + */ + OB_PROP_D2C_PREPROCESS_BOOL = 91, + + /** + * @brief Enable/disable GPM function + */ + OB_PROP_GPM_BOOL = 93, + + /** + * @brief Custom RGB cropping switch, 0 is off, 1 is on custom cropping, and the ROI cropping area is issued + */ + OB_PROP_RGB_CUSTOM_CROP_BOOL = 94, + + /** + * @brief Device operating mode (power consumption) + */ + OB_PROP_DEVICE_WORK_MODE_INT = 95, + + /** + * @brief Device communication type, 0: USB; 1: Ethernet(RTSP) + */ + OB_PROP_DEVICE_COMMUNICATION_TYPE_INT = 97, + + /** + * @brief Switch infrared imaging mode, 0: active IR mode, 1: passive IR mode + */ + OB_PROP_SWITCH_IR_MODE_INT = 98, + + /** + * @brief Laser power level + */ + OB_PROP_LASER_POWER_LEVEL_CONTROL_INT = 99, + + /** + * @brief LDP's measure distance, unit: mm + */ + OB_PROP_LDP_MEASURE_DISTANCE_INT = 100, + + /** + * @brief Reset device time to zero + */ + OB_PROP_TIMER_RESET_SIGNAL_BOOL = 104, + + /** + * @brief Enable send reset device time signal to other device. true: enable, false: disable + */ + OB_PROP_TIMER_RESET_TRIGGER_OUT_ENABLE_BOOL = 105, + + /** + * @brief Delay to reset device time, unit: us + */ + OB_PROP_TIMER_RESET_DELAY_US_INT = 106, + + /** + * @brief Signal to capture image + */ + OB_PROP_CAPTURE_IMAGE_SIGNAL_BOOL = 107, + + /** + * @brief Right IR sensor mirror state + */ + OB_PROP_IR_RIGHT_MIRROR_BOOL = 112, + + /** + * @brief Number frame to capture once a 'OB_PROP_CAPTURE_IMAGE_SIGNAL_BOOL' effect. range: [1, 255] + */ + OB_PROP_CAPTURE_IMAGE_FRAME_NUMBER_INT = 113, + + /** + * @brief Right IR sensor flip state. true: flip image, false: origin, default: false + */ + OB_PROP_IR_RIGHT_FLIP_BOOL = 114, + + /** + * @brief Color sensor rotation, angle{0, 90, 180, 270} + */ + OB_PROP_COLOR_ROTATE_INT = 115, + + /** + * @brief IR/Left-IR sensor rotation, angle{0, 90, 180, 270} + */ + OB_PROP_IR_ROTATE_INT = 116, + + /** + * @brief Right IR sensor rotation, angle{0, 90, 180, 270} + */ + OB_PROP_IR_RIGHT_ROTATE_INT = 117, + + /** + * @brief Depth sensor rotation, angle{0, 90, 180, 270} + */ + OB_PROP_DEPTH_ROTATE_INT = 118, + + /** + * @brief Get hardware laser power actual level which real state of laser element. OB_PROP_LASER_POWER_LEVEL_CONTROL_INT99 will effect this command + * which it setting and changed the hardware laser energy level. + */ + OB_PROP_LASER_POWER_ACTUAL_LEVEL_INT = 119, + + /** + * @brief USB's power state, enum type: OBUSBPowerState + */ + OB_PROP_USB_POWER_STATE_INT = 121, + + /** + * @brief DC's power state, enum type: OBDCPowerState + */ + OB_PROP_DC_POWER_STATE_INT = 122, + + /** + * @brief Device development mode switch, optional modes can refer to the definition in @ref OBDeviceDevelopmentMode,the default mode is + * @ref OB_USER_MODE + * @attention The device takes effect after rebooting when switching modes. + */ + OB_PROP_DEVICE_DEVELOPMENT_MODE_INT = 129, + + /** + * @brief Multi-DeviceSync synchronized signal trigger out is enable state. true: enable, false: disable + */ + OB_PROP_SYNC_SIGNAL_TRIGGER_OUT_BOOL = 130, + + /** + * @brief Restore factory settings and factory parameters + * @attention This command can only be written, and the parameter value must be true. The command takes effect after restarting the device. + */ + OB_PROP_RESTORE_FACTORY_SETTINGS_BOOL = 131, + + /** + * @brief Enter recovery mode (flashing mode) when boot the device + * @attention The device will take effect after rebooting with the enable option. After entering recovery mode, you can upgrade the device system. Upgrading + * the system may cause system damage, please use it with caution. + */ + OB_PROP_BOOT_INTO_RECOVERY_MODE_BOOL = 132, + + /** + * @brief Query whether the current device is running in recovery mode (read-only) + */ + OB_PROP_DEVICE_IN_RECOVERY_MODE_BOOL = 133, + + /** + * @brief Capture interval mode, 0:time interval, 1:number interval + */ + OB_PROP_CAPTURE_INTERVAL_MODE_INT = 134, + + /** + * @brief Capture time interval + */ + OB_PROP_CAPTURE_IMAGE_TIME_INTERVAL_INT = 135, + + /** + * @brief Capture number interval + */ + OB_PROP_CAPTURE_IMAGE_NUMBER_INTERVAL_INT = 136, + + /* + * @brief Timer reset function enable + */ + OB_PROP_TIMER_RESET_ENABLE_BOOL = 140, + + /** + * @brief Enable or disable the device to retry USB2.0 re-identification when the device is connected to a USB2.0 port. + * @brief This feature ensures that the device is not mistakenly identified as a USB 2.0 device when connected to a USB 3.0 port. + */ + OB_PROP_DEVICE_USB2_REPEAT_IDENTIFY_BOOL = 141, + + /** + * @brief Reboot device delay mode. Delay time unit: ms, range: [0, 8000). + */ + OB_PROP_DEVICE_REBOOT_DELAY_INT = 142, + + /** + * @brief Query the status of laser overcurrent protection (read-only) + */ + OB_PROP_LASER_OVERCURRENT_PROTECTION_STATUS_BOOL = 148, + + /** + * @brief Query the status of laser pulse width protection (read-only) + */ + OB_PROP_LASER_PULSE_WIDTH_PROTECTION_STATUS_BOOL = 149, + + /** + * @brief Laser always on, true: always on, false: off, laser will be turned off when out of exposure time + */ + OB_PROP_LASER_ALWAYS_ON_BOOL = 174, + + /** + * @brief Laser on/off alternate mode, 0: off, 1: on-off alternate, 2: off-on alternate + * @attention When turn on this mode, the laser will turn on and turn off alternately each frame. + */ + OB_PROP_LASER_ON_OFF_PATTERN_INT = 175, + + /** + * @brief Depth unit flexible adjustment\ + * @brief This property allows continuous adjustment of the depth unit, unlike @ref OB_PROP_DEPTH_PRECISION_LEVEL_INT must be set to some fixed value. + */ + OB_PROP_DEPTH_UNIT_FLEXIBLE_ADJUSTMENT_FLOAT = 176, + + /** + * @brief Laser control, 0: off, 1: on, 2: auto + * + */ + OB_PROP_LASER_CONTROL_INT = 182, + + /** + * @brief IR brightness + */ + OB_PROP_IR_BRIGHTNESS_INT = 184, + + /** + * @brief Slave/secondary device synchronization status (read-only) + */ + OB_PROP_SLAVE_DEVICE_SYNC_STATUS_BOOL = 188, + + /** + * @brief Color AE max exposure + */ + OB_PROP_COLOR_AE_MAX_EXPOSURE_INT = 189, + + /** + * @brief Max exposure time of IR auto exposure + */ + OB_PROP_IR_AE_MAX_EXPOSURE_INT = 190, + + /** + * @brief Disparity search range mode, 1: 128, 2: 256 + */ + OB_PROP_DISP_SEARCH_RANGE_MODE_INT = 191, + + /** + * @brief Laser high temperature protection + */ + OB_PROP_LASER_HIGH_TEMPERATURE_PROTECT_BOOL = 193, + + /** + * @brief low exposure laser control + * + * @brief Currently using for DabaiA device,if the exposure value is lower than a certain threshold, the laser is turned off; + * if it exceeds another threshold, the laser is turned on again. + */ + OB_PROP_LOW_EXPOSURE_LASER_CONTROL_BOOL = 194, + + /** + * @brief check pps sync in signal + */ + OB_PROP_CHECK_PPS_SYNC_IN_SIGNAL_BOOL = 195, + + /** + * @brief Disparity search range offset, range: [0, 127] + */ + OB_PROP_DISP_SEARCH_OFFSET_INT = 196, + + /** + * @brief Repower device (cut off power and power on again) + * + * @brief Currently using for GMSL device, cut off power and power on again by GMSL host driver. + */ + OB_PROP_DEVICE_REPOWER_BOOL = 202, + + /** + * @brief frame interleave config index + */ + OB_PROP_FRAME_INTERLEAVE_CONFIG_INDEX_INT = 204, + + /** + * @brief frame interleave enable (true:enable,false:disable) + */ + OB_PROP_FRAME_INTERLEAVE_ENABLE_BOOL = 205, + /** + * @brief laser pattern sync with delay(us) + */ + OB_PROP_FRAME_INTERLEAVE_LASER_PATTERN_SYNC_DELAY_INT = 206, + /** + * @brief Get the health check result from device,range is [0.0f,1.5f] + */ + OB_PROP_ON_CHIP_CALIBRATION_HEALTH_CHECK_FLOAT = 209, + + /** + * @brief Enable or disable on-chip calibration + */ + OB_PROP_ON_CHIP_CALIBRATION_ENABLE_BOOL = 210, + + /** + * @brief hardware noise remove filter switch + */ + OB_PROP_HW_NOISE_REMOVE_FILTER_ENABLE_BOOL = 211, + /** + * @brief hardware noise remove filter threshold ,range [0.0 - 1.0] + */ + OB_PROP_HW_NOISE_REMOVE_FILTER_THRESHOLD_FLOAT = 212, + /** + * @brief soft trigger auto capture enable, use in OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING mode + */ + OB_DEVICE_AUTO_CAPTURE_ENABLE_BOOL = 216, + /** + * @brief soft trigger auto capture interval time, use in OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING mode + */ + OB_DEVICE_AUTO_CAPTURE_INTERVAL_TIME_INT = 217, + + /** + * @brief PTP time synchronization enable + */ + OB_DEVICE_PTP_CLOCK_SYNC_ENABLE_BOOL = 223, + + /** + * @brief Baseline calibration parameters + */ + OB_STRUCT_BASELINE_CALIBRATION_PARAM = 1002, + + /** + * @brief Device temperature information + */ + OB_STRUCT_DEVICE_TEMPERATURE = 1003, + + /** + * @brief TOF exposure threshold range + */ + OB_STRUCT_TOF_EXPOSURE_THRESHOLD_CONTROL = 1024, + + /** + * @brief get/set serial number + */ + OB_STRUCT_DEVICE_SERIAL_NUMBER = 1035, + + /** + * @brief get/set device time + */ + OB_STRUCT_DEVICE_TIME = 1037, + + /** + * @brief Multi-device synchronization mode and parameter configuration + */ + OB_STRUCT_MULTI_DEVICE_SYNC_CONFIG = 1038, + + /** + * @brief RGB cropping ROI + */ + OB_STRUCT_RGB_CROP_ROI = 1040, + + /** + * @brief Device IP address configuration + */ + OB_STRUCT_DEVICE_IP_ADDR_CONFIG = 1041, + + /** + * @brief The current camera depth mode + */ + OB_STRUCT_CURRENT_DEPTH_ALG_MODE = 1043, + + /** + * @brief A list of depth accuracy levels, returning an array of uin16_t, corresponding to the enumeration + */ + OB_STRUCT_DEPTH_PRECISION_SUPPORT_LIST = 1045, + + /** + * @brief Device network static ip config record + * @brief Using for get last static ip config, witch is record in device flash when user set static ip config + * + * @attention read only + */ + OB_STRUCT_DEVICE_STATIC_IP_CONFIG_RECORD = 1053, + + /** + * @brief Using to configure the depth sensor's HDR mode + * @brief The Value type is @ref OBHdrConfig + * + * @attention After enable HDR mode, the depth sensor auto exposure will be disabled. + */ + OB_STRUCT_DEPTH_HDR_CONFIG = 1059, + + /** + * @brief Color Sensor AE ROI configuration + * @brief The Value type is @ref OBRegionOfInterest + */ + OB_STRUCT_COLOR_AE_ROI = 1060, + + /** + * @brief Depth Sensor AE ROI configuration + * @brief The Value type is @ref OBRegionOfInterest + * @brief Since the ir sensor is the same physical sensor as the depth sensor, this property will also effect the ir sensor. + */ + OB_STRUCT_DEPTH_AE_ROI = 1061, + + /** + * @brief ASIC serial number + */ + OB_STRUCT_ASIC_SERIAL_NUMBER = 1063, + + /** + * @brief Disparity offset interleaving + */ + OB_STRUCT_DISP_OFFSET_CONFIG = 1064, + + /** + * @brief Color camera auto exposure + */ + OB_PROP_COLOR_AUTO_EXPOSURE_BOOL = 2000, + + /** + * @brief Color camera exposure adjustment + */ + OB_PROP_COLOR_EXPOSURE_INT = 2001, + + /** + * @brief Color camera gain adjustment + */ + OB_PROP_COLOR_GAIN_INT = 2002, + + /** + * @brief Color camera automatic white balance + */ + OB_PROP_COLOR_AUTO_WHITE_BALANCE_BOOL = 2003, + + /** + * @brief Color camera white balance adjustment + */ + OB_PROP_COLOR_WHITE_BALANCE_INT = 2004, + + /** + * @brief Color camera brightness adjustment + */ + OB_PROP_COLOR_BRIGHTNESS_INT = 2005, + + /** + * @brief Color camera sharpness adjustment + */ + OB_PROP_COLOR_SHARPNESS_INT = 2006, + + /** + * @brief Color camera shutter adjustment + */ + OB_PROP_COLOR_SHUTTER_INT = 2007, + + /** + * @brief Color camera saturation adjustment + */ + OB_PROP_COLOR_SATURATION_INT = 2008, + + /** + * @brief Color camera contrast adjustment + */ + OB_PROP_COLOR_CONTRAST_INT = 2009, + + /** + * @brief Color camera gamma adjustment + */ + OB_PROP_COLOR_GAMMA_INT = 2010, + + /** + * @brief Color camera image rotation + */ + OB_PROP_COLOR_ROLL_INT = 2011, + + /** + * @brief Color camera auto exposure priority + */ + OB_PROP_COLOR_AUTO_EXPOSURE_PRIORITY_INT = 2012, + + /** + * @brief Color camera brightness compensation + */ + OB_PROP_COLOR_BACKLIGHT_COMPENSATION_INT = 2013, + + /** + * @brief Color camera color tint + */ + OB_PROP_COLOR_HUE_INT = 2014, + + /** + * @brief Color Camera Power Line Frequency + */ + OB_PROP_COLOR_POWER_LINE_FREQUENCY_INT = 2015, + + /** + * @brief Automatic exposure of depth camera (infrared camera will be set synchronously under some models of devices) + */ + OB_PROP_DEPTH_AUTO_EXPOSURE_BOOL = 2016, + + /** + * @brief Depth camera exposure adjustment (infrared cameras will be set synchronously under some models of devices) + */ + OB_PROP_DEPTH_EXPOSURE_INT = 2017, + + /** + * @brief Depth camera gain adjustment (infrared cameras will be set synchronously under some models of devices) + */ + OB_PROP_DEPTH_GAIN_INT = 2018, + + /** + * @brief Infrared camera auto exposure (depth camera will be set synchronously under some models of devices) + */ + OB_PROP_IR_AUTO_EXPOSURE_BOOL = 2025, + + /** + * @brief Infrared camera exposure adjustment (some models of devices will set the depth camera synchronously) + */ + OB_PROP_IR_EXPOSURE_INT = 2026, + + /** + * @brief Infrared camera gain adjustment (the depth camera will be set synchronously under some models of devices) + */ + OB_PROP_IR_GAIN_INT = 2027, + + /** + * @brief Select Infrared camera data source channel. If not support throw exception. 0 : IR stream from IR Left sensor; 1 : IR stream from IR Right sensor; + */ + OB_PROP_IR_CHANNEL_DATA_SOURCE_INT = 2028, + + /** + * @brief Depth effect dedistortion, true: on, false: off. mutually exclusive with D2C function, RM_Filter disable When hardware or software D2C is enabled. + */ + OB_PROP_DEPTH_RM_FILTER_BOOL = 2029, + + /** + * @brief Color camera maximal gain + */ + OB_PROP_COLOR_MAXIMAL_GAIN_INT = 2030, + + /** + * @brief Color camera shutter gain + */ + OB_PROP_COLOR_MAXIMAL_SHUTTER_INT = 2031, + + /** + * @brief The enable/disable switch for IR short exposure function, supported only by a few devices. + */ + OB_PROP_IR_SHORT_EXPOSURE_BOOL = 2032, + + /** + * @brief Color camera HDR + */ + OB_PROP_COLOR_HDR_BOOL = 2034, + + /** + * @brief IR long exposure mode switch read and write. + */ + OB_PROP_IR_LONG_EXPOSURE_BOOL = 2035, + + /** + * @brief Setting and getting the USB device frame skipping mode status, true: frame skipping mode, false: non-frame skipping mode. + */ + OB_PROP_SKIP_FRAME_BOOL = 2036, + + /** + * @brief Depth HDR merge, true: on, false: off. + */ + OB_PROP_HDR_MERGE_BOOL = 2037, + + /** + * @brief Color camera FOCUS + */ + OB_PROP_COLOR_FOCUS_INT = 2038, + /** + * @brief ir rectify status,true: ir rectify, false: no rectify + */ + OB_PROP_IR_RECTIFY_BOOL = 2040, + + /** + * @brief Depth camera priority + * + */ + OB_PROP_DEPTH_AUTO_EXPOSURE_PRIORITY_INT = 2052, + + /** + * @brief Software disparity to depth + */ + OB_PROP_SDK_DISPARITY_TO_DEPTH_BOOL = 3004, + + /** + * @brief Depth data unpacking function switch (each open stream will be turned on by default, support RLE/Y10/Y11/Y12/Y14 format) + */ + OB_PROP_SDK_DEPTH_FRAME_UNPACK_BOOL = 3007, + + /** + * @brief IR data unpacking function switch (each current will be turned on by default, support RLE/Y10/Y11/Y12/Y14 format) + */ + OB_PROP_SDK_IR_FRAME_UNPACK_BOOL = 3008, + + /** + * @brief Accel data conversion function switch (on by default) + */ + OB_PROP_SDK_ACCEL_FRAME_TRANSFORMED_BOOL = 3009, + + /** + * @brief Gyro data conversion function switch (on by default) + */ + OB_PROP_SDK_GYRO_FRAME_TRANSFORMED_BOOL = 3010, + + /** + * @brief Left IR frame data unpacking function switch (each current will be turned on by default, support RLE/Y10/Y11/Y12/Y14 format) + */ + OB_PROP_SDK_IR_LEFT_FRAME_UNPACK_BOOL = 3011, + + /** + * @brief Right IR frame data unpacking function switch (each current will be turned on by default, support RLE/Y10/Y11/Y12/Y14 format) + */ + OB_PROP_SDK_IR_RIGHT_FRAME_UNPACK_BOOL = 3012, + + /** + * @brief Read the current network bandwidth type of the network device, whether it is Gigabit Ethernet or Fast Ethernet, such as G335LE. + */ + OB_PROP_NETWORK_BANDWIDTH_TYPE_INT = 3027, + + /** + * @brief Switch device performance mode, currently available in Adaptive Mode and High Performance Mode, such as G335LE. + */ + OB_PROP_DEVICE_PERFORMANCE_MODE_INT = 3028, + + /** + * @brief Calibration JSON file read from device (Femto Mega, read only) + */ + OB_RAW_DATA_CAMERA_CALIB_JSON_FILE = 4029, + + /** + * @brief Confidence degree + */ + OB_PROP_DEBUG_ESGM_CONFIDENCE_FLOAT = 5013, +} OBPropertyID, + ob_property_id; + +// For backward compatibility +#define OB_PROP_TIMER_RESET_TRIGGLE_OUT_ENABLE_BOOL OB_PROP_TIMER_RESET_TRIGGER_OUT_ENABLE_BOOL +#define OB_PROP_LASER_ON_OFF_MODE_INT OB_PROP_LASER_ON_OFF_PATTERN_INT +#define OB_PROP_LASER_ENERGY_LEVEL_INT OB_PROP_LASER_POWER_LEVEL_CONTROL_INT +#define OB_PROP_LASER_HW_ENERGY_LEVEL_INT OB_PROP_LASER_POWER_ACTUAL_LEVEL_INT +#define OB_PROP_DEVICE_USB3_REPEAT_IDENTIFY_BOOL OB_PROP_DEVICE_USB2_REPEAT_IDENTIFY_BOOL +#define OB_PROP_DEPTH_SOFT_FILTER_BOOL OB_PROP_DEPTH_NOISE_REMOVAL_FILTER_BOOL +#define OB_PROP_DEPTH_MAX_DIFF_INT OB_PROP_DEPTH_NOISE_REMOVAL_FILTER_MAX_DIFF_INT +#define OB_PROP_DEPTH_MAX_SPECKLE_SIZE_INT OB_PROP_DEPTH_NOISE_REMOVAL_FILTER_MAX_SPECKLE_SIZE_INT + +/** + * @brief The data type used to describe all property settings + */ +typedef enum OBPropertyType { + OB_BOOL_PROPERTY = 0, /**< Boolean property */ + OB_INT_PROPERTY = 1, /**< Integer property */ + OB_FLOAT_PROPERTY = 2, /**< Floating-point property */ + OB_STRUCT_PROPERTY = 3, /**< Struct property */ +} OBPropertyType, + ob_property_type; + +/** + * @brief Used to describe the characteristics of each property + */ +typedef struct OBPropertyItem { + OBPropertyID id; /**< Property ID */ + const char *name; /**< Property name */ + OBPropertyType type; /**< Property type */ + OBPermissionType permission; /**< Property read and write permission */ +} OBPropertyItem, ob_property_item; + +#ifdef __cplusplus +} +#endif diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/RecordPlayback.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/RecordPlayback.h new file mode 100644 index 0000000..7b93ff3 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/RecordPlayback.h @@ -0,0 +1,135 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file RecordPlayback.hpp + * @brief Record and playback device-related types, including interfaces to create recording and playback devices, + record and playback streaming data, etc. + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "Device.h" + +/** + * @brief Create a recording device for the specified device with a specified file path and compression enabled. + * + * @param[in] device The device to record. + * @param[in] file_path The file path to record to. + * @param[in] compression_enabled Whether to enable compression for the recording. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return A pointer to the newly created recording device, or NULL if an error occurred. + */ +OB_EXPORT ob_record_device *ob_create_record_device(ob_device *device, const char *file_path, bool compression_enabled, ob_error **error); + +/** + * @brief Delete a recording device. + * + * @param[in] recorder The recording device to delete. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_delete_record_device(ob_record_device *recorder, ob_error **error); + +/** + * @brief Pause recording on the specified recording device. + * + * @param[in] recorder The recording device to pause. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_record_device_pause(ob_record_device *recorder, ob_error **error); + +/** + * @brief Resume recording on the specified recording device. + * + * @param[in] recorder The recording device to resume. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_record_device_resume(ob_record_device *recorder, ob_error **error); + +/** + * @brief Create a playback device for the specified file path. + * + * @param[in] file_path The file path to playback from. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return A pointer to the newly created playback device, or NULL if an error occurred. + */ +OB_EXPORT ob_device *ob_create_playback_device(const char *file_path, ob_error **error); + +/** + * @brief Pause playback on the specified playback device. + * + * @param[in] player The playback device to pause. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_playback_device_pause(ob_device *player, ob_error **error); + +/** + * @brief Resume playback on the specified playback device. + * + * @param[in] player The playback device to resume. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_playback_device_resume(ob_device *player, ob_error **error); + +/** + * @brief Set the playback to a specified time point of the played data. + * + * @param[in] player The playback device to set the position for. + * @param[in] timestamp The position to set the playback to, in milliseconds. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_playback_device_seek(ob_device *player, const uint64_t timestamp, ob_error **error); + +/** + * @brief Set the playback to a specified time point of the played data. + * + * @param[in] player The playback device to set the position for. + * @param[in] rate The playback rate to set. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_playback_device_set_playback_rate(ob_device *player, const float rate, ob_error **error); + +/** + * @brief Get the current playback status of the played data. + * + * @param[in] player The playback device to get the status for. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The current playback status of the played data. + */ +OB_EXPORT ob_playback_status ob_playback_device_get_current_playback_status(ob_device *player, ob_error **error); + +/** + * @brief Set a callback function to receive playback status updates. + * + * @param[in] player The playback device to set the callback for. + * @param[in] callback The callback function to receive playback status updates. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_playback_device_set_playback_status_changed_callback(ob_device *player, ob_playback_status_changed_callback callback, void *user_data, + ob_error **error); + +/** + * @brief Get the current playback position of the played data. + * + * @param[in] player The playback device to get the position for. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The current playback position of the played data, in milliseconds. + */ +OB_EXPORT uint64_t ob_playback_device_get_position(ob_device *player, ob_error **error); + +/** + * @brief Get the duration of the played data. + * + * @param[in] player The playback device to get the duration for. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The duration of the played data, in milliseconds. + */ +OB_EXPORT uint64_t ob_playback_device_get_duration(ob_device *player, ob_error **error); + +#ifdef __cplusplus +} // extern "C" +#endif \ No newline at end of file diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Sensor.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Sensor.h new file mode 100644 index 0000000..b758779 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Sensor.h @@ -0,0 +1,132 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Sensor.h + * @brief Defines types related to sensors, used for obtaining stream configurations, opening and closing streams, and setting and getting sensor properties. + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ObTypes.h" + +/** + * @brief Get the type of the sensor. + * + * @param[in] sensor The sensor object. + * @param[out] error Logs error messages. + * @return The sensor type. + */ +OB_EXPORT ob_sensor_type ob_sensor_get_type(const ob_sensor *sensor, ob_error **error); + +/** + * @brief Get a list of all supported stream profiles. + * + * @param[in] sensor The sensor object. + * @param[out] error Logs error messages. + * @return A list of stream profiles. + */ +OB_EXPORT ob_stream_profile_list *ob_sensor_get_stream_profile_list(const ob_sensor *sensor, ob_error **error); + +/** + * @brief Open the current sensor and set the callback data frame. + * + * @param[in] sensor The sensor object. + * @param[in] profile The stream configuration information. + * @param[in] callback The callback function triggered when frame data arrives. + * @param[in] user_data Any user data to pass in and get from the callback. + * @param[out] error Logs error messages. + */ +OB_EXPORT void ob_sensor_start(ob_sensor *sensor, const ob_stream_profile *profile, ob_frame_callback callback, void *user_data, ob_error **error); + +/** + * @brief Stop the sensor stream. + * + * @param[in] sensor The sensor object. + * @param[out] error Logs error messages. + */ +OB_EXPORT void ob_sensor_stop(ob_sensor *sensor, ob_error **error); + +/** + * @brief Switch resolutions. + * + * @param[in] sensor The sensor object. + * @param[in] profile The stream configuration information. + * @param[out] error Logs error messages. + */ +OB_EXPORT void ob_sensor_switch_profile(ob_sensor *sensor, ob_stream_profile *profile, ob_error **error); + +/** + * @brief Delete a sensor object. + * + * @param[in] sensor The sensor object to delete. + * @param[out] error Logs error messages. + */ +OB_EXPORT void ob_delete_sensor(ob_sensor *sensor, ob_error **error); + +/** + * @brief Create a list of recommended filters for the specified sensor. + * + * @param[in] sensor The ob_sensor object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return ob_filter_list + */ +OB_EXPORT ob_filter_list *ob_sensor_create_recommended_filter_list(const ob_sensor *sensor, ob_error **error); + +/** + * @brief Get the number of sensors in the sensor list. + * + * @param[in] sensor_list The list of sensor objects. + * @param[out] error Logs error messages. + * @return The number of sensors in the list. + */ +OB_EXPORT uint32_t ob_sensor_list_get_count(const ob_sensor_list *sensor_list, ob_error **error); + +/** + * @brief Get the sensor type. + * + * @param[in] sensor_list The list of sensor objects. + * @param[in] index The index of the sensor on the list. + * @param[out] error Logs error messages. + * @return The sensor type. + */ +OB_EXPORT ob_sensor_type ob_sensor_list_get_sensor_type(const ob_sensor_list *sensor_list, uint32_t index, ob_error **error); + +/** + * @brief Get a sensor by sensor type. + * + * @param[in] sensor_list The list of sensor objects. + * @param[in] sensorType The sensor type to be obtained. + * @param[out] error Logs error messages. + * @return The sensor pointer. If the specified type of sensor does not exist, it will return null. + */ +OB_EXPORT ob_sensor *ob_sensor_list_get_sensor_by_type(const ob_sensor_list *sensor_list, ob_sensor_type sensorType, ob_error **error); + +/** + * @brief Get a sensor by index number. + * + * @param[in] sensor_list The list of sensor objects. + * @param[in] index The index of the sensor on the list. + * @param[out] error Logs error messages. + * @return The sensor object. + */ +OB_EXPORT ob_sensor *ob_sensor_list_get_sensor(const ob_sensor_list *sensor_list, uint32_t index, ob_error **error); + +/** + * @brief Delete a list of sensor objects. + * + * @param[in] sensor_list The list of sensor objects to delete. + * @param[out] error Logs error messages. + */ +OB_EXPORT void ob_delete_sensor_list(ob_sensor_list *sensor_list, ob_error **error); + +#define ob_sensor_list_get_sensor_count ob_sensor_list_get_count +#define ob_sensor_get_recommended_filter_list ob_sensor_create_recommended_filter_list + +#ifdef __cplusplus +} +#endif diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/StreamProfile.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/StreamProfile.h new file mode 100644 index 0000000..98e5ad1 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/StreamProfile.h @@ -0,0 +1,417 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file StreamProfile.h + * @brief The stream profile related type is used to get information such as the width, height, frame rate, and format of the stream. + * + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ObTypes.h" + +/** + * @brief Create a stream profile object + * + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_stream_profile* return the stream profile object + */ +OB_EXPORT ob_stream_profile *ob_create_stream_profile(ob_stream_type type, ob_format format, ob_error **error); + +/** + * @brief Create a video stream profile object + * + * @param[in] type Stream type + * @param[in] format Stream format + * @param[in] width Stream width + * @param[in] height Stream height + * @param[in] fps Stream frame rate + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_stream_profile* return the video stream profile object + */ +OB_EXPORT ob_stream_profile *ob_create_video_stream_profile(ob_stream_type type, ob_format format, uint32_t width, uint32_t height, uint32_t fps, + ob_error **error); + +/** + * @brief Create a accel stream profile object + * + * @param[in] full_scale_range Accel full scale range + * @param[in] sample_rate Accel sample rate + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_stream_profile* return the accel stream profile object + */ +OB_EXPORT ob_stream_profile *ob_create_accel_stream_profile(ob_accel_full_scale_range full_scale_range, ob_accel_sample_rate sample_rate, ob_error **error); + +/** + * @brief Create a gyro stream profile object + * + * @param[in] full_scale_range Gyro full scale range + * @param[in] sample_rate Gyro sample rate + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_stream_profile* return the accel stream profile object + */ +OB_EXPORT ob_stream_profile *ob_create_gyro_stream_profile(ob_gyro_full_scale_range full_scale_range, ob_gyro_sample_rate sample_rate, ob_error **error); + +/** + * @brief Copy the stream profile object from an other stream profile object + * + * @param[in] srcProfile Source stream profile object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return ob_stream_profile* return the new stream profile object + */ +OB_EXPORT ob_stream_profile *ob_create_stream_profile_from_other_stream_profile(const ob_stream_profile *srcProfile, ob_error **error); + +/** + * @brief Copy the stream profile object with a new format object + * + * @param[in] profile Stream profile object + * @param[in] new_format New format + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return ob_stream_profile* return the new stream profile object with the new format + */ +OB_EXPORT ob_stream_profile *ob_create_stream_profile_with_new_format(const ob_stream_profile *profile, ob_format new_format, ob_error **error); + +/** + * @brief Delete the stream configuration. + * + * @param[in] profile Stream profile object . + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_delete_stream_profile(const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Get stream profile format + * + * @param[in] profile Stream profile object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_format return the format of the stream + */ +OB_EXPORT ob_format ob_stream_profile_get_format(const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Set stream profile format + * + * @param[in] profile Stream profile object + * @param[in] format The format of the stream + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_stream_profile_set_format(ob_stream_profile *profile, ob_format format, ob_error **error); + +/** + * @brief Get stream profile type + * + * @param[in] profile Stream profile object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_stream_type stream type + */ +OB_EXPORT ob_stream_type ob_stream_profile_get_type(const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Set stream profile type + * + * @param[in] profile Stream profile object + * @param[in] type The type of the stream + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_stream_profile_set_type(const ob_stream_profile *profile, ob_stream_type type, ob_error **error); + +/** + * @brief Get the extrinsic for source stream to target stream + * + * @param[in] source Source stream profile + * @param[in] target Target stream profile + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_extrinsic The extrinsic + */ +OB_EXPORT ob_extrinsic ob_stream_profile_get_extrinsic_to(const ob_stream_profile *source, ob_stream_profile *target, ob_error **error); + +/** + * @brief Set the extrinsic for source stream to target stream + * + * @param[in] source Stream profile object + * @param[in] target Target stream type + * @param[in] extrinsic The extrinsic + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_stream_profile_set_extrinsic_to(ob_stream_profile *source, const ob_stream_profile *target, ob_extrinsic extrinsic, ob_error **error); + +/** + * @brief Set the extrinsic for source stream to target stream type + * + * @param[in] source Source stream profile + * @param[in] type Target stream type + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_extrinsic The extrinsic + */ +OB_EXPORT void ob_stream_profile_set_extrinsic_to_type(ob_stream_profile *source, const ob_stream_type type, ob_extrinsic extrinsic, ob_error **error); + +/** + * @brief Get the frame rate of the video stream + * + * @param[in] profile Stream profile object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint32_t return the frame rate of the stream + */ +OB_EXPORT uint32_t ob_video_stream_profile_get_fps(const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Get the width of the video stream + * + * @param[in] profile Stream profile object , If the profile is not a video stream configuration, an error will be returned + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint32_t return the width of the stream + */ +OB_EXPORT uint32_t ob_video_stream_profile_get_width(const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Set the width of the video stream + * + * @param[in] profile Stream profile object , If the profile is not a video stream configuration, an error will be returned + * @param[in] width The width of the stream + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_video_stream_profile_set_width(ob_stream_profile *profile, uint32_t width, ob_error **error); + +/** + * @brief Get the height of the video stream + * + * @param[in] profile Stream profile object , If the profile is not a video stream configuration, an error will be returned + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return uint32_t return the height of the stream + */ +OB_EXPORT uint32_t ob_video_stream_profile_get_height(const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Set the height of the video stream + * + * @param[in] profile Stream profile object , If the profile is not a video stream configuration, an error will be returned + * @param[in] height The height of the stream + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_video_stream_profile_set_height(ob_stream_profile *profile, uint32_t height, ob_error **error); + +/** + * @brief Get the intrinsic of the video stream profile + * + * @param[in] profile Stream profile object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_camera_intrinsic Return the intrinsic of the stream + */ +OB_EXPORT ob_camera_intrinsic ob_video_stream_profile_get_intrinsic(const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Set the intrinsic of the video stream profile + * + * @param[in] profile Stream profile object + * @param[in] intrinsic The intrinsic of the stream + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_video_stream_profile_set_intrinsic(ob_stream_profile *profile, ob_camera_intrinsic intrinsic, ob_error **error); + +/** + * @brief Get the distortion of the video stream profile + * + * @param[in] profile Stream profile object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_camera_distortion Return the distortion of the stream + */ +OB_EXPORT ob_camera_distortion ob_video_stream_profile_get_distortion(const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Set the distortion of the video stream profile + * + * @param[in] profile Stream profile object + * @param[in] distortion The distortion of the stream + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_video_stream_profile_set_distortion(ob_stream_profile *profile, ob_camera_distortion distortion, ob_error **error); + +/** + * @brief Get the process param of the disparity stream + * + * @param[in] profile Stream profile object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_disparity_param Return the disparity process param of the stream + */ +OB_EXPORT ob_disparity_param ob_disparity_based_stream_profile_get_disparity_param(const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Set the disparity process param of the disparity stream. + * + * @param[in] profile Stream profile object. If the profile is not for the disparity stream, an error will be returned. + * @param[in] param The disparity process param of the disparity stream. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_disparity_based_stream_profile_set_disparity_param(ob_stream_profile *profile, ob_disparity_param param, ob_error **error); + +/** + * @brief Get the full-scale range of the accelerometer stream. + * + * @param[in] profile Stream profile object. If the profile is not for the accelerometer stream, an error will be returned. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The full-scale range of the accelerometer stream. + */ +OB_EXPORT ob_accel_full_scale_range ob_accel_stream_profile_get_full_scale_range(const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Get the sampling frequency of the accelerometer frame. + * + * @param[in] profile Stream profile object. If the profile is not for the accelerometer stream, an error will be returned. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The sampling frequency of the accelerometer frame. + */ +OB_EXPORT ob_accel_sample_rate ob_accel_stream_profile_get_sample_rate(const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Get the intrinsic of the accelerometer stream. + * + * @param[in] profile Stream profile object. If the profile is not for the accelerometer stream, an error will be returned. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_accel_intrinsic Return the intrinsic of the accelerometer stream. + */ +OB_EXPORT ob_accel_intrinsic ob_accel_stream_profile_get_intrinsic(const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Set the intrinsic of the accelerometer stream. + * + * @param[in] profile Stream profile object. If the profile is not for the accelerometer stream, an error will be returned. + * @param[in] intrinsic The intrinsic of the accelerometer stream. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_accel_stream_profile_set_intrinsic(ob_stream_profile *profile, ob_accel_intrinsic intrinsic, ob_error **error); + +/** + * @brief Get the full-scale range of the gyroscope stream. + * + * @param[in] profile Stream profile object. If the profile is not for the gyroscope stream, an error will be returned. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The full-scale range of the gyroscope stream. + */ +OB_EXPORT ob_gyro_full_scale_range ob_gyro_stream_profile_get_full_scale_range(const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Get the sampling frequency of the gyroscope stream. + * + * @param[in] profile Stream profile object. If the profile is not for the gyroscope stream, an error will be returned. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The sampling frequency of the gyroscope stream. + */ +OB_EXPORT ob_gyro_sample_rate ob_gyro_stream_profile_get_sample_rate(const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Get the intrinsic of the gyroscope stream. + * + * @param[in] profile Stream profile object. If the profile is not for the gyroscope stream, an error will be returned. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_gyro_intrinsic Return the intrinsic of the gyroscope stream. + */ +OB_EXPORT ob_gyro_intrinsic ob_gyro_stream_get_intrinsic(const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Set the intrinsic of the gyroscope stream. + * + * @param[in] profile Stream profile object. If the profile is not for the gyroscope stream, an error will be returned. + * @param[in] intrinsic The intrinsic of the gyroscope stream. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_gyro_stream_set_intrinsic(ob_stream_profile *profile, ob_gyro_intrinsic intrinsic, ob_error **error); + +/** + * @brief Get the number of StreamProfile lists. + * + * @param[in] profile_list StreamProfile list. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The number of StreamProfile lists. + */ +OB_EXPORT uint32_t ob_stream_profile_list_get_count(const ob_stream_profile_list *profile_list, ob_error **error); + +/** + * @brief Get the corresponding StreamProfile by subscripting. + * + * @attention The stream profile returned by this function should be deleted by calling @ref ob_delete_stream_profile() when it is no longer needed. + * + * @param[in] profile_list StreamProfile lists. + * @param[in] index Index. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The matching profile. + */ +OB_EXPORT ob_stream_profile *ob_stream_profile_list_get_profile(const ob_stream_profile_list *profile_list, int index, ob_error **error); + +/** + * @brief Match the corresponding ob_stream_profile through the passed parameters. If there are multiple matches, + * the first one in the list will be returned by default. If no matched profile is found, an error will be returned. + * + * @attention The stream profile returned by this function should be deleted by calling @ref ob_delete_stream_profile() when it is no longer needed. + * + * @param[in] profile_list Resolution list. + * @param[in] width Width. If you don't need to add matching conditions, you can pass OB_WIDTH_ANY. + * @param[in] height Height. If you don't need to add matching conditions, you can pass OB_HEIGHT_ANY. + * @param[in] format Format. If you don't need to add matching conditions, you can pass OB_FORMAT_ANY. + * @param[in] fps Frame rate. If you don't need to add matching conditions, you can pass OB_FPS_ANY. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The matching profile. + */ +OB_EXPORT ob_stream_profile *ob_stream_profile_list_get_video_stream_profile(const ob_stream_profile_list *profile_list, int width, int height, + ob_format format, int fps, ob_error **error); + +/** + * @brief Match the corresponding ob_stream_profile through the passed parameters. If there are multiple matches, + * the first one in the list will be returned by default. If no matched profile is found, an error will be returned. + * + * @attention The stream profile returned by this function should be deleted by calling @ref ob_delete_stream_profile() when it is no longer needed. + * + * @param[in] profile_list Resolution list. + * @param[in] full_scale_range Full-scale range. If you don't need to add matching conditions, you can pass 0. + * @param[in] sample_rate Sample rate. If you don't need to add matching conditions, you can pass 0. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The matching profile. + */ +OB_EXPORT ob_stream_profile *ob_stream_profile_list_get_accel_stream_profile(const ob_stream_profile_list *profile_list, + ob_accel_full_scale_range full_scale_range, ob_accel_sample_rate sample_rate, + ob_error **error); + +/** + * @brief Match the corresponding ob_stream_profile through the passed parameters. If there are multiple matches, + * the first one in the list will be returned by default. If no matched profile is found, an error will be returned. + * + * @attention The stream profile returned by this function should be deleted by calling @ref ob_delete_stream_profile() when it is no longer needed. + * + * @param[in] profile_list Resolution list. + * @param[in] full_scale_range Full-scale range. If you don't need to add matching conditions, you can pass 0. + * @param[in] sample_rate Sample rate. If you don't need to add matching conditions, you can pass 0. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The matching profile. + */ +OB_EXPORT ob_stream_profile *ob_stream_profile_list_get_gyro_stream_profile(const ob_stream_profile_list *profile_list, + ob_gyro_full_scale_range full_scale_range, ob_gyro_sample_rate sample_rate, + ob_error **error); + +/** + * @brief Delete the stream profile list. + * + * @param[in] profile_list Stream configuration list. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_delete_stream_profile_list(const ob_stream_profile_list *profile_list, ob_error **error); + +// The following interfaces are deprecated and are retained here for compatibility purposes. +#define ob_stream_profile_format ob_stream_profile_get_format +#define ob_stream_profile_type ob_stream_profile_get_type +#define ob_video_stream_profile_fps ob_video_stream_profile_get_fps +#define ob_video_stream_profile_width ob_video_stream_profile_get_width +#define ob_video_stream_profile_height ob_video_stream_profile_get_height +#define ob_accel_stream_profile_full_scale_range ob_accel_stream_profile_get_full_scale_range +#define ob_accel_stream_profile_sample_rate ob_accel_stream_profile_get_sample_rate +#define ob_gyro_stream_profile_full_scale_range ob_gyro_stream_profile_get_full_scale_range +#define ob_gyro_stream_profile_sample_rate ob_gyro_stream_profile_get_sample_rate +#define ob_stream_profile_list_count ob_stream_profile_list_get_count + +#ifdef __cplusplus +} +#endif diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/TypeHelper.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/TypeHelper.h new file mode 100644 index 0000000..c71328f --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/TypeHelper.h @@ -0,0 +1,93 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ObTypes.h" + +/** + * @brief Convert OBFormat to " char* " type and then return. + * + * @param[in] type OBFormat type. + * @return OBFormat of "char*" type. + */ +OB_EXPORT const char* ob_format_type_to_string(OBFormat type); + +/** + * @brief Convert OBFrameType to " char* " type and then return. + * + * @param[in] type OBFrameType type. + * @return OBFrameType of "char*" type. + */ +OB_EXPORT const char* ob_frame_type_to_string(OBFrameType type); + +/** + * @brief Convert OBStreamType to " char* " type and then return. + * + * @param[in] type OBStreamType type. + * @return OBStreamType of "char*" type. + */ +OB_EXPORT const char* ob_stream_type_to_string(OBStreamType type); + +/** + * @brief Convert OBSensorType to " char* " type and then return. + * + * @param[in] type OBSensorType type. + * @return OBSensorType of "char*" type. + */ +OB_EXPORT const char* ob_sensor_type_to_string(OBSensorType type); + +/** + * @brief Convert OBIMUSampleRate to " char* " type and then return. + * + * @param[in] type OBIMUSampleRate type. + * @return OBIMUSampleRate of "char*" type. + */ +OB_EXPORT const char* ob_imu_rate_type_to_string(OBIMUSampleRate type); + +/** + * @brief Convert OBGyroFullScaleRange to " char* " type and then return. + * + * @param[in] type OBGyroFullScaleRange type. + * @return OBGyroFullScaleRange of "char*" type. + */ +OB_EXPORT const char* ob_gyro_range_type_to_string(OBGyroFullScaleRange type); + +/** + * @brief Convert OBAccelFullScaleRange to " char* " type and then return. + * + * @param[in] type OBAccelFullScaleRange type. + * @return OBAccelFullScaleRange of "char*" type. + */ +OB_EXPORT const char* ob_accel_range_type_to_string(OBAccelFullScaleRange type); + +/** + * @brief Convert OBFrameMetadataType to " char* " type and then return. + * + * @param[in] type OBFrameMetadataType type. + * @return OBFrameMetadataType of "char*" type. + */ +OB_EXPORT const char* ob_meta_data_type_to_string(OBFrameMetadataType type); + +/** + * @brief Convert OBStreamType to OBSensorType. + * + * @param[in] type The sensor type to convert. + * @return OBStreamType The corresponding stream type. + */ +OB_EXPORT OBStreamType ob_sensor_type_to_stream_type(OBSensorType type); + +/** + * @brief Convert OBFormat to " char* " type and then return. + * + * @param format The OBFormat to convert. + * @return The string. + */ +OB_EXPORT const char *ob_format_to_string(OBFormat format); +#ifdef __cplusplus +} +#endif diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Utils.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Utils.h new file mode 100644 index 0000000..90f3945 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Utils.h @@ -0,0 +1,124 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ObTypes.h" + +/** + * @brief Transform a 3d point of a source coordinate system into a 3d point of the target coordinate system. + * + * @param[in] source_point3f Source 3d point value + * @param[in] extrinsic Transformation matrix from source to target + * @param[out] target_point3f Target 3d point value + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return bool Transform result + */ +OB_EXPORT bool ob_transformation_3d_to_3d(const OBPoint3f source_point3f, OBExtrinsic extrinsic, OBPoint3f *target_point3f, ob_error **error); + +/** + * @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into a 3d point of the target coordinate system. + * + * @param[in] source_point2f Source 2d point value + * @param[in] source_depth_pixel_value The depth of sourcePoint2f in millimeters + * @param[in] source_intrinsic Source intrinsic parameters + * @param[in] extrinsic Transformation matrix from source to target + * @param[out] target_point3f Target 3d point value + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return bool Transform result + */ +OB_EXPORT bool ob_transformation_2d_to_3d(const OBPoint2f source_point2f, const float source_depth_pixel_value, const OBCameraIntrinsic source_intrinsic, + OBExtrinsic extrinsic, OBPoint3f *target_point3f, ob_error **error); + +/** + * @brief Transform a 3d point of a source coordinate system into a 2d pixel coordinate of the target camera. + * + * @param[in] source_point3f Source 3d point value + * @param[in] target_intrinsic Target intrinsic parameters + * @param[in] target_distortion Target distortion parameters + * @param[in] extrinsic Transformation matrix from source to target + * @param[out] target_point2f Target 2d point value + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return bool Transform result + */ +OB_EXPORT bool ob_transformation_3d_to_2d(const OBPoint3f source_point3f, const OBCameraIntrinsic target_intrinsic, const OBCameraDistortion target_distortion, + OBExtrinsic extrinsic, OBPoint2f *target_point2f, ob_error **error); + +/** + * @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into a 2d pixel coordinate of the target camera + * + * @param[in] source_intrinsic Source intrinsic parameters + * @param[in] source_distortion Source distortion parameters + * @param[in] source_point2f Source 2d point value + * @param[in] source_depth_pixel_value The depth of sourcePoint2f in millimeters + * @param[in] target_intrinsic Target intrinsic parameters + * @param[in] target_distortion Target distortion parameters + * @param[in] extrinsic Transformation matrix from source to target + * @param[out] target_point2f Target 2d point value + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return bool Transform result + */ +OB_EXPORT bool ob_transformation_2d_to_2d(const OBPoint2f source_point2f, const float source_depth_pixel_value, const OBCameraIntrinsic source_intrinsic, + const OBCameraDistortion source_distortion, const OBCameraIntrinsic target_intrinsic, + const OBCameraDistortion target_distortion, OBExtrinsic extrinsic, OBPoint2f *target_point2f, ob_error **error); + +// \deprecated This function is deprecated and will be removed in a future version. +OB_EXPORT ob_frame *transformation_depth_frame_to_color_camera(ob_device *device, ob_frame *depth_frame, uint32_t target_color_camera_width, + uint32_t target_color_camera_height, ob_error **error); + +// \deprecated This function is deprecated and will be removed in a future version. +OB_EXPORT bool transformation_init_xy_tables(const ob_calibration_param calibration_param, const ob_sensor_type sensor_type, float *data, uint32_t *data_size, + ob_xy_tables *xy_tables, ob_error **error); + +// \deprecated This function is deprecated and will be removed in a future version. +OB_EXPORT void transformation_depth_to_pointcloud(ob_xy_tables *xy_tables, const void *depth_image_data, void *pointcloud_data, ob_error **error); + +// \deprecated This function is deprecated and will be removed in a future version. +OB_EXPORT void transformation_depth_to_rgbd_pointcloud(ob_xy_tables *xy_tables, const void *depth_image_data, const void *color_image_data, + void *pointcloud_data, ob_error **error); + +// \deprecated This function is deprecated and will be removed in a future version. +// Use the ob_transformation_3d_to_3d instead. +OB_EXPORT bool ob_calibration_3d_to_3d(const ob_calibration_param calibration_param, const ob_point3f source_point3f, const ob_sensor_type source_sensor_type, + const ob_sensor_type target_sensor_type, ob_point3f *target_point3f, ob_error **error); + +// \deprecated This function is deprecated and will be removed in a future version. +// Use the ob_transformation_2d_to_3d instead. +OB_EXPORT bool ob_calibration_2d_to_3d(const ob_calibration_param calibration_param, const ob_point2f source_point2f, const float source_depth_pixel_value, + const ob_sensor_type source_sensor_type, const ob_sensor_type target_sensor_type, ob_point3f *target_point3f, + ob_error **error); + +// \deprecated This function is deprecated and will be removed in a future version. +// Use the ob_transformation_3d_to_2d instead. +OB_EXPORT bool ob_calibration_3d_to_2d(const ob_calibration_param calibration_param, const ob_point3f source_point3f, const ob_sensor_type source_sensor_type, + const ob_sensor_type target_sensor_type, ob_point2f *target_point2f, ob_error **error); + +// \deprecated This function is deprecated and will be removed in a future version. +// Use the ob_transformation_2d_to_2d instead. +OB_EXPORT bool ob_calibration_2d_to_2d(const ob_calibration_param calibration_param, const ob_point2f source_point2f, const float source_depth_pixel_value, + const ob_sensor_type source_sensor_type, const ob_sensor_type target_sensor_type, ob_point2f *target_point2f, + ob_error **error); +/** + * @brief save point cloud to ply file. + * + * @param[in] file_name Point cloud save path + * @param[in] frame Point cloud frame + * @param[in] save_binary Binary or textual,true: binary, false: textual + * @param[in] use_mesh Save mesh or not, true: save as mesh, false: not save as mesh + * @param[in] mesh_threshold Distance threshold for creating faces in point cloud,default value :50 + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return bool save point cloud result + */ +OB_EXPORT bool ob_save_pointcloud_to_ply(const char *file_name, ob_frame *frame, bool save_binary, bool use_mesh, float mesh_threshold, ob_error **error); +#ifdef __cplusplus +} +#endif diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Version.h b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Version.h new file mode 100644 index 0000000..b117a2f --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/h/Version.h @@ -0,0 +1,55 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Version.h + * @brief Functions for retrieving the SDK version number information. + * + */ +#pragma once + +#include "Export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get the SDK version number. + * + * @return int The SDK version number. + */ +OB_EXPORT int ob_get_version(); + +/** + * @brief Get the SDK major version number. + * + * @return int The SDK major version number. + */ +OB_EXPORT int ob_get_major_version(); + +/** + * @brief Get the SDK minor version number. + * + * @return int The SDK minor version number. + */ +OB_EXPORT int ob_get_minor_version(); + +/** + * @brief Get the SDK patch version number. + * + * @return int The SDK patch version number. + */ +OB_EXPORT int ob_get_patch_version(); + +/** + * @brief Get the SDK stage version. + * @attention The returned char* does not need to be freed. + * + * @return const char* The SDK stage version. + */ +OB_EXPORT const char *ob_get_stage_version(); + +#ifdef __cplusplus +} +#endif diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Context.hpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Context.hpp new file mode 100644 index 0000000..259b520 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Context.hpp @@ -0,0 +1,251 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Context.hpp + * @brief The SDK context class, which serves as the entry point to the underlying SDK. It is used to query device lists, handle device callbacks, and set the + * log level. + * + */ +#pragma once + +#include "libobsensor/h/Context.h" +#include "Types.hpp" +#include "Error.hpp" + +#include +#include + +namespace ob { + +// forward declarations +class Device; +class DeviceInfo; +class DeviceList; + +class Context { +public: + /** + * @brief Type definition for the device changed callback function. + * + * @param removedList The list of removed devices. + * @param addedList The list of added devices. + */ + typedef std::function removedList, std::shared_ptr addedList)> DeviceChangedCallback; + + /** + * @brief Type definition for the log output callback function. + * + * @param severity The current callback log level. + * @param logMsg The log message. + */ + typedef std::function LogCallback; + +private: + ob_context *impl_ = nullptr; + DeviceChangedCallback deviceChangedCallback_; + // static LogCallback logCallback_; + +public: + /** + * @brief Context constructor. + * @brief The Context class is a management class that describes the runtime of the SDK. It is responsible for applying and releasing resources for the SDK. + * The context has the ability to manage multiple devices, enumerate devices, monitor device callbacks, and enable functions such as multi-device + * synchronization. + * + * @param[in] configPath The path to the configuration file. If the path is empty, the default configuration will be used. + */ + explicit Context(const char *configPath = "") { + ob_error *error = nullptr; + impl_ = ob_create_context_with_config(configPath, &error); + Error::handle(&error); + } + + /** + * @brief Context destructor. + */ + ~Context() noexcept { + ob_error *error = nullptr; + ob_delete_context(impl_, &error); + Error::handle(&error, false); + } + + /** + * @brief Queries the enumerated device list. + * + * @return std::shared_ptr A pointer to the device list class. + */ + std::shared_ptr queryDeviceList() const { + ob_error *error = nullptr; + auto list = ob_query_device_list(impl_, &error); + Error::handle(&error); + return std::make_shared(list); + } + + /** + * @brief enable or disable net device enumeration. + * @brief after enable, the net device will be discovered automatically and can be retrieved by @ref queryDeviceList. The default state can be set in the + * configuration file. + * + * @attention Net device enumeration by gvcp protocol, if the device is not in the same subnet as the host, it will be discovered but cannot be connected. + * + * @param[in] enable true to enable, false to disable + */ + void enableNetDeviceEnumeration(bool enable) const { + ob_error *error = nullptr; + ob_enable_net_device_enumeration(impl_, enable, &error); + Error::handle(&error); + } + + /** + * @brief Creates a network device with the specified IP address and port. + * + * @param[in] address The IP address, ipv4 only. such as "192.168.1.10" + * @param[in] port The port number, currently only support 8090 + * @return std::shared_ptr The created device object. + */ + std::shared_ptr createNetDevice(const char *address, uint16_t port) const { + ob_error *error = nullptr; + auto device = ob_create_net_device(impl_, address, port, &error); + Error::handle(&error); + return std::make_shared(device); + } + + /** + * @brief Set the device plug-in callback function. + * @attention This function supports multiple callbacks. Each call to this function adds a new callback to an internal list. + * + * @param callback The function triggered when the device is plugged and unplugged. + */ + void setDeviceChangedCallback(DeviceChangedCallback callback) { + deviceChangedCallback_ = callback; + ob_error *error = nullptr; + ob_set_device_changed_callback(impl_, &Context::deviceChangedCallback, this, &error); + Error::handle(&error); + } + + /** + * @brief Activates device clock synchronization to synchronize the clock of the host and all created devices (if supported). + * + * @param repeatIntervalMsec The interval for auto-repeated synchronization, in milliseconds. If the value is 0, synchronization is performed only once. + */ + void enableDeviceClockSync(uint64_t repeatIntervalMsec) const { + ob_error *error = nullptr; + ob_enable_device_clock_sync(impl_, repeatIntervalMsec, &error); + Error::handle(&error); + } + + /** + * @brief Frees idle memory from the internal frame memory pool. + * @brief The SDK includes an internal frame memory pool that caches memory allocated for frames received from devices. + */ + void freeIdleMemory() const { + ob_error *error = nullptr; + ob_free_idle_memory(impl_, &error); + Error::handle(&error); + } + + /** + * @brief For linux, there are two ways to enable the UVC backend: libuvc and v4l2. This function is used to set the backend type. + * @brief It is effective when the new device is created. + * + * @attention This interface is only available for Linux. + * + * @param[in] type The backend type to be used. + */ + void setUvcBackendType(OBUvcBackendType type) const { + ob_error *error = nullptr; + ob_set_uvc_backend_type(impl_, type, &error); + Error::handle(&error); + } + + /** + * @brief Set the level of the global log, which affects both the log level output to the console, output to the file and output the user defined + * callback. + * + * @param severity The log output level. + */ + static void setLoggerSeverity(OBLogSeverity severity) { + ob_error *error = nullptr; + ob_set_logger_severity(severity, &error); + Error::handle(&error); + } + + /** + * @brief Set log output to a file. + * + * @param severity The log level output to the file. + * @param directory The log file output path. If the path is empty, the existing settings will continue to be used (if the existing configuration is also + * empty, the log will not be output to the file). + */ + static void setLoggerToFile(OBLogSeverity severity, const char *directory) { + ob_error *error = nullptr; + ob_set_logger_to_file(severity, directory, &error); + Error::handle(&error); + } + + /** + * @brief Set log output to the console. + * + * @param severity The log level output to the console. + */ + static void setLoggerToConsole(OBLogSeverity severity) { + ob_error *error = nullptr; + ob_set_logger_to_console(severity, &error); + Error::handle(&error); + } + + /** + * @brief Set the logger to callback. + * + * @param severity The callback log level. + * @param callback The callback function. + */ + static void setLoggerToCallback(OBLogSeverity severity, LogCallback callback) { + ob_error *error = nullptr; + Context::getLogCallback() = callback; + ob_set_logger_to_callback(severity, &Context::logCallback, &Context::getLogCallback(), &error); + Error::handle(&error); + } + + /** + * @brief Set the extensions directory + * @brief The extensions directory is used to search for dynamic libraries that provide additional functionality to the SDK, such as the Frame filters. + * + * @attention Should be called before creating the context and pipeline, otherwise the default extensions directory (./extensions) will be used. + * + * @param directory Path to the extensions directory. If the path is empty, the existing settings will continue to be used (if the existing + */ + static void setExtensionsDirectory(const char *directory) { + ob_error *error = nullptr; + ob_set_extensions_directory(directory, &error); + Error::handle(&error); + } + +private: + static void deviceChangedCallback(ob_device_list *removedList, ob_device_list *addedList, void *userData) { + auto ctx = static_cast(userData); + if(ctx && ctx->deviceChangedCallback_) { + auto removed = std::make_shared(removedList); + auto added = std::make_shared(addedList); + ctx->deviceChangedCallback_(removed, added); + } + } + + static void logCallback(OBLogSeverity severity, const char *logMsg, void *userData) { + auto cb = static_cast(userData); + if(cb) { + (*cb)(severity, logMsg); + } + } + + // Lazy initialization of the logcallback_. The purpose is to initialize logcallback_ in .hpp + static LogCallback &getLogCallback() { + static LogCallback logCallback_ = nullptr; + return logCallback_; + } + +// for backward compatibility +#define enableMultiDeviceSync enableDeviceClockSync +}; +} // namespace ob diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Device.hpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Device.hpp new file mode 100644 index 0000000..d3aa463 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Device.hpp @@ -0,0 +1,1505 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Device.hpp + * @brief Device related types, including operations such as getting and creating a device, setting and obtaining device attributes, and obtaining sensors + * + */ +#pragma once +#include "Types.hpp" + +#include "libobsensor/h/Property.h" +#include "libobsensor/h/Device.h" +#include "libobsensor/h/Advanced.h" +#include "libobsensor/hpp/Filter.hpp" +#include "libobsensor/hpp/Sensor.hpp" + +#include "Error.hpp" +#include +#include +#include +#include +#include + +namespace ob { + +class DeviceInfo; +class SensorList; +class DevicePresetList; +class OBDepthWorkModeList; +class CameraParamList; +class DeviceFrameInterleaveList; + +class Device { +public: + /** + * @brief Callback function for device firmware update progress + * + * @param state The device firmware update status. + * @param message Status information. + * @param percent The percentage of the update progress. + */ + typedef std::function DeviceFwUpdateCallback; + + /** + * @brief Callback function for device status updates. + * + * @param state The device status. + * @param message Status information. + */ + typedef std::function DeviceStateChangedCallback; + +protected: + ob_device *impl_ = nullptr; + DeviceStateChangedCallback deviceStateChangeCallback_; + DeviceFwUpdateCallback fwUpdateCallback_; + +public: + /** + * @brief Describe the entity of the RGBD camera, representing a specific model of RGBD camera + */ + explicit Device(ob_device_t *impl) : impl_(impl) {} + + Device(Device &&other) noexcept : impl_(other.impl_) { + other.impl_ = nullptr; + } + + Device &operator=(Device &&other) noexcept { + if(this != &other) { + ob_error *error = nullptr; + ob_delete_device(impl_, &error); + Error::handle(&error); + impl_ = other.impl_; + other.impl_ = nullptr; + } + return *this; + } + + Device(const Device &) = delete; + Device &operator=(const Device &) = delete; + + virtual ~Device() noexcept { + ob_error *error = nullptr; + ob_delete_device(impl_, &error); + Error::handle(&error, false); + } + + ob_device_t *getImpl() const { + return impl_; + } + + /** + * @brief Get device information + * + * @return std::shared_ptr return device information + */ + std::shared_ptr getDeviceInfo() const { + ob_error *error = nullptr; + auto info = ob_device_get_device_info(impl_, &error); + Error::handle(&error); + return std::make_shared(info); + } + + /** + * @brief Check if the extension information is exist + * + * @param infoKey The key of the extension information + * @return bool Whether the extension information exists + */ + bool isExtensionInfoExist(const std::string &infoKey) const { + ob_error *error = nullptr; + auto exist = ob_device_is_extension_info_exist(impl_, infoKey.c_str(), &error); + Error::handle(&error); + return exist; + } + + /** + * @brief Get information about extensions obtained from SDK supported by the device + * + * @param infoKey The key of the extension information + * @return const char* Returns extended information about the device + */ + const char *getExtensionInfo(const std::string &infoKey) const { + ob_error *error = nullptr; + const char *info = ob_device_get_extension_info(impl_, infoKey.c_str(), &error); + Error::handle(&error); + return info; + } + + /** + * @brief Get device sensor list + * + * @return std::shared_ptr return the sensor list + */ + std::shared_ptr getSensorList() const { + ob_error *error = nullptr; + auto list = ob_device_get_sensor_list(impl_, &error); + Error::handle(&error); + return std::make_shared(list); + } + + /** + * @brief Get specific type of sensor + * if device not open, SDK will automatically open the connected device and return to the instance + * + * @return std::shared_ptr return the sensor example, if the device does not have the device,return nullptr + */ + std::shared_ptr getSensor(OBSensorType type) const { + ob_error *error = nullptr; + auto sensor = ob_device_get_sensor(impl_, type, &error); + Error::handle(&error); + return std::make_shared(sensor); + } + + /** + * @brief Set int type of device property + * + * @param propertyId Property id + * @param value Property value to be set + */ + void setIntProperty(OBPropertyID propertyId, int32_t value) const { + ob_error *error = nullptr; + ob_device_set_int_property(impl_, propertyId, value, &error); + Error::handle(&error); + } + + /** + * @brief Set float type of device property + * + * @param propertyId Property id + * @param value Property value to be set + */ + void setFloatProperty(OBPropertyID propertyId, float value) const { + ob_error *error = nullptr; + ob_device_set_float_property(impl_, propertyId, value, &error); + Error::handle(&error); + } + + /** + * @brief Set bool type of device property + * + * @param propertyId Property id + * @param value Property value to be set + */ + void setBoolProperty(OBPropertyID propertyId, bool value) const { + ob_error *error = nullptr; + ob_device_set_bool_property(impl_, propertyId, value, &error); + Error::handle(&error); + } + + /** + * @brief Get int type of device property + * + * @param propertyId Property id + * @return int32_t Property to get + */ + int32_t getIntProperty(OBPropertyID propertyId) const { + ob_error *error = nullptr; + auto value = ob_device_get_int_property(impl_, propertyId, &error); + Error::handle(&error); + return value; + } + + /** + * @brief Get float type of device property + * + * @param propertyId Property id + * @return float Property to get + */ + float getFloatProperty(OBPropertyID propertyId) const { + ob_error *error = nullptr; + auto value = ob_device_get_float_property(impl_, propertyId, &error); + Error::handle(&error); + return value; + } + + /** + * @brief Get bool type of device property + * + * @param propertyId Property id + * @return bool Property to get + */ + bool getBoolProperty(OBPropertyID propertyId) const { + ob_error *error = nullptr; + auto value = ob_device_get_bool_property(impl_, propertyId, &error); + Error::handle(&error); + return value; + } + + /** + * @brief Get int type device property range (including current value and default value) + * + * @param propertyId Property id + * @return OBIntPropertyRange Property range + */ + OBIntPropertyRange getIntPropertyRange(OBPropertyID propertyId) const { + ob_error *error = nullptr; + auto range = ob_device_get_int_property_range(impl_, propertyId, &error); + Error::handle(&error); + return range; + } + + /** + * @brief Get float type device property range((including current value and default value) + * + * @param propertyId Property id + * @return OBFloatPropertyRange Property range + */ + OBFloatPropertyRange getFloatPropertyRange(OBPropertyID propertyId) const { + ob_error *error = nullptr; + auto range = ob_device_get_float_property_range(impl_, propertyId, &error); + Error::handle(&error); + return range; + } + + /** + * @brief Get bool type device property range (including current value and default value) + * + * @param propertyId The ID of the property + * @return OBBoolPropertyRange The range of the property + */ + OBBoolPropertyRange getBoolPropertyRange(OBPropertyID propertyId) const { + ob_error *error = nullptr; + auto range = ob_device_get_bool_property_range(impl_, propertyId, &error); + Error::handle(&error); + return range; + } + + /** + * @brief Set the structured data type of a device property + * + * @param propertyId The ID of the property + * @param data The data to set + * @param dataSize The size of the data to set + */ + void setStructuredData(OBPropertyID propertyId, const uint8_t *data, uint32_t dataSize) const { + ob_error *error = nullptr; + ob_device_set_structured_data(impl_, propertyId, data, dataSize, &error); + Error::handle(&error); + } + + /** + * @brief Get the structured data type of a device property + * + * @param propertyId The ID of the property + * @param data The property data obtained + * @param dataSize The size of the data obtained + */ + void getStructuredData(OBPropertyID propertyId, uint8_t *data, uint32_t *dataSize) const { + ob_error *error = nullptr; + ob_device_get_structured_data(impl_, propertyId, data, dataSize, &error); + Error::handle(&error); + } + + /** + * @brief Set the customer data type of a device property + * + * @param data The data to set + * @param dataSize The size of the data to set,the maximum length cannot exceed 65532 bytes. + */ + void writeCustomerData(const void *data, uint32_t dataSize) { + ob_error *error = nullptr; + ob_device_write_customer_data(impl_, data, dataSize, &error); + Error::handle(&error); + } + + /** + * @brief Get the customer data type of a device property + * + * @param data The property data obtained + * @param dataSize The size of the data obtained + */ + void readCustomerData(void *data, uint32_t *dataSize) { + ob_error *error = nullptr; + ob_device_read_customer_data(impl_, data, dataSize, &error); + Error::handle(&error); + } + + /** + * @brief Get the number of properties supported by the device + * + * @return The number of supported properties + */ + int getSupportedPropertyCount() const { + ob_error *error = nullptr; + auto count = ob_device_get_supported_property_count(impl_, &error); + Error::handle(&error); + return count; + } + + /** + * @brief Get the supported properties of the device + * + * @param index The index of the property + * @return The type of supported property + */ + OBPropertyItem getSupportedProperty(uint32_t index) const { + ob_error *error = nullptr; + auto item = ob_device_get_supported_property_item(impl_, index, &error); + Error::handle(&error); + return item; + } + + /** + * @brief Check if a property permission is supported + * + * @param propertyId The ID of the property + * @param permission The read and write permissions to check + * @return Whether the property permission is supported + */ + bool isPropertySupported(OBPropertyID propertyId, OBPermissionType permission) const { + ob_error *error = nullptr; + auto result = ob_device_is_property_supported(impl_, propertyId, permission, &error); + Error::handle(&error); + return result; + } + + /** + * @brief Check if the global timestamp is supported for the device + * + * @return Whether the global timestamp is supported + */ + bool isGlobalTimestampSupported() const { + ob_error *error = nullptr; + auto result = ob_device_is_global_timestamp_supported(impl_, &error); + Error::handle(&error); + return result; + } + + /** + * @brief Enable or disable the global timestamp + * + * @param enable Whether to enable the global timestamp + */ + void enableGlobalTimestamp(bool enable) { + ob_error *error = nullptr; + ob_device_enable_global_timestamp(impl_, enable, &error); + Error::handle(&error); + } + + /** + * @brief Update the device firmware + * + * @param filePath Firmware path + * @param callback Firmware Update progress and status callback + * @param async Whether to execute asynchronously + */ + void updateFirmware(const char *filePath, DeviceFwUpdateCallback callback, bool async = true) { + ob_error *error = nullptr; + fwUpdateCallback_ = callback; + ob_device_update_firmware(impl_, filePath, &Device::firmwareUpdateCallback, async, this, &error); + Error::handle(&error); + } + + /** + * @brief Update the device firmware from data + * + * @param firmwareData Firmware data + * @param firmwareDataSize Firmware data size + * @param callback Firmware Update progress and status callback + * @param async Whether to execute asynchronously + */ + void updateFirmwareFromData(const uint8_t *firmwareData, uint32_t firmwareDataSize, DeviceFwUpdateCallback callback, bool async = true) { + ob_error *error = nullptr; + fwUpdateCallback_ = callback; + ob_device_update_firmware_from_data(impl_, firmwareData, firmwareDataSize, &Device::firmwareUpdateCallback, async, this, &error); + Error::handle(&error); + } + + /** + * @brief Update the device optional depth presets + * + * @param filePathList A list(2D array) of preset file paths, each up to OB_PATH_MAX characters. + * @param pathCount The number of the preset file paths. + * @param callback Preset update progress and status callback + */ + void updateOptionalDepthPresets(const char filePathList[][OB_PATH_MAX], uint8_t pathCount, DeviceFwUpdateCallback callback) { + ob_error *error = nullptr; + fwUpdateCallback_ = callback; + ob_device_update_optional_depth_presets(impl_, filePathList, pathCount, &Device::firmwareUpdateCallback, this, &error); + Error::handle(&error); + } + + /** + * @brief Set the device state changed callbacks + * + * @param callback The callback function that is triggered when the device status changes (for example, the frame rate is automatically reduced or the + * stream is closed due to high temperature, etc.) + */ + void setDeviceStateChangedCallback(DeviceStateChangedCallback callback) { + ob_error *error = nullptr; + deviceStateChangeCallback_ = callback; + ob_device_set_state_changed_callback(impl_, &Device::deviceStateChangedCallback, this, &error); + Error::handle(&error); + } + + static void deviceStateChangedCallback(OBDeviceState state, const char *message, void *userData) { + auto device = static_cast(userData); + device->deviceStateChangeCallback_(state, message); + } + + /** + * @brief Get current depth work mode + * + * @return ob_depth_work_mode Current depth work mode + */ + OBDepthWorkMode getCurrentDepthWorkMode() const { + ob_error *error = nullptr; + auto mode = ob_device_get_current_depth_work_mode(impl_, &error); + Error::handle(&error); + return mode; + } + + /** + * @brief Get current depth mode name + * @brief According the current preset name to return current depth mode name + * @return const char* return the current depth mode name. + */ + const char *getCurrentDepthModeName() { + ob_error *error = nullptr; + auto name = ob_device_get_current_depth_work_mode_name(impl_, &error); + Error::handle(&error); + return name; + } + + /** + * @brief Switch depth work mode by OBDepthWorkMode. Prefer invoke switchDepthWorkMode(const char *modeName) to switch depth mode + * when known the complete name of depth work mode. + * @param[in] workMode Depth work mode come from ob_depth_work_mode_list which return by ob_device_get_depth_work_mode_list + */ + OBStatus switchDepthWorkMode(const OBDepthWorkMode &workMode) const { + ob_error *error = nullptr; + auto status = ob_device_switch_depth_work_mode(impl_, &workMode, &error); + Error::handle(&error); + return status; + } + + /** + * @brief Switch depth work mode by work mode name. + * + * @param[in] modeName Depth work mode name which equals to OBDepthWorkMode.name + */ + OBStatus switchDepthWorkMode(const char *modeName) const { + ob_error *error = nullptr; + auto status = ob_device_switch_depth_work_mode_by_name(impl_, modeName, &error); + Error::handle(&error); + return status; + } + + /** + * @brief Request support depth work mode list + * @return OBDepthWorkModeList list of ob_depth_work_mode + */ + std::shared_ptr getDepthWorkModeList() const { + ob_error *error = nullptr; + auto list = ob_device_get_depth_work_mode_list(impl_, &error); + Error::handle(&error); + return std::make_shared(list); + } + + /** + * @brief Device restart + * @attention The device will be disconnected and reconnected. After the device is disconnected, the access to the Device object interface may be abnormal. + * Please delete the object directly and obtain it again after the device is reconnected. + */ + void reboot() const { + ob_error *error = nullptr; + ob_device_reboot(impl_, &error); + Error::handle(&error); + } + + /** + * @brief Device restart delay mode + * @attention The device will be disconnected and reconnected. After the device is disconnected, the access to the Device object interface may be abnormal. + * Please delete the object directly and obtain it again after the device is reconnected. + * Support devices: Gemini2 L + * + * @param[in] delayMs Time unit: ms. delayMs == 0: No delay; delayMs > 0, Delay millisecond connect to host device after reboot + */ + void reboot(uint32_t delayMs) const { + setIntProperty(OB_PROP_DEVICE_REBOOT_DELAY_INT, delayMs); + reboot(); + } + + /** + * @brief Enable or disable the device heartbeat. + * @brief After enable the device heartbeat, the sdk will start a thread to send heartbeat signal to the device error every 3 seconds. + * + * @attention If the device does not receive the heartbeat signal for a long time, it will be disconnected and rebooted. + * + * @param[in] enable Whether to enable the device heartbeat. + */ + void enableHeartbeat(bool enable) const { + ob_error *error = nullptr; + ob_device_enable_heartbeat(impl_, enable, &error); + Error::handle(&error); + } + + /** + * @brief Get the supported multi device sync mode bitmap of the device. + * @brief For example, if the return value is 0b00001100, it means the device supports @ref OB_MULTI_DEVICE_SYNC_MODE_PRIMARY and @ref + * OB_MULTI_DEVICE_SYNC_MODE_SECONDARY. User can check the supported mode by the code: + * ```c + * if(supported_mode_bitmap & OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN){ + * //support OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN + * } + * if(supported_mode_bitmap & OB_MULTI_DEVICE_SYNC_MODE_STANDALONE){ + * //support OB_MULTI_DEVICE_SYNC_MODE_STANDALONE + * } + * // and so on + * ``` + * @return uint16_t return the supported multi device sync mode bitmap of the device. + */ + uint16_t getSupportedMultiDeviceSyncModeBitmap() const { + ob_error *error = nullptr; + auto mode = ob_device_get_supported_multi_device_sync_mode_bitmap(impl_, &error); + Error::handle(&error); + return mode; + } + + /** + * @brief set the multi device sync configuration of the device. + * + * @param[in] config The multi device sync configuration. + */ + void setMultiDeviceSyncConfig(const OBMultiDeviceSyncConfig &config) const { + ob_error *error = nullptr; + ob_device_set_multi_device_sync_config(impl_, &config, &error); + Error::handle(&error); + } + + /** + * @brief get the multi device sync configuration of the device. + * + * @return OBMultiDeviceSyncConfig return the multi device sync configuration of the device. + */ + OBMultiDeviceSyncConfig getMultiDeviceSyncConfig() const { + ob_error *error = nullptr; + auto config = ob_device_get_multi_device_sync_config(impl_, &error); + Error::handle(&error); + return config; + } + + /** + * @brief send the capture command to the device. + * @brief The device will start one time image capture after receiving the capture command when it is in the @ref + * OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING + * + * @attention The frequency of the user call this function multiplied by the number of frames per trigger should be less than the frame rate of the stream. + * The number of frames per trigger can be set by @ref framesPerTrigger. + * @attention For some models, receive and execute the capture command will have a certain delay and performance consumption, so the frequency of calling + * this function should not be too high, please refer to the product manual for the specific supported frequency. + * @attention If the device is not in the @ref OB_MULTI_DEVICE_SYNC_MODE_HARDWARE_TRIGGERING mode, device will ignore the capture command. + */ + void triggerCapture() const { + ob_error *error = nullptr; + ob_device_trigger_capture(impl_, &error); + Error::handle(&error); + } + + /** + * @brief set the timestamp reset configuration of the device. + */ + void setTimestampResetConfig(const OBDeviceTimestampResetConfig &config) const { + ob_error *error = nullptr; + ob_device_set_timestamp_reset_config(impl_, &config, &error); + Error::handle(&error); + } + + /** + * @brief get the timestamp reset configuration of the device. + * + * @return OBDeviceTimestampResetConfig return the timestamp reset configuration of the device. + */ + OBDeviceTimestampResetConfig getTimestampResetConfig() const { + ob_error *error = nullptr; + auto config = ob_device_get_timestamp_reset_config(impl_, &error); + Error::handle(&error); + return config; + } + + /** + * @brief send the timestamp reset command to the device. + * @brief The device will reset the timer for calculating the timestamp for output frames to 0 after receiving the timestamp reset command when the + * timestamp reset function is enabled. The timestamp reset function can be enabled by call @ref ob_device_set_timestamp_reset_config. + * @brief Before calling this function, user should call @ref ob_device_set_timestamp_reset_config to disable the timestamp reset function (It is not + * required for some models, but it is still recommended to do so for code compatibility). + * + * @attention If the stream of the device is started, the timestamp of the continuous frames output by the stream will jump once after the timestamp reset. + * @attention Due to the timer of device is not high-accuracy, the timestamp of the continuous frames output by the stream will drift after a long time. + * User can call this function periodically to reset the timer to avoid the timestamp drift, the recommended interval time is 60 minutes. + */ + void timestampReset() const { + ob_error *error = nullptr; + ob_device_timestamp_reset(impl_, &error); + Error::handle(&error); + } + + /** + * @brief Alias for @ref timestampReset since it is more accurate. + */ +#define timerReset timestampReset + + /** + * @brief synchronize the timer of the device with the host. + * @brief After calling this function, the timer of the device will be synchronized with the host. User can call this function to multiple devices to + * synchronize all timers of the devices. + * + * @attention If the stream of the device is started, the timestamp of the continuous frames output by the stream will may jump once after the timer + * sync. + * @attention Due to the timer of device is not high-accuracy, the timestamp of the continuous frames output by the stream will drift after a long time. + * User can call this function periodically to synchronize the timer to avoid the timestamp drift, the recommended interval time is 60 minutes. + * + */ + void timerSyncWithHost() const { + ob_error *error = nullptr; + ob_device_timer_sync_with_host(impl_, &error); + Error::handle(&error); + } + + /** + * @brief Get current preset name + * @brief The preset mean a set of parameters or configurations that can be applied to the device to achieve a specific effect or function. + * @return const char* return the current preset name, it should be one of the preset names returned by @ref getAvailablePresetList. + */ + const char *getCurrentPresetName() const { + ob_error *error = nullptr; + const char *name = ob_device_get_current_preset_name(impl_, &error); + Error::handle(&error); + return name; + } + + /** + * @brief load the preset according to the preset name. + * @attention After loading the preset, the settings in the preset will set to the device immediately. Therefore, it is recommended to re-read the device + * settings to update the user program temporarily. + * @param presetName The preset name to set. The name should be one of the preset names returned by @ref getAvailablePresetList. + */ + void loadPreset(const char *presetName) const { + ob_error *error = nullptr; + ob_device_load_preset(impl_, presetName, &error); + Error::handle(&error); + } + + /** + * @brief Get available preset list + * @brief The available preset list usually defined by the device manufacturer and restores on the device. + * @brief User can load the custom preset by calling @ref loadPresetFromJsonFile to append the available preset list. + * + * @return DevicePresetList return the available preset list. + */ + std::shared_ptr getAvailablePresetList() const { + ob_error *error = nullptr; + auto list = ob_device_get_available_preset_list(impl_, &error); + Error::handle(&error); + return std::make_shared(list); + } + + /** + * @brief Load custom preset from file. + * @brief After loading the custom preset, the settings in the custom preset will set to the device immediately. + * @brief After loading the custom preset, the available preset list will be appended with the custom preset and named as the file name. + * + * @attention The user should ensure that the custom preset file is adapted to the device and the settings in the file are valid. + * @attention It is recommended to re-read the device settings to update the user program temporarily after successfully loading the custom preset. + * + * @param filePath The path of the custom preset file. + */ + void loadPresetFromJsonFile(const char *filePath) const { + ob_error *error = nullptr; + ob_device_load_preset_from_json_file(impl_, filePath, &error); + Error::handle(&error); + } + + /** + * @brief Load custom preset from data. + * @brief After loading the custom preset, the settings in the custom preset will set to the device immediately. + * @brief After loading the custom preset, the available preset list will be appended with the custom preset and named as the @ref presetName. + * + * @attention The user should ensure that the custom preset data is adapted to the device and the settings in the data are valid. + * @attention It is recommended to re-read the device settings to update the user program temporarily after successfully loading the custom preset. + * + * @param data The custom preset data. + * @param size The size of the custom preset data. + */ + void loadPresetFromJsonData(const char *presetName, const uint8_t *data, uint32_t size) { + ob_error *error = nullptr; + ob_device_load_preset_from_json_data(impl_, presetName, data, size, &error); + } + + /** + * @brief Export current device settings as a preset json data. + * @brief After exporting the preset, a new preset named as the @ref presetName will be added to the available preset list. + * + * @attention The memory of the data is allocated by the SDK, and will automatically be released by the SDK. + * @attention The memory of the data will be reused by the SDK on the next call, so the user should copy the data to a new buffer if it needs to be + * preserved. + * + * @param[out] data return the preset json data. + * @param[out] dataSize return the size of the preset json data. + */ + void exportSettingsAsPresetJsonData(const char *presetName, const uint8_t **data, uint32_t *dataSize) { + ob_error *error = nullptr; + ob_device_export_current_settings_as_preset_json_data(impl_, presetName, data, dataSize, &error); + } + + /** + * @brief Export current device settings as a preset json file. + * @brief The exported preset file can be loaded by calling @ref loadPresetFromJsonFile to restore the device setting. + * @brief After exporting the preset, a new preset named as the @ref filePath will be added to the available preset list. + * + * @param filePath The path of the preset file to be exported. + */ + void exportSettingsAsPresetJsonFile(const char *filePath) const { + ob_error *error = nullptr; + ob_device_export_current_settings_as_preset_json_file(impl_, filePath, &error); + Error::handle(&error); + } + + /** + * @brief Get the current device status. + * + * @return OBDeviceState The device state information. + */ + OBDeviceState getDeviceState() { + OBDeviceState state = {}; + ob_error *error = nullptr; + state = ob_device_get_device_state(impl_, &error); + return state; + } + + /** + * @brief Send data to the device and receive data from the device. + * @brief This is a factory and debug function, which can be used to send and receive data from the device. The data format is secret and belongs to the + * device vendor. + * + * @attention The send and receive data buffer are managed by the caller, the receive data buffer should be allocated at 1024 bytes or larger. + * + * @param[in] sendData The data to be sent to the device. + * @param[in] sendDataSize The size of the data to be sent to the device. + * @param[out] receiveData The data received from the device. + * @param[in,out] receiveDataSize The requeseted size of the data received from the device, and the actual size of the data received from the device. + */ + void sendAndReceiveData(const uint8_t *sendData, uint32_t sendDataSize, uint8_t *receiveData, uint32_t *receiveDataSize) const { + ob_error *error = nullptr; + ob_device_send_and_receive_data(impl_, sendData, sendDataSize, receiveData, receiveDataSize, &error); + Error::handle(&error); + } + + /** + * @brief Check if the device supports the frame interleave feature. + * + * @return bool Returns true if the device supports the frame interleave feature. + */ + bool isFrameInterleaveSupported() const { + ob_error *error = nullptr; + bool ret = ob_device_is_frame_interleave_supported(impl_, &error); + Error::handle(&error); + return ret; + } + + /** + * @brief load the frame interleave according to frame interleave name. + * @param frameInterleaveName The frame interleave name to set. The name should be one of the frame interleave names returned by @ref + * getAvailableFrameInterleaveList. + */ + void loadFrameInterleave(const char *frameInterleaveName) const { + ob_error *error = nullptr; + ob_device_load_frame_interleave(impl_, frameInterleaveName, &error); + Error::handle(&error); + } + + /** + * @brief Get available frame interleave list + * + * @return DeviceFrameInterleaveList return the available frame interleave list. + */ + std::shared_ptr getAvailableFrameInterleaveList() const { + ob_error *error = nullptr; + auto list = ob_device_get_available_frame_interleave_list(impl_, &error); + Error::handle(&error); + return std::make_shared(list); + } + +private: + static void firmwareUpdateCallback(ob_fw_update_state state, const char *message, uint8_t percent, void *userData) { + auto device = static_cast(userData); + if(device && device->fwUpdateCallback_) { + device->fwUpdateCallback_(state, message, percent); + } + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + void deviceUpgrade(const char *filePath, DeviceFwUpdateCallback callback, bool async = true) { + updateFirmware(filePath, callback, async); + } + + void deviceUpgradeFromData(const uint8_t *firmwareData, uint32_t firmwareDataSize, DeviceFwUpdateCallback callback, bool async = true) { + updateFirmwareFromData(firmwareData, firmwareDataSize, callback, async); + } + + std::shared_ptr getCalibrationCameraParamList() { + ob_error *error = nullptr; + auto impl = ob_device_get_calibration_camera_param_list(impl_, &error); + Error::handle(&error); + return std::make_shared(impl); + } + + void loadDepthFilterConfig(const char *filePath) { + // In order to compile, some high-version compilers will warn that the function parameters are not used. + (void)filePath; + } +}; + +/** + * @brief A class describing device information, representing the name, id, serial number and other basic information of an RGBD camera. + */ +class DeviceInfo { +private: + ob_device_info_t *impl_ = nullptr; + +public: + explicit DeviceInfo(ob_device_info_t *impl) : impl_(impl) {} + ~DeviceInfo() noexcept { + ob_error *error = nullptr; + ob_delete_device_info(impl_, &error); + Error::handle(&error, false); + } + + /** + * @brief Get device name + * + * @return const char * return the device name + */ + const char *getName() const { + ob_error *error = nullptr; + const char *name = ob_device_info_get_name(impl_, &error); + Error::handle(&error); + return name; + } + + /** + * @brief Get the pid of the device + * + * @return int return the pid of the device + */ + int getPid() const { + ob_error *error = nullptr; + int pid = ob_device_info_get_pid(impl_, &error); + Error::handle(&error); + return pid; + } + + /** + * @brief Get the vid of the device + * + * @return int return the vid of the device + */ + int getVid() const { + ob_error *error = nullptr; + int vid = ob_device_info_get_vid(impl_, &error); + Error::handle(&error); + return vid; + } + + /** + * @brief Get system assigned uid for distinguishing between different devices + * + * @return const char * return the uid of the device + */ + const char *getUid() const { + ob_error *error = nullptr; + const char *uid = ob_device_info_get_uid(impl_, &error); + Error::handle(&error); + return uid; + } + + /** + * @brief Get the serial number of the device + * + * @return const char * return the serial number of the device + */ + const char *getSerialNumber() const { + ob_error *error = nullptr; + const char *sn = ob_device_info_get_serial_number(impl_, &error); + Error::handle(&error); + return sn; + } + + /** + * @brief Get the version number of the firmware + * + * @return const char* return the version number of the firmware + */ + const char *getFirmwareVersion() const { + ob_error *error = nullptr; + const char *version = ob_device_info_get_firmware_version(impl_, &error); + Error::handle(&error); + return version; + } + + /** + * @brief Get the connection type of the device + * + * @return const char* the connection type of the device, currently supports: "USB", "USB1.0", "USB1.1", "USB2.0", "USB2.1", "USB3.0", "USB3.1", + * "USB3.2", "Ethernet" + */ + const char *getConnectionType() const { + ob_error *error = nullptr; + const char *type = ob_device_info_get_connection_type(impl_, &error); + Error::handle(&error); + return type; + } + + /** + * @brief Get the IP address of the device + * + * @attention Only valid for network devices, otherwise it will return "0.0.0.0". + * + * @return const char* the IP address of the device, such as "192.168.1.10" + */ + const char *getIpAddress() const { + ob_error *error = nullptr; + const char *ip = ob_device_info_get_ip_address(impl_, &error); + Error::handle(&error); + return ip; + } + + /** + * @brief Get the version number of the hardware + * + * @return const char* the version number of the hardware + */ + const char *getHardwareVersion() const { + ob_error *error = nullptr; + const char *version = ob_device_info_get_hardware_version(impl_, &error); + Error::handle(&error); + return version; + } + + /** + * @brief Get the minimum version number of the SDK supported by the device + * + * @return const char* the minimum SDK version number supported by the device + */ + const char *getSupportedMinSdkVersion() const { + ob_error *error = nullptr; + const char *version = ob_device_info_get_supported_min_sdk_version(impl_, &error); + Error::handle(&error); + return version; + } + + /** + * @brief Get chip type name + * + * @return const char* the chip type name + */ + const char *getAsicName() const { + ob_error *error = nullptr; + const char *name = ob_device_info_get_asicName(impl_, &error); + Error::handle(&error); + return name; + } + + /** + * @brief Get the device type + * + * @return OBDeviceType the device type + */ + OBDeviceType getDeviceType() const { + ob_error *error = nullptr; + OBDeviceType type = ob_device_info_get_device_type(impl_, &error); + Error::handle(&error); + return type; + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + const char *name() const { + return getName(); + } + + int pid() const { + return getPid(); + } + + int vid() const { + return getVid(); + } + + const char *uid() const { + return getUid(); + } + + const char *serialNumber() const { + return getSerialNumber(); + } + + const char *firmwareVersion() const { + return getFirmwareVersion(); + } + + const char *connectionType() const { + return getConnectionType(); + } + + const char *ipAddress() const { + return getIpAddress(); + } + + const char *hardwareVersion() const { + return getHardwareVersion(); + } + + const char *supportedMinSdkVersion() const { + return getSupportedMinSdkVersion(); + } + + const char *asicName() const { + return getAsicName(); + } + + OBDeviceType deviceType() const { + return getDeviceType(); + } +}; + +/** + * @brief Class representing a list of devices + */ +class DeviceList { +private: + ob_device_list_t *impl_ = nullptr; + +public: + explicit DeviceList(ob_device_list_t *impl) : impl_(impl) {} + ~DeviceList() noexcept { + ob_error *error = nullptr; + ob_delete_device_list(impl_, &error); + Error::handle(&error, false); + } + + /** + * @brief Get the number of devices in the list + * + * @return uint32_t the number of devices in the list + */ + uint32_t getCount() const { + ob_error *error = nullptr; + auto count = ob_device_list_get_count(impl_, &error); + Error::handle(&error); + return count; + } + + /** + * @brief Get the PID of the device at the specified index + * + * @param index the index of the device + * @return int the PID of the device + */ + int getPid(uint32_t index) const { + ob_error *error = nullptr; + auto pid = ob_device_list_get_device_pid(impl_, index, &error); + Error::handle(&error); + return pid; + } + + /** + * @brief Get the VID of the device at the specified index + * + * @param index the index of the device + * @return int the VID of the device + */ + int getVid(uint32_t index) const { + ob_error *error = nullptr; + auto vid = ob_device_list_get_device_vid(impl_, index, &error); + Error::handle(&error); + return vid; + } + + /** + * @brief Get the UID of the device at the specified index + * + * @param index the index of the device + * @return const char* the UID of the device + */ + const char *getUid(uint32_t index) const { + ob_error *error = nullptr; + auto uid = ob_device_list_get_device_uid(impl_, index, &error); + Error::handle(&error); + return uid; + } + + /** + * @brief Get the serial number of the device at the specified index + * + * @param index the index of the device + * @return const char* the serial number of the device + */ + const char *getSerialNumber(uint32_t index) const { + ob_error *error = nullptr; + auto sn = ob_device_list_get_device_serial_number(impl_, index, &error); + Error::handle(&error); + return sn; + } + + /** + * @brief Get the name of the device at the specified index in the device list. + * + * This function retrieves the name of the device at the given index in the device list. + * If an error occurs during the operation, it will be handled by the Error::handle function. + * + * @param index The index of the device in the device list. + * @return const char* The name of the device at the specified index. + */ + const char *getName(uint32_t index) const { + ob_error *error = nullptr; + auto name = ob_device_list_get_device_name(impl_, index, &error); + Error::handle(&error); + return name; + } + + /** + * @brief Get device connection type + * + * @param index device index + * @return const char* returns connection type, currently supports: "USB", "USB1.0", "USB1.1", "USB2.0", "USB2.1", "USB3.0", "USB3.1", "USB3.2", "Ethernet" + */ + const char *getConnectionType(uint32_t index) const { + ob_error *error = nullptr; + auto type = ob_device_list_get_device_connection_type(impl_, index, &error); + Error::handle(&error); + return type; + } + + /** + * @brief get the ip address of the device at the specified index + * + * @attention Only valid for network devices, otherwise it will return "0.0.0.0". + * + * @param index the index of the device + * @return const char* the ip address of the device + */ + const char *getIpAddress(uint32_t index) const { + ob_error *error = nullptr; + auto ip = ob_device_list_get_device_ip_address(impl_, index, &error); + Error::handle(&error); + return ip; + } + + /** + * @brief get the local mac address of the device at the specified index + * + * @attention Only valid for network devices, otherwise it will return "0:0:0:0:0:0". + * + * @param index the index of the device + * @return const char* the local mac address of the device + */ + const char *getLocalMacAddress(uint32_t index) const { + ob_error *error = nullptr; + auto mac = ob_device_list_get_device_local_mac(impl_, index, &error); + Error::handle(&error); + return mac; + } + + /** + * @brief Get the device object at the specified index + * + * @attention If the device has already been acquired and created elsewhere, repeated acquisition will throw an exception + * + * @param index the index of the device to create + * @return std::shared_ptr the device object + */ + std::shared_ptr getDevice(uint32_t index) const { + ob_error *error = nullptr; + auto device = ob_device_list_get_device(impl_, index, &error); + Error::handle(&error); + return std::make_shared(device); + } + + /** + * @brief Get the device object with the specified serial number + * + * @attention If the device has already been acquired and created elsewhere, repeated acquisition will throw an exception + * + * @param serialNumber the serial number of the device to create + * @return std::shared_ptr the device object + */ + std::shared_ptr getDeviceBySN(const char *serialNumber) const { + ob_error *error = nullptr; + auto device = ob_device_list_get_device_by_serial_number(impl_, serialNumber, &error); + Error::handle(&error); + return std::make_shared(device); + } + + /** + * @brief Get the specified device object from the device list by uid + * @brief On Linux platform, for usb device, the uid of the device is composed of bus-port-dev, for example 1-1.2-1. But the SDK will remove the dev number + * and only keep the bus-port as the uid to create the device, for example 1-1.2, so that we can create a device connected to the specified USB port. + * Similarly, users can also directly pass in bus-port as uid to create device. + * @brief For GMSL device, the uid is GMSL port with "gmsl2-" prefix, for example gmsl2-1. + * + * @attention If the device has been acquired and created elsewhere, repeated acquisition will throw an exception + * + * @param uid The uid of the device to be created + * @return std::shared_ptr returns the device object + */ + std::shared_ptr getDeviceByUid(const char *uid) const { + ob_error *error = nullptr; + auto device = ob_device_list_get_device_by_uid(impl_, uid, &error); + Error::handle(&error); + return std::make_shared(device); + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + uint32_t deviceCount() const { + return getCount(); + } + + int pid(uint32_t index) const { + return getPid(index); + } + + int vid(uint32_t index) const { + return getVid(index); + } + + const char *uid(uint32_t index) const { + return getUid(index); + } + + const char *serialNumber(uint32_t index) const { + return getSerialNumber(index); + } + + const char *name(uint32_t index) const { + return getName(index); + } + + const char *connectionType(uint32_t index) const { + return getConnectionType(index); + } + + const char *ipAddress(uint32_t index) const { + return getIpAddress(index); + } +}; + +class OBDepthWorkModeList { +private: + ob_depth_work_mode_list_t *impl_ = nullptr; + +public: + explicit OBDepthWorkModeList(ob_depth_work_mode_list_t *impl) : impl_(impl) {} + ~OBDepthWorkModeList() { + ob_error *error = nullptr; + ob_delete_depth_work_mode_list(impl_, &error); + Error::handle(&error, false); + } + + /** + * @brief Get the number of OBDepthWorkMode objects in the list + * + * @return uint32_t the number of OBDepthWorkMode objects in the list + */ + uint32_t getCount() { + ob_error *error = nullptr; + auto count = ob_depth_work_mode_list_get_count(impl_, &error); + Error::handle(&error); + return count; + } + + /** + * @brief Get the OBDepthWorkMode object at the specified index + * + * @param index the index of the target OBDepthWorkMode object + * @return OBDepthWorkMode the OBDepthWorkMode object at the specified index + */ + OBDepthWorkMode getOBDepthWorkMode(uint32_t index) { + ob_error *error = nullptr; + auto mode = ob_depth_work_mode_list_get_item(impl_, index, &error); + Error::handle(&error); + return mode; + } + + /** + * @brief Get the OBDepthWorkMode object at the specified index + * + * @param index the index of the target OBDepthWorkMode object + * @return OBDepthWorkMode the OBDepthWorkMode object at the specified index + */ + OBDepthWorkMode operator[](uint32_t index) { + return getOBDepthWorkMode(index); + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + uint32_t count() { + return getCount(); + } +}; + +/** + * @brief Class representing a list of device presets + * @brief A device preset is a set of parameters or configurations that can be applied to the device to achieve a specific effect or function. + */ +class DevicePresetList { +private: + ob_device_preset_list_t *impl_ = nullptr; + +public: + explicit DevicePresetList(ob_device_preset_list_t *impl) : impl_(impl) {} + ~DevicePresetList() noexcept { + ob_error *error = nullptr; + ob_delete_preset_list(impl_, &error); + Error::handle(&error, false); + } + + /** + * @brief Get the number of device presets in the list + * + * @return uint32_t the number of device presets in the list + */ + uint32_t getCount() { + ob_error *error = nullptr; + auto count = ob_device_preset_list_get_count(impl_, &error); + Error::handle(&error); + return count; + } + + /** + * @brief Get the name of the device preset at the specified index + * + * @param index the index of the device preset + * @return const char* the name of the device preset + */ + const char *getName(uint32_t index) { + ob_error *error = nullptr; + const char *name = ob_device_preset_list_get_name(impl_, index, &error); + Error::handle(&error); + return name; + } + + /** + * @brief check if the preset list contains the special name preset. + * @param name The name of the preset + * @return bool Returns true if the special name is found in the preset list, otherwise returns false. + */ + bool hasPreset(const char *name) { + ob_error *error = nullptr; + auto result = ob_device_preset_list_has_preset(impl_, name, &error); + Error::handle(&error); + return result; + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + uint32_t count() { + return getCount(); + } +}; + +/** + * @brief Class representing a list of camera parameters + */ +class CameraParamList { +private: + ob_camera_param_list_t *impl_ = nullptr; + +public: + explicit CameraParamList(ob_camera_param_list_t *impl) : impl_(impl) {} + ~CameraParamList() noexcept { + ob_error *error = nullptr; + ob_delete_camera_param_list(impl_, &error); + Error::handle(&error, false); + } + + /** + * @brief Get the number of camera parameters in the list. + * + * @return uint32_t the number of camera parameters in the list. + */ + uint32_t getCount() { + ob_error *error = nullptr; + auto count = ob_camera_param_list_get_count(impl_, &error); + Error::handle(&error); + return count; + } + + /** + * @brief Get the camera parameters for the specified index + * + * @param index the index of the parameter group + * @return OBCameraParam the corresponding group parameters + */ + OBCameraParam getCameraParam(uint32_t index) { + ob_error *error = nullptr; + auto param = ob_camera_param_list_get_param(impl_, index, &error); + Error::handle(&error); + return param; + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + uint32_t count() { + return getCount(); + } +}; + +/** + * @brief Class representing a list of device Frame Interleave + */ +class DeviceFrameInterleaveList { +private: + ob_device_frame_interleave_list_t *impl_ = nullptr; + +public: + explicit DeviceFrameInterleaveList(ob_device_frame_interleave_list_t *impl) : impl_(impl) {} + ~DeviceFrameInterleaveList() noexcept { + ob_error *error = nullptr; + ob_delete_frame_interleave_list(impl_, &error); + Error::handle(&error, false); + } + + /** + * @brief Get the number of device frame interleave in the list + * + * @return uint32_t the number of device frame interleave in the list + */ + uint32_t getCount() { + ob_error *error = nullptr; + auto count = ob_device_frame_interleave_list_get_count(impl_, &error); + Error::handle(&error); + return count; + } + + /** + * @brief Get the name of the device frame interleave at the specified index + * + * @param index the index of the device frame interleave + * @return const char* the name of the device frame interleave + */ + const char *getName(uint32_t index) { + ob_error *error = nullptr; + const char *name = ob_device_frame_interleave_list_get_name(impl_, index, &error); + Error::handle(&error); + return name; + } + + /** + * @brief check if the frame interleave list contains the special name frame interleave. + * @param name The name of the frame interleave + * @return bool Returns true if the special name is found in the frame interleave list, otherwise returns false. + */ + bool hasFrameInterleave(const char *name) { + ob_error *error = nullptr; + auto result = ob_device_frame_interleave_list_has_frame_interleave(impl_, name, &error); + Error::handle(&error); + return result; + } +}; + +} // namespace ob diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Error.hpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Error.hpp new file mode 100644 index 0000000..d0c099a --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Error.hpp @@ -0,0 +1,116 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Error.hpp + * @brief This file defines the Error class, which describes abnormal errors within the SDK. + * Detailed information about the exception can be obtained through this class. + */ +#pragma once + +#include "Types.hpp" +#include "libobsensor/h/Error.h" +#include + +namespace ob { +class Error : public std::exception { +private: + ob_error *impl_; + + /** + * @brief Construct a new Error object + * + * @attention This constructor should not be called directly, use the handle() function instead. + * + * @param error The ob_error object + */ + explicit Error(ob_error *error) : impl_(error) {}; + + Error& operator=(const Error&) = default; + +public: + /** + * @brief A static function to handle the ob_error and throw an exception if needed. + * + * @param error The ob_error pointer to be handled. + * @param throw_exception A boolean value to indicate whether to throw an exception or not, the default value is true. + */ + static void handle(ob_error **error, bool throw_exception = true) { + if(!error || !*error) { // no error + return; + } + + if(throw_exception) { + throw Error(*error); + } + else { + ob_delete_error(*error); + *error = nullptr; + } + } + + /** + * @brief Destroy the Error object + */ + ~Error() override { + if(impl_) { + ob_delete_error(impl_); + impl_ = nullptr; + } + } + + /** + * @brief Returns the error message of the exception. + * + * @return const char* The error message. + */ + const char *what() const noexcept override { + return impl_->message; + } + + /** + * @brief Returns the exception type of the exception. + * @brief Read the comments of the OBExceptionType enum in the libobsensor/h/ObTypes.h file for more information. + * + * @return OBExceptionType The exception type. + */ + OBExceptionType getExceptionType() const noexcept { + return impl_->exception_type; + } + + /** + * @brief Returns the name of the function where the exception occurred. + * + * @return const char* The function name. + */ + const char *getFunction() const noexcept { + return impl_->function; + } + + /** + * @brief Returns the arguments of the function where the exception occurred. + * + * @return const char* The arguments. + */ + const char *getArgs() const noexcept { + return impl_->args; + } + + /** + * @brief Returns the error message of the exception. + * @brief It is recommended to use the what() function instead. + * + * @return const char* The error message. + */ + const char *getMessage() const noexcept { + return impl_->message; + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + const char *getName() const noexcept { + return impl_->function; + } +}; +} // namespace ob + diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Filter.hpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Filter.hpp new file mode 100644 index 0000000..c6d7f70 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Filter.hpp @@ -0,0 +1,1037 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Filter.hpp + * @brief This file contains the Filter class, which is the processing unit of the SDK that can perform point cloud generation, format conversion, and other + * functions. + */ +#pragma once + +#include "Types.hpp" +#include "Error.hpp" +#include "Frame.hpp" +#include "libobsensor/h/Filter.h" +#include "libobsensor/h/Frame.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace ob { + +/** + * @brief A callback function that takes a shared pointer to a Frame object as its argument. + */ +typedef std::function)> FilterCallback; + +/** + * @brief Get the type of a PropertyRange member + */ +template struct RangeTraits { + using valueType = void; +}; + +template <> struct RangeTraits { + using valueType = uint8_t; +}; + +template <> struct RangeTraits { + using valueType = uint16_t; +}; + +template <> struct RangeTraits { + using valueType = uint32_t; +}; + +template <> struct RangeTraits { + using valueType = float; +}; + +/** + * @brief Get T Property Range + */ +template T getPropertyRange(const OBFilterConfigSchemaItem &item, const double cur) { + // If T type is illegal, T will be void + using valueType = typename RangeTraits::valueType; + T range{}; + // Compilate error will be reported here if T is void + range.cur = static_cast(cur); + range.def = static_cast(item.def); + range.max = static_cast(item.max); + range.min = static_cast(item.min); + range.step = static_cast(item.step); + return range; +} + +/** + * @brief The Filter class is the base class for all filters in the SDK. + */ +class Filter : public std::enable_shared_from_this { +protected: + ob_filter *impl_ = nullptr; + std::string name_; + FilterCallback callback_; + std::vector configSchemaVec_; + +protected: + /** + * @brief Default constructor with nullptr impl, used for derived classes only. + */ + Filter() = default; + + virtual void init(ob_filter *impl) { + impl_ = impl; + ob_error *error = nullptr; + name_ = ob_filter_get_name(impl_, &error); + Error::handle(&error); + + auto configSchemaList = ob_filter_get_config_schema_list(impl_, &error); + Error::handle(&error); + + auto count = ob_filter_config_schema_list_get_count(configSchemaList, &error); + Error::handle(&error); + + for(uint32_t i = 0; i < count; i++) { + auto item = ob_filter_config_schema_list_get_item(configSchemaList, i, &error); + Error::handle(&error); + configSchemaVec_.emplace_back(item); + } + + ob_delete_filter_config_schema_list(configSchemaList, &error); + Error::handle(&error); + } + +public: + explicit Filter(ob_filter *impl) { + init(impl); + } + + virtual ~Filter() noexcept { + if(impl_ != nullptr) { + ob_error *error = nullptr; + ob_delete_filter(impl_, &error); + Error::handle(&error, false); + } + } + + /** + * @brief Get the Impl object of the filter. + * + * @return ob_filter* The Impl object of the filter. + */ + ob_filter *getImpl() const { + return impl_; + } + + /** + * @brief Get the type of filter. + * + * @return string The type of filte. + */ + virtual const std::string &getName() const { + return name_; + } + + /** + * @brief Reset the filter, freeing the internal cache, stopping the processing thread, and clearing the pending buffer frame when asynchronous processing + * is used. + */ + virtual void reset() const { + ob_error *error = nullptr; + ob_filter_reset(impl_, &error); + Error::handle(&error); + } + + /** + * @brief enable the filter + */ + virtual void enable(bool enable) const { + ob_error *error = nullptr; + ob_filter_enable(impl_, enable, &error); + Error::handle(&error); + } + + /** + * @brief Return Enable State + */ + virtual bool isEnabled() const { + ob_error *error = nullptr; + bool enable = ob_filter_is_enabled(impl_, &error); + Error::handle(&error); + return enable; + } + + /** + * @brief Processes a frame synchronously. + * + * @param frame The frame to be processed. + * @return std::shared_ptr< Frame > The processed frame. + */ + virtual std::shared_ptr process(std::shared_ptr frame) const { + ob_error *error = nullptr; + auto result = ob_filter_process(impl_, frame->getImpl(), &error); + Error::handle(&error); + if(!result) { + return nullptr; + } + return std::make_shared(result); + } + + /** + * @brief Pushes the pending frame into the cache for asynchronous processing. + * + * @param frame The pending frame. The processing result is returned by the callback function. + */ + virtual void pushFrame(std::shared_ptr frame) const { + ob_error *error = nullptr; + ob_filter_push_frame(impl_, frame->getImpl(), &error); + Error::handle(&error); + } + + /** + * @brief Set the callback function for asynchronous processing. + * + * @param callback The processing result callback. + */ + virtual void setCallBack(FilterCallback callback) { + callback_ = callback; + ob_error *error = nullptr; + ob_filter_set_callback(impl_, &Filter::filterCallback, this, &error); + Error::handle(&error); + } + + /** + * @brief Get config schema of the filter + * @brief The returned string is a csv format string representing the configuration schema of the filter. The format of the string is: + * , , , , , , + * + * @return std::string The config schema of the filter. + */ + virtual std::string getConfigSchema() const { + ob_error *error = nullptr; + auto schema = ob_filter_get_config_schema(impl_, &error); + Error::handle(&error); + return schema; + } + + /** + * @brief Get the Config Schema Vec object + * @brief The returned vector contains the config schema items. Each item in the vector is an @ref OBFilterConfigSchemaItem object. + * + * @return std::vector The vector of the filter config schema. + */ + virtual std::vector getConfigSchemaVec() const { + return configSchemaVec_; + } + + /** + * @brief Set the filter config value by name. + * + * @attention The pass into value type is double, witch will be cast to the actual type inside the filter. The actual type can be queried by the filter + * config schema returned by @ref getConfigSchemaVec. + * + * @param configName The name of the config. + * @param value The value of the config. + */ + virtual void setConfigValue(const std::string &configName, double value) const { + ob_error *error = nullptr; + ob_filter_set_config_value(impl_, configName.c_str(), value, &error); + Error::handle(&error); + } + + /** + * @brief Get the Config Value object by name. + * + * @attention The returned value type has been casted to double inside the filter. The actual type can be queried by the filter config schema returned by + * @ref getConfigSchemaVec. + * + * @param configName The name of the config. + * @return double The value of the config. + */ + virtual double getConfigValue(const std::string &configName) const { + ob_error *error = nullptr; + double value = ob_filter_get_config_value(impl_, configName.c_str(), &error); + Error::handle(&error); + return value; + } + +private: + static void filterCallback(ob_frame *frame, void *userData) { + auto filter = static_cast(userData); + filter->callback_(std::make_shared(frame)); + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + virtual const char *type() { + return getName().c_str(); + } + + /** + * @brief Check if the runtime type of the filter object is compatible with a given type. + * + * @tparam T The given type. + * @return bool The result. + */ + template bool is(); + + template std::shared_ptr as() { + if(!is()) { + throw std::runtime_error("unsupported operation, object's type is not require type"); + } + + return std::static_pointer_cast(shared_from_this()); + } +}; + +/** + * @brief A factory class for creating filters. + */ +class FilterFactory { +public: + /** + * @brief Create a filter by name. + */ + static std::shared_ptr createFilter(const std::string &name) { + ob_error *error = nullptr; + auto impl = ob_create_filter(name.c_str(), &error); + Error::handle(&error); + return std::make_shared(impl); + } + + /** + * @brief Create a private filter by name and activation key. + * @brief Some private filters require an activation key to be activated, its depends on the vendor of the filter. + * + * @param name The name of the filter. + * @param activationKey The activation key of the filter. + */ + static std::shared_ptr createPrivateFilter(const std::string &name, const std::string &activationKey) { + ob_error *error = nullptr; + auto impl = ob_create_private_filter(name.c_str(), activationKey.c_str(), &error); + Error::handle(&error); + return std::make_shared(impl); + } + + /** + * @brief Get the vendor specific code of a filter by filter name. + * @brief A private filter can define its own vendor specific code for specific purposes. + * + * @param name The name of the filter. + * @return std::string The vendor specific code of the filter. + */ + static std::string getFilterVendorSpecificCode(const std::string &name) { + ob_error *error = nullptr; + auto code = ob_filter_get_vendor_specific_code(name.c_str(), &error); + Error::handle(&error); + return code; + } +}; + +/** + * @brief The PointCloudFilter class is a subclass of Filter that generates point clouds. + */ +class PointCloudFilter : public Filter { +public: + PointCloudFilter() { + ob_error *error = nullptr; + auto impl = ob_create_filter("PointCloudFilter", &error); + Error::handle(&error); + init(impl); + } + + virtual ~PointCloudFilter() noexcept = default; + + /** + * @brief Set the output pointcloud frame format. + * + * @param format The point cloud frame format: OB_FORMAT_POINT or OB_FORMAT_RGB_POINT + */ + void setCreatePointFormat(OBFormat format) { + setConfigValue("pointFormat", static_cast(format)); + } + + /** + * @brief Set the point cloud coordinate data zoom factor. + * + * @brief Calling this function to set the scale will change the point coordinate scaling factor of the output point cloud frame, The point coordinate + * scaling factor for the output point cloud frame can be obtained via @ref PointsFrame::getCoordinateValueScale function. + * + * @param factor The scale factor. + */ + void setCoordinateDataScaled(float factor) { + setConfigValue("coordinateDataScale", factor); + } + + /** + * @brief Set point cloud color data normalization. + * @brief If normalization is required, the output point cloud frame's color data will be normalized to the range [0, 1]. + * + * @attention This function only works for when create point format is set to OB_FORMAT_RGB_POINT. + * + * @param state Whether normalization is required. + */ + void setColorDataNormalization(bool state) { + setConfigValue("colorDataNormalization", state); + } + + /** + * @brief Set the point cloud coordinate system. + * + * @param type The coordinate system type. + */ + void setCoordinateSystem(OBCoordinateSystemType type) { + setConfigValue("coordinateSystemType", static_cast(type)); + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + void setPositionDataScaled(float scale) { + setCoordinateDataScaled(scale); + } + + // The following interfaces are deprecated and are retained here for compatibility purposes. + void setFrameAlignState(bool state) { + (void)state; // to complie + } + // The following interfaces are deprecated and are retained here for compatibility purposes. + void setCameraParam(OBCameraParam param) { + (void)param; + } +}; + +/** + * @brief Align for depth to other or other to depth. + */ +class Align : public Filter { +public: + Align(OBStreamType alignToStreamType) { + ob_error *error = nullptr; + auto impl = ob_create_filter("Align", &error); + Error::handle(&error); + init(impl); + + setConfigValue("AlignType", static_cast(alignToStreamType)); + } + + virtual ~Align() noexcept = default; + + OBStreamType getAlignToStreamType() { + return static_cast(static_cast(getConfigValue("AlignType"))); + } + + /** + * @brief Sets whether the output frame resolution should match the target resolution. + * When enabled, the output frame resolution will be adjusted to match (same as) the target resolution. + * When disabled, the output frame resolution will match the original resolution while maintaining + * the aspect ratio of the target resolution. + * + * + * @param state If true, output frame resolution will match the target resolution; otherwise, it will + * maintain the original resolution with the target's aspect ratio. + */ + void setMatchTargetResolution(bool state) { + setConfigValue("MatchTargetRes", state); + } + + /** + * @brief Set the Align To Stream Profile + * @brief It is useful when the align target stream dose not started (without any frame to get intrinsics and extrinsics). + * + * @param profile The Align To Stream Profile. + */ + void setAlignToStreamProfile(std::shared_ptr profile) { + ob_error *error = nullptr; + ob_align_filter_set_align_to_stream_profile(impl_, profile->getImpl(), &error); + Error::handle(&error); + } +}; + +/** + * @brief The FormatConvertFilter class is a subclass of Filter that performs format conversion. + */ +class FormatConvertFilter : public Filter { +public: + FormatConvertFilter() { + ob_error *error = nullptr; + auto impl = ob_create_filter("FormatConverter", &error); + Error::handle(&error); + init(impl); + } + + virtual ~FormatConvertFilter() noexcept = default; + + /** + * @brief Set the format conversion type. + * + * @param type The format conversion type. + */ + void setFormatConvertType(OBConvertFormat type) { + setConfigValue("convertType", static_cast(type)); + } +}; + +/** + * @brief HdrMerge processing block, + * the processing merges between depth frames with + * different sub-preset sequence ids. + */ +class HdrMerge : public Filter { +public: + HdrMerge() { + ob_error *error = nullptr; + auto impl = ob_create_filter("HDRMerge", &error); + Error::handle(&error); + init(impl); + } + + virtual ~HdrMerge() noexcept = default; +}; + +/** + * @brief Create SequenceIdFilter processing block. + */ +class SequenceIdFilter : public Filter { +private: + std::map sequenceIdList_{ { 0.f, "all" }, { 1.f, "1" } }; + OBSequenceIdItem *outputSequenceIdList_ = nullptr; + + void initSequenceIdList() { + outputSequenceIdList_ = new OBSequenceIdItem[sequenceIdList_.size()]; + + int i = 0; + for(const auto &pair: sequenceIdList_) { + outputSequenceIdList_[i].sequenceSelectId = static_cast(pair.first); + strncpy(outputSequenceIdList_[i].name, pair.second.c_str(), sizeof(outputSequenceIdList_[i].name) - 1); + outputSequenceIdList_[i].name[sizeof(outputSequenceIdList_[i].name) - 1] = '\0'; + ++i; + } + } + +public: + SequenceIdFilter() { + ob_error *error = nullptr; + auto impl = ob_create_filter("SequenceIdFilter", &error); + Error::handle(&error); + init(impl); + initSequenceIdList(); + } + + virtual ~SequenceIdFilter() noexcept { + if(outputSequenceIdList_) { + delete[] outputSequenceIdList_; + outputSequenceIdList_ = nullptr; + } + } + + /** + * @brief Set the sequenceId filter params. + * + * @param sequence_id id to pass the filter. + */ + void selectSequenceId(int sequence_id) { + setConfigValue("sequenceid", static_cast(sequence_id)); + } + + /** + * @brief Get the current sequence id. + * + * @return sequence id to pass the filter. + */ + int getSelectSequenceId() { + return static_cast(getConfigValue("sequenceid")); + } + + OBSequenceIdItem *getSequenceIdList() { + return outputSequenceIdList_; + } + + /** + * @brief Get the sequenceId list size. + * + * @return the size of sequenceId list. + */ + int getSequenceIdListSize() { + return static_cast(sequenceIdList_.size()); + } +}; + +/** + * @brief Decimation filter, reducing complexity by subsampling depth maps and losing depth details. + */ +class DecimationFilter : public Filter { +public: + DecimationFilter() { + ob_error *error = nullptr; + auto impl = ob_create_filter("DecimationFilter", &error); + Error::handle(&error); + init(impl); + } + + virtual ~DecimationFilter() noexcept = default; + + /** + * @brief Set the decimation filter scale value. + * + * @param value The decimation filter scale value. + */ + void setScaleValue(uint8_t value) { + setConfigValue("decimate", static_cast(value)); + } + + /** + * @brief Get the decimation filter scale value. + */ + uint8_t getScaleValue() { + return static_cast(getConfigValue("decimate")); + } + + /** + * @brief Get the property range of the decimation filter scale value. + */ + OBUint8PropertyRange getScaleRange() { + OBUint8PropertyRange scaleRange{}; + if(configSchemaVec_.size() != 0) { + const auto &item = configSchemaVec_[0]; + scaleRange = getPropertyRange(item, getConfigValue("decimate")); + } + return scaleRange; + } +}; + +/** + * @brief Creates depth Thresholding filter + * By controlling min and max options on the block + */ +class ThresholdFilter : public Filter { +public: + ThresholdFilter() { + ob_error *error = nullptr; + auto impl = ob_create_filter("ThresholdFilter", &error); + Error::handle(&error); + init(impl); + } + + virtual ~ThresholdFilter() noexcept = default; + + /** + * @brief Get the threshold filter min range. + * + * @return OBIntPropertyRange The range of the threshold filter min. + */ + OBIntPropertyRange getMinRange() { + OBIntPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "min") == 0) { + range = getPropertyRange(item, getConfigValue("min")); + break; + } + } + return range; + } + + /** + * @brief Get the threshold filter max range. + * + * @return OBIntPropertyRange The range of the threshold filter max. + */ + OBIntPropertyRange getMaxRange() { + OBIntPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "max") == 0) { + range = getPropertyRange(item, getConfigValue("max")); + break; + } + } + return range; + } + + /** + * @brief Set the threshold filter max and min range. + */ + bool setValueRange(uint16_t min, uint16_t max) { + if(min >= max) { + return false; + } + setConfigValue("min", min); + setConfigValue("max", max); + return true; + } +}; + +/** + * @brief Spatial advanced filte smooths the image by calculating frame with alpha and delta settings + * alpha defines the weight of the current pixel for smoothing, + * delta defines the depth gradient below which the smoothing will occur as number of depth levels. + */ +class SpatialAdvancedFilter : public Filter { +public: + SpatialAdvancedFilter(const std::string &activationKey = "") { + ob_error *error = nullptr; + auto impl = ob_create_private_filter("SpatialAdvancedFilter", activationKey.c_str(), &error); + Error::handle(&error); + init(impl); + } + + virtual ~SpatialAdvancedFilter() noexcept = default; + + /** + * @brief Get the spatial advanced filter alpha range. + * + * @return OBFloatPropertyRange the alpha value of property range. + */ + OBFloatPropertyRange getAlphaRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "alpha") == 0) { + range = getPropertyRange(item, getConfigValue("alpha")); + break; + } + } + return range; + } + + /** + * @brief Get the spatial advanced filter dispdiff range. + * + * @return OBFloatPropertyRange the dispdiff value of property range. + */ + OBUint16PropertyRange getDispDiffRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "disp_diff") == 0) { + range = getPropertyRange(item, getConfigValue("disp_diff")); + break; + } + } + return range; + } + + /** + * @brief Get the spatial advanced filter radius range. + * + * @return OBFloatPropertyRange the radius value of property range. + */ + OBUint16PropertyRange getRadiusRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "radius") == 0) { + range = getPropertyRange(item, getConfigValue("radius")); + break; + } + } + return range; + } + + /** + * @brief Get the spatial advanced filter magnitude range. + * + * @return OBFloatPropertyRange the magnitude value of property range. + */ + OBIntPropertyRange getMagnitudeRange() { + OBIntPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "magnitude") == 0) { + range = getPropertyRange(item, getConfigValue("magnitude")); + break; + } + } + return range; + } + + /** + * @brief Get the spatial advanced filter params. + * + * @return OBSpatialAdvancedFilterParams + */ + OBSpatialAdvancedFilterParams getFilterParams() { + OBSpatialAdvancedFilterParams params{}; + params.alpha = static_cast(getConfigValue("alpha")); + params.disp_diff = static_cast(getConfigValue("disp_diff")); + params.magnitude = static_cast(getConfigValue("magnitude")); + params.radius = static_cast(getConfigValue("radius")); + return params; + } + + /** + * @brief Set the spatial advanced filter params. + * + * @param params OBSpatialAdvancedFilterParams. + */ + void setFilterParams(OBSpatialAdvancedFilterParams params) { + setConfigValue("alpha", params.alpha); + setConfigValue("disp_diff", params.disp_diff); + setConfigValue("magnitude", params.magnitude); + setConfigValue("radius", params.radius); + } +}; + +/** + * @brief Hole filling filter,the processing performed depends on the selected hole filling mode. + */ +class HoleFillingFilter : public Filter { +public: + HoleFillingFilter(const std::string &activationKey = "") { + ob_error *error = nullptr; + auto impl = ob_create_private_filter("HoleFillingFilter", activationKey.c_str(), &error); + Error::handle(&error); + init(impl); + } + + ~HoleFillingFilter() noexcept = default; + + /** + * @brief Set the HoleFillingFilter mode. + * + * @param mode OBHoleFillingMode, OB_HOLE_FILL_TOP,OB_HOLE_FILL_NEAREST or OB_HOLE_FILL_FAREST. + */ + void setFilterMode(OBHoleFillingMode mode) { + setConfigValue("hole_filling_mode", static_cast(mode)); + } + + /** + * @brief Get the HoleFillingFilter mode. + * + * @return OBHoleFillingMode + */ + OBHoleFillingMode getFilterMode() { + return static_cast(static_cast(getConfigValue("hole_filling_mode"))); + } +}; + +/** + * @brief The noise removal filter,removing scattering depth pixels. + */ +class NoiseRemovalFilter : public Filter { +public: + NoiseRemovalFilter(const std::string &activationKey = "") { + ob_error *error = nullptr; + auto impl = ob_create_private_filter("NoiseRemovalFilter", activationKey.c_str(), &error); + Error::handle(&error); + init(impl); + } + + ~NoiseRemovalFilter() noexcept = default; + + /** + * @brief Set the noise removal filter params. + * + * @param[in] filterParams ob_noise_removal_filter_params. + */ + void setFilterParams(OBNoiseRemovalFilterParams filterParams) { + setConfigValue("max_size", static_cast(filterParams.max_size)); + setConfigValue("min_diff", static_cast(filterParams.disp_diff)); + // todo:set noise remove type + } + + /** + * @brief Get the noise removal filter params. + * + * @return OBNoiseRemovalFilterParams. + */ + OBNoiseRemovalFilterParams getFilterParams() { + OBNoiseRemovalFilterParams param{}; + param.max_size = static_cast(getConfigValue("max_size")); + param.disp_diff = static_cast(getConfigValue("min_diff")); + // todo: type is not set + return param; + } + + /** + * @brief Get the noise removal filter disp diff range. + * @return OBUint16PropertyRange The disp diff of property range. + */ + OBUint16PropertyRange getDispDiffRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "min_diff") == 0) { + range = getPropertyRange(item, getConfigValue("min_diff")); + break; + } + } + return range; + } + + /** + * @brief Get the noise removal filter max size range. + * @return OBUint16PropertyRange The max size of property range. + */ + OBUint16PropertyRange getMaxSizeRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "max_size") == 0) { + range = getPropertyRange(item, getConfigValue("max_size")); + break; + } + } + return range; + } +}; + +/** + * @brief Temporal filter + */ +class TemporalFilter : public Filter { +public: + TemporalFilter(const std::string &activationKey = "") { + ob_error *error = nullptr; + auto impl = ob_create_private_filter("TemporalFilter", activationKey.c_str(), &error); + Error::handle(&error); + init(impl); + } + + ~TemporalFilter() noexcept = default; + + /** + * @brief Get the TemporalFilter diffscale range. + * + * @return OBFloatPropertyRange the diffscale value of property range. + */ + OBFloatPropertyRange getDiffScaleRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "diff_scale") == 0) { + range = getPropertyRange(item, getConfigValue("diff_scale")); + break; + } + } + return range; + } + + /** + * @brief Set the TemporalFilter diffscale value. + * + * @param value diffscale value. + */ + void setDiffScale(float value) { + setConfigValue("diff_scale", static_cast(value)); + } + + /** + * @brief Get the TemporalFilter weight range. + * + * @return OBFloatPropertyRange the weight value of property range. + */ + OBFloatPropertyRange getWeightRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "weight") == 0) { + range = getPropertyRange(item, getConfigValue("weight")); + break; + } + } + return range; + } + + /** + * @brief Set the TemporalFilter weight value. + * + * @param value weight value. + */ + void setWeight(float value) { + setConfigValue("weight", static_cast(value)); + } +}; + +/** + * @brief Depth to disparity or disparity to depth + */ +class DisparityTransform : public Filter { +public: + DisparityTransform(const std::string &activationKey = "") { + ob_error *error = nullptr; + auto impl = ob_create_private_filter("DisparityTransform", activationKey.c_str(), &error); + Error::handle(&error); + init(impl); + } + + ~DisparityTransform() noexcept = default; +}; + +class OBFilterList { +private: + ob_filter_list_t *impl_; + +public: + explicit OBFilterList(ob_filter_list_t *impl) : impl_(impl) {} + + ~OBFilterList() noexcept { + ob_error *error = nullptr; + ob_delete_filter_list(impl_, &error); + Error::handle(&error, false); + } + + /** + * @brief Get the number of filters + * + * @return uint32_t The number of filters + */ + uint32_t getCount() const { + ob_error *error = nullptr; + auto count = ob_filter_list_get_count(impl_, &error); + Error::handle(&error); + return count; + } + + /** + * @brief Get the Filter object at the specified index + * + * @param index The filter index. The range is [0, count-1]. If the index exceeds the range, an exception will be thrown. + * @return std::shared_ptr The filter object. + */ + std::shared_ptr getFilter(uint32_t index) { + ob_error *error = nullptr; + auto filter = ob_filter_list_get_filter(impl_, index, &error); + Error::handle(&error); + return std::make_shared(filter); + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + uint32_t count() const { + return getCount(); + } +}; + +/** + * @brief Define the Filter type map + */ +static const std::unordered_map obFilterTypeMap = { + { "PointCloudFilter", typeid(PointCloudFilter) }, { "Align", typeid(Align) }, + { "FormatConverter", typeid(FormatConvertFilter) }, { "HDRMerge", typeid(HdrMerge) }, + { "SequenceIdFilter", typeid(SequenceIdFilter) }, { "DecimationFilter", typeid(DecimationFilter) }, + { "ThresholdFilter", typeid(ThresholdFilter) }, { "SpatialAdvancedFilter", typeid(SpatialAdvancedFilter) }, + { "HoleFillingFilter", typeid(HoleFillingFilter) }, { "NoiseRemovalFilter", typeid(NoiseRemovalFilter) }, + { "TemporalFilter", typeid(TemporalFilter) }, { "DisparityTransform", typeid(DisparityTransform) } +}; + +/** + * @brief Define the is() template function for the Filter class + */ +template bool Filter::is() { + std::string name = type(); + auto it = obFilterTypeMap.find(name); + if(it != obFilterTypeMap.end()) { + return std::type_index(typeid(T)) == it->second; + } + return false; +} + +} // namespace ob diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Frame.hpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Frame.hpp new file mode 100644 index 0000000..ea5a876 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Frame.hpp @@ -0,0 +1,1054 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Frame.hpp + * @brief Frame related type, which is mainly used to obtain frame data and frame information. + * + */ +#pragma once + +#include "Types.hpp" +#include "libobsensor/h/Frame.h" +#include "libobsensor/hpp/Error.hpp" +#include "libobsensor/hpp/StreamProfile.hpp" +#include +#include +#include +#include + +/** + * Frame classis inheritance hierarchy: + * Frame + * | + * +-----------+----------+----------+-----------+ + * | | | | | + * VideoFrame PointsFrame AccelFrame GyroFrame FrameSet + * | + * +----+----------+-------------------+ + * | | | + * ColorFrame DepthFrame IRFrame + * | + * +-----+-----+ + * | | + * IRLeftFrame IRRightFrame + */ + +namespace ob { +class Device; +class Sensor; + +/** + * @brief Define the frame class, which is the base class of all frame types. + * + */ +class Frame : public std::enable_shared_from_this { +protected: + /** + * @brief The pointer to the internal (c api level) frame object. + */ + const ob_frame *impl_ = nullptr; + +public: + /** + * @brief Construct a new Frame object with a given pointer to the internal frame object. + * + * @attention After calling this constructor, the frame object will own the internal frame object, and the internal frame object will be deleted when the + * frame object is destroyed. + * @attention The internal frame object should not be deleted by the caller. + * + * @param impl The pointer to the internal frame object. + */ + explicit Frame(const ob_frame *impl) : impl_(impl) {} + + /** + * @brief Get the internal (impl) frame object + * + * @return const ob_frame* the pointer to the internal frame object. + */ + const ob_frame *getImpl() const { + return impl_; + } + + /** + * @brief Destroy the Frame object + */ + virtual ~Frame() noexcept { + if(impl_) { + ob_error *error = nullptr; + ob_delete_frame(impl_, &error); + Error::handle(&error, false); + impl_ = nullptr; + } + } + + /** + * @brief Get the type of frame. + * + * @return OBFrameType The type of frame. + */ + virtual OBFrameType getType() const { + ob_error *error = nullptr; + auto type = ob_frame_get_type(impl_, &error); + Error::handle(&error); + + return type; + } + + /** + * @brief Get the format of the frame. + * + * @return OBFormat The format of the frame. + */ + virtual OBFormat getFormat() const { + ob_error *error = nullptr; + auto format = ob_frame_get_format(impl_, &error); + Error::handle(&error); + + return format; + } + + /** + * @brief Get the sequence number of the frame. + * + * @note The sequence number for each frame is managed by the SDK. It increments by 1 for each frame on each stream. + * + * @return uint64_t The sequence number of the frame. + */ + virtual uint64_t getIndex() const { + ob_error *error = nullptr; + auto index = ob_frame_get_index(impl_, &error); + Error::handle(&error); + + return index; + } + + /** + * @brief Get frame data + * + * @return const uint8_t * The frame data pointer. + */ + virtual uint8_t *getData() const { + ob_error *error = nullptr; + auto data = ob_frame_get_data(impl_, &error); + Error::handle(&error); + + return data; + } + + /** + * @brief Get the size of the frame data. + * + * @return uint32_t The size of the frame data. + * For point cloud data, this returns the number of bytes occupied by all point sets. To find the number of points, divide the dataSize by the structure + * size of the corresponding point type. + */ + virtual uint32_t getDataSize() const { + ob_error *error = nullptr; + auto dataSize = ob_frame_get_data_size(impl_, &error); + Error::handle(&error); + + return dataSize; + } + + /** + * @brief Get the hardware timestamp of the frame in microseconds. + * @brief The hardware timestamp is the time point when the frame was captured by the device, on device clock domain. + * + * @return uint64_t The hardware timestamp of the frame in microseconds. + */ + uint64_t getTimeStampUs() const { + ob_error *error = nullptr; + auto timeStampUs = ob_frame_get_timestamp_us(impl_, &error); + Error::handle(&error); + + return timeStampUs; + } + + /** + * @brief Get the system timestamp of the frame in microseconds. + * @brief The system timestamp is the time point when the frame was received by the host, on host clock domain. + * + * @return uint64_t The system timestamp of the frame in microseconds. + */ + uint64_t getSystemTimeStampUs() const { + ob_error *error = nullptr; + auto systemTimeStampUs = ob_frame_get_system_timestamp_us(impl_, &error); + Error::handle(&error); + + return systemTimeStampUs; + } + + /** + * @brief Get the global timestamp of the frame in microseconds. + * @brief The global timestamp is the time point when the frame was captured by the device, and has been converted to the host clock domain. The + * conversion process base on the device timestamp and can eliminate the timer drift of the device + * + * @attention The global timestamp disable by default. If global timestamp is not enabled, the function will return 0. To enable the global timestamp, + * please call @ref Device::enableGlobalTimestamp() function. + * @attention Only some devices support getting the global timestamp. Check the device support status by @ref Device::isGlobalTimestampSupported() function. + * + * @return uint64_t The global timestamp of the frame in microseconds. + */ + uint64_t getGlobalTimeStampUs() const { + ob_error *error = nullptr; + auto globalTimeStampUs = ob_frame_get_global_timestamp_us(impl_, &error); + Error::handle(&error); + + return globalTimeStampUs; + } + + /** + * @brief Get the metadata pointer of the frame. + * + * @return const uint8_t * The metadata pointer of the frame. + */ + uint8_t *getMetadata() const { + ob_error *error = nullptr; + auto metadata = ob_frame_get_metadata(impl_, &error); + Error::handle(&error); + + return metadata; + } + + /** + * @brief Get the size of the metadata of the frame. + * + * @return uint32_t The size of the metadata of the frame. + */ + uint32_t getMetadataSize() const { + ob_error *error = nullptr; + auto metadataSize = ob_frame_get_metadata_size(impl_, &error); + Error::handle(&error); + + return metadataSize; + } + + /** + * @brief Check if the frame object has metadata of a given type. + * + * @param type The metadata type. refer to @ref OBFrameMetadataType + * @return bool The result. + */ + bool hasMetadata(OBFrameMetadataType type) const { + ob_error *error = nullptr; + auto result = ob_frame_has_metadata(impl_, type, &error); + Error::handle(&error); + + return result; + } + + /** + * @brief Get the metadata value + * + * @param type The metadata type. refer to @ref OBFrameMetadataType + * @return int64_t The metadata value. + */ + int64_t getMetadataValue(OBFrameMetadataType type) const { + ob_error *error = nullptr; + auto value = ob_frame_get_metadata_value(impl_, type, &error); + Error::handle(&error); + + return value; + } + + /** + * @brief get StreamProfile of the frame + * + * @return std::shared_ptr The StreamProfile of the frame, may return nullptr if the frame is not captured from a stream. + */ + std::shared_ptr getStreamProfile() const { + ob_error *error = nullptr; + auto profile = ob_frame_get_stream_profile(impl_, &error); + Error::handle(&error); + return StreamProfileFactory::create(profile); + } + + /** + * @brief get owner sensor of the frame + * + * @return std::shared_ptr The owner sensor of the frame, return nullptr if the frame is not owned by any sensor or the sensor is destroyed + */ + std::shared_ptr getSensor() const { + ob_error *error = nullptr; + auto sensor = ob_frame_get_sensor(impl_, &error); + Error::handle(&error); + + return std::make_shared(sensor); + } + + /** + * @brief get owner device of the frame + * + * @return std::shared_ptr The owner device of the frame, return nullptr if the frame is not owned by any device or the device is destroyed + */ + std::shared_ptr getDevice() const { + ob_error *error = nullptr; + auto device = ob_frame_get_device(impl_, &error); + Error::handle(&error); + + return std::make_shared(device); + } + + /** + * @brief Check if the runtime type of the frame object is compatible with a given type. + * + * @tparam T The given type. + * @return bool The result. + */ + template bool is() const; + + /** + * @brief Convert the frame object to a target type. + * + * @tparam T The target type. + * @return std::shared_ptr The result. If it cannot be converted, an exception will be thrown. + */ + template std::shared_ptr as() { + if(!is()) { + throw std::runtime_error("unsupported operation, object's type is not require type"); + } + + ob_error *error = nullptr; + ob_frame_add_ref(impl_, &error); + Error::handle(&error); + + return std::make_shared(impl_); + } + + /** + * @brief Convert the frame object to a target type. + * + * @tparam T The target type. + * @return std::shared_ptr The result. If it cannot be converted, an exception will be thrown. + */ + template std::shared_ptr as() const { + if(!is()) { + throw std::runtime_error("unsupported operation, object's type is not require type"); + } + + ob_error *error = nullptr; + ob_frame_add_ref(impl_, &error); + Error::handle(&error); + + return std::make_shared(impl_); + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + OBFrameType type() const { + return getType(); + } + + virtual OBFormat format() const { + return getFormat(); + } + + virtual uint64_t index() const { + return getIndex(); + } + + virtual void *data() const { + auto data = getData(); + return reinterpret_cast(data); + } + + virtual uint32_t dataSize() const { + return getDataSize(); + } + + uint64_t timeStamp() const { + return getTimeStampUs() / 1000; + } + + uint64_t timeStampUs() const { + return getTimeStampUs(); + } + + uint64_t systemTimeStamp() const { + return getSystemTimeStampUs() / 1000; + } + + uint64_t systemTimeStampUs() const { + return getSystemTimeStampUs(); + } + + uint64_t globalTimeStampUs() const { + return getGlobalTimeStampUs(); + } + + uint8_t *metadata() const { + return getMetadata(); + } + + uint32_t metadataSize() const { + return getMetadataSize(); + } +}; + +/** + * @brief Define the VideoFrame class, which inherits from the Frame class + */ +class VideoFrame : public Frame { +public: + /** + * @brief Construct a new VideoFrame object with a given pointer to the internal frame object. + * + * @attention After calling this constructor, the frame object will own the internal frame object, and the internal frame object will be deleted when the + * frame object is destroyed. + * @attention The internal frame object should not be deleted by the caller. + * + * @param impl The pointer to the internal frame object. + */ + explicit VideoFrame(const ob_frame *impl) : Frame(impl) {}; + + ~VideoFrame() noexcept override = default; + + /** + * @brief Get the width of the frame. + * + * @return uint32_t The width of the frame. + */ + uint32_t getWidth() const { + ob_error *error = nullptr; + auto width = ob_video_frame_get_width(impl_, &error); + Error::handle(&error); + + return width; + } + + /** + * @brief Get the height of the frame. + * + * @return uint32_t The height of the frame. + */ + uint32_t getHeight() const { + ob_error *error = nullptr; + auto height = ob_video_frame_get_height(impl_, &error); + Error::handle(&error); + + return height; + } + + /** + * @brief Get the Pixel Type object + * @brief Usually used to determine the pixel type of depth frame (depth, disparity, raw phase, etc.) + * + * @attention Always return OB_PIXEL_UNKNOWN for non-depth frame currently + * + * @return OBPixelType + */ + OBPixelType getPixelType() const { + ob_error *error = nullptr; + auto pixelType = ob_video_frame_get_pixel_type(impl_, &error); + Error::handle(&error); + + return pixelType; + } + + /** + * @brief Get the effective number of pixels in the frame. + * @attention Only valid for Y8/Y10/Y11/Y12/Y14/Y16 format. + * + * @return uint8_t The effective number of pixels in the frame, or 0 if it is an unsupported format. + */ + uint8_t getPixelAvailableBitSize() const { + ob_error *error = nullptr; + auto bitSize = ob_video_frame_get_pixel_available_bit_size(impl_, &error); + Error::handle(&error); + + return bitSize; + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + uint32_t width() const { + return getWidth(); + } + + uint32_t height() const { + return getHeight(); + } + + uint8_t pixelAvailableBitSize() const { + return getPixelAvailableBitSize(); + } +}; + +/** + * @brief Define the ColorFrame class, which inherits from the VideoFrame classd + */ +class ColorFrame : public VideoFrame { +public: + /** + * @brief Construct a new ColorFrame object with a given pointer to the internal frame object. + * + * @attention After calling this constructor, the frame object will own the internal frame object, and the internal frame object will be deleted when the + * frame object is destroyed. + * @attention The internal frame object should not be deleted by the caller. + * @attention Please use the FrameFactory to create a Frame object. + * + * @param impl The pointer to the internal frame object. + */ + explicit ColorFrame(const ob_frame *impl) : VideoFrame(impl) {}; + + ~ColorFrame() noexcept override = default; +}; + +/** + * @brief Define the DepthFrame class, which inherits from the VideoFrame class + */ +class DepthFrame : public VideoFrame { + +public: + /** + * @brief Construct a new DepthFrame object with a given pointer to the internal frame object. + * + * @attention After calling this constructor, the frame object will own the internal frame object, and the internal frame object will be deleted when the + * frame object is destroyed. + * @attention The internal frame object should not be deleted by the caller. + * @attention Please use the FrameFactory to create a Frame object. + * + * @param impl The pointer to the internal frame object. + */ + explicit DepthFrame(const ob_frame *impl) : VideoFrame(impl) {}; + + ~DepthFrame() noexcept override = default; + + /** + * @brief Get the value scale of the depth frame. The pixel value of depth frame is multiplied by the scale to give a depth value in millimeters. + * For example, if valueScale=0.1 and a certain coordinate pixel value is pixelValue=10000, then the depth value = pixelValue*valueScale = + * 10000*0.1=1000mm. + * + * @return float The scale. + */ + float getValueScale() const { + ob_error *error = nullptr; + auto scale = ob_depth_frame_get_value_scale(impl_, &error); + Error::handle(&error); + + return scale; + } +}; + +/** + * @brief Define the IRFrame class, which inherits from the VideoFrame class + * + */ +class IRFrame : public VideoFrame { + +public: + /** + * @brief Construct a new IRFrame object with a given pointer to the internal frame object. + * + * @attention After calling this constructor, the frame object will own the internal frame object, and the internal frame object will be deleted when the + * frame object is destroyed. + * @attention The internal frame object should not be deleted by the caller. + * @attention Please use the FrameFactory to create a Frame object. + * + * @param impl The pointer to the internal frame object. + */ + explicit IRFrame(const ob_frame *impl) : VideoFrame(impl) {}; + + ~IRFrame() noexcept override = default; +}; + +/** + * @brief Define the PointsFrame class, which inherits from the Frame class + * @brief The PointsFrame class is used to obtain pointcloud data and point cloud information. + * + * @note The pointcloud data format can be obtained from the @ref Frame::getFormat() function. Witch can be one of the following formats: + * - @ref OB_FORMAT_POINT: 32-bit float format with 3D point coordinates (x, y, z), @ref OBPoint + * - @ref OB_FORMAT_RGB_POINT: 32-bit float format with 3D point coordinates (x, y, z) and point colors (r, g, b) @ref, OBColorPoint + */ +class PointsFrame : public Frame { + +public: + /** + * @brief Construct a new PointsFrame object with a given pointer to the internal frame object. + * + * @attention After calling this constructor, the frame object will own the internal frame object, and the internal frame object will be deleted when the + * frame object is destroyed. + * @attention The internal frame object should not be deleted by the caller. + * @attention Please use the FrameFactory to create a Frame object. + * + * @param impl The pointer to the internal frame object. + */ + explicit PointsFrame(const ob_frame *impl) : Frame(impl) {}; + + ~PointsFrame() noexcept override = default; + + /** + * @brief Get the point coordinate value scale of the points frame. The point position value of the points frame is multiplied by the scale to give a + * position value in millimeters. For example, if scale=0.1, the x-coordinate value of a point is x = 10000, which means that the actual x-coordinate value + * = x*scale = 10000*0.1 = 1000mm. + * + * @return float The coordinate value scale. + */ + float getCoordinateValueScale() const { + ob_error *error = nullptr; + auto scale = ob_points_frame_get_coordinate_value_scale(impl_, &error); + Error::handle(&error); + + return scale; + } + + /** + * @brief Get the width of the frame. + * + * @return uint32_t The width of the frame. + */ + uint32_t getWidth() const { + ob_error *error = nullptr; + // TODO + auto width = ob_point_cloud_frame_get_width(impl_, &error); + Error::handle(&error); + + return width; + } + + /** + * @brief Get the height of the frame. + * + * @return uint32_t The height of the frame. + */ + uint32_t getHeight() const { + ob_error *error = nullptr; + auto height = ob_point_cloud_frame_get_height(impl_, &error); + Error::handle(&error); + + return height; + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. +#define getPositionValueScale getCoordinateValueScale +}; + +/** + * @brief Define the AccelFrame class, which inherits from the Frame class + * + */ +class AccelFrame : public Frame { + +public: + explicit AccelFrame(const ob_frame *impl) : Frame(impl) {}; + + ~AccelFrame() noexcept override = default; + + /** + * @brief Get the accelerometer frame data + * + * @return OBAccelValue The accelerometer frame data + */ + OBAccelValue getValue() const { + ob_error *error = nullptr; + auto value = ob_accel_frame_get_value(impl_, &error); + Error::handle(&error); + + return value; + } + + /** + * @brief Get the temperature when the frame was sampled + * + * @return float The temperature value in celsius + */ + float getTemperature() const { + ob_error *error = nullptr; + auto temp = ob_accel_frame_get_temperature(impl_, &error); + Error::handle(&error); + + return temp; + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + OBAccelValue value() { + return getValue(); + } + + float temperature() { + return getTemperature(); + } +}; + +/** + * @brief Define the GyroFrame class, which inherits from the Frame class + */ +class GyroFrame : public Frame { + +public: + explicit GyroFrame(const ob_frame *impl) : Frame(impl) {}; + + ~GyroFrame() noexcept override = default; + + /** + * @brief Get the gyro frame data + * + * @return OBAccelValue The gyro frame data + */ + OBGyroValue getValue() const { + ob_error *error = nullptr; + auto value = ob_gyro_frame_get_value(impl_, &error); + Error::handle(&error); + + return value; + } + + /** + * @brief Get the temperature when the frame was sampled + * + * @return float The temperature value in celsius + */ + float getTemperature() const { + ob_error *error = nullptr; + auto temperature = ob_gyro_frame_get_temperature(impl_, &error); + Error::handle(&error); + + return temperature; + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + OBGyroValue value() { + return getValue(); + } + + float temperature() { + return getTemperature(); + } +}; + +/** + * @brief Define the FrameSet class, which inherits from the Frame class + * @brief A FrameSet is a container for multiple frames of different types. + */ +class FrameSet : public Frame { + +public: + explicit FrameSet(const ob_frame *impl) : Frame(impl) {}; + + ~FrameSet() noexcept override = default; + + /** + * @brief Get the number of frames in the FrameSet + * + * @return uint32_t The number of frames + */ + uint32_t getCount() const { + ob_error *error = nullptr; + auto count = ob_frameset_get_count(impl_, &error); + Error::handle(&error); + return count; + } + + /** + * @brief Get a frame of a specific type from the FrameSet + * + * @param frameType The type of sensor + * @return std::shared_ptr The corresponding type of frame + */ + std::shared_ptr getFrame(OBFrameType frameType) const { + ob_error *error = nullptr; + auto frame = ob_frameset_get_frame(impl_, frameType, &error); + if(!frame) { + return nullptr; + } + Error::handle(&error); + return std::make_shared(frame); + } + + /** + * @brief Get a frame at a specific index from the FrameSet + * + * @param index The index of the frame + * @return std::shared_ptr The frame at the specified index + */ + std::shared_ptr getFrameByIndex(uint32_t index) const { + ob_error *error = nullptr; + auto frame = ob_frameset_get_frame_by_index(impl_, index, &error); + if(!frame) { + return nullptr; + } + Error::handle(&error); + return std::make_shared(frame); + } + + /** + * @brief Push a frame to the FrameSet + * + * @attention If the FrameSet contains the same type of frame, the new frame will replace the old one. + * + * @param frame The frame to be pushed + */ + void pushFrame(std::shared_ptr frame) const { + ob_error *error = nullptr; + + // unsafe operation, need to cast const to non-const + auto unConstImpl = const_cast(impl_); + + auto otherImpl = frame->getImpl(); + ob_frameset_push_frame(unConstImpl, otherImpl, &error); + + Error::handle(&error); + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + uint32_t frameCount() const { + return getCount(); + } + + std::shared_ptr depthFrame() const { + auto frame = getFrame(OB_FRAME_DEPTH); + if(frame == nullptr) { + return nullptr; + } + auto depthFrame = frame->as(); + return depthFrame; + } + + std::shared_ptr colorFrame() const { + auto frame = getFrame(OB_FRAME_COLOR); + if(frame == nullptr) { + return nullptr; + } + auto colorFrame = frame->as(); + return colorFrame; + } + + std::shared_ptr irFrame() const { + auto frame = getFrame(OB_FRAME_IR); + if(frame == nullptr) { + return nullptr; + } + auto irFrame = frame->as(); + return irFrame; + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + std::shared_ptr pointsFrame() const { + auto frame = getFrame(OB_FRAME_POINTS); + if(frame == nullptr) { + return nullptr; + } + auto pointsFrame = frame->as(); + return pointsFrame; + } + + std::shared_ptr getFrame(int index) const { + return getFrameByIndex(index); + } +}; + +/** + * @brief FrameFactory class, which provides some static functions to create frame objects + */ +class FrameFactory { +public: + /** + * @brief Create a Frame object of a specific type with a given format and data size. + * + * @param frameType The type of the frame. + * @param format The format of the frame. + * @param dataSize The size of the data in bytes. + * @return std::shared_ptr The created frame object. + */ + static std::shared_ptr createFrame(OBFrameType frameType, OBFormat format, uint32_t dataSize) { + ob_error *error = nullptr; + auto impl = ob_create_frame(frameType, format, dataSize, &error); + Error::handle(&error); + + return std::make_shared(impl); + } + + /** + * @brief Create a VideoFrame object of a specific type with a given format, width, height, and stride. + * @note If stride is not specified, it will be calculated based on the width and format. + * + * @param frameType The type of the frame. + * @param format The format of the frame. + * @param width The width of the frame. + * @param height The height of the frame. + * @param stride The stride of the frame. + * + * @return std::shared_ptr The created video frame object. + */ + static std::shared_ptr createVideoFrame(OBFrameType frameType, OBFormat format, uint32_t width, uint32_t height, uint32_t stride = 0) { + ob_error *error = nullptr; + auto impl = ob_create_video_frame(frameType, format, width, height, stride, &error); + Error::handle(&error); + + auto frame = std::make_shared(impl); + return frame->as(); + } + + /** + * @brief Create (clone) a frame object based on the specified other frame object. + * @brief The new frame object will have the same properties as the other frame object, but the data buffer is newly allocated. + * + * @param shouldCopyData If true, the data of the source frame object will be copied to the new frame object. If false, the new frame object will + * have a data buffer with random data. The default value is true. + * + * @return std::shared_ptr The new frame object. + */ + static std::shared_ptr createFrameFromOtherFrame(std::shared_ptr otherFrame, bool shouldCopyData = true) { + ob_error *error = nullptr; + auto otherImpl = otherFrame->getImpl(); + auto impl = ob_create_frame_from_other_frame(otherImpl, shouldCopyData, &error); + Error::handle(&error); + + return std::make_shared(impl); + } + + /** + * @brief Create a Frame From (according to)Stream Profile object + * + * @param profile The stream profile object to create the frame from. + * + * @return std::shared_ptr The created frame object. + */ + static std::shared_ptr createFrameFromStreamProfile(std::shared_ptr profile) { + ob_error *error = nullptr; + auto impl = ob_create_frame_from_stream_profile(profile->getImpl(), &error); + Error::handle(&error); + + return std::make_shared(impl); + } + + /** + * @brief The callback function to destroy the buffer when the frame is destroyed. + */ + typedef std::function BufferDestroyCallback; + + /** + * @brief Create a frame object based on an externally created buffer. + * + * @attention The buffer is owned by the caller, and will not be destroyed by the frame object. The user should ensure that the buffer is valid and not + * modified. + * + * @param[in] frameType Frame object type. + * @param[in] format Frame object format. + * @param[in] buffer Frame object buffer. + * @param[in] destroyCallback Destroy callback, will be called when the frame object is destroyed. + * @param[in] bufferSize Frame object buffer size. + * + * @return std::shared_ptr The created frame object. + */ + static std::shared_ptr createFrameFromBuffer(OBFrameType frameType, OBFormat format, uint8_t *buffer, BufferDestroyCallback destroyCallback, + uint32_t bufferSize) { + ob_error *error = nullptr; + auto ctx = new BufferDestroyContext{ destroyCallback }; + auto impl = ob_create_frame_from_buffer(frameType, format, buffer, bufferSize, &FrameFactory::BufferDestroy, ctx, &error); + Error::handle(&error); + + return std::make_shared(impl); + } + + /** + * @brief Create a video frame object based on an externally created buffer. + * + * @attention The buffer is owned by the user and will not be destroyed by the frame object. The user should ensure that the buffer is valid and not + * modified. + * @attention The frame object is created with a reference count of 1, and the reference count should be decreased by calling @ref ob_delete_frame() when it + * is no longer needed. + * + * @param[in] frameType Frame object type. + * @param[in] format Frame object format. + * @param[in] width Frame object width. + * @param[in] height Frame object height. + * @param[in] buffer Frame object buffer. + * @param[in] bufferSize Frame object buffer size. + * @param[in] destroyCallback Destroy callback, will be called when the frame object is destroyed. + * @param[in] stride Row span in bytes. If 0, the stride is calculated based on the width and format. + * + * @return std::shared_ptr The created video frame object. + */ + static std::shared_ptr createVideoFrameFromBuffer(OBFrameType frameType, OBFormat format, uint32_t width, uint32_t height, uint8_t *buffer, + BufferDestroyCallback destroyCallback, uint32_t bufferSize, uint32_t stride = 0) { + ob_error *error = nullptr; + auto ctx = new BufferDestroyContext{ destroyCallback }; + auto impl = ob_create_video_frame_from_buffer(frameType, format, width, height, stride, buffer, bufferSize, &FrameFactory::BufferDestroy, ctx, &error); + Error::handle(&error); + + auto frame = std::make_shared(impl); + return frame->as(); + } + +private: + struct BufferDestroyContext { + BufferDestroyCallback callback; + }; + + static void BufferDestroy(uint8_t *buffer, void *context) { + auto *ctx = static_cast(context); + if(ctx->callback) { + ctx->callback(buffer); + } + delete ctx; + } +}; + +/** + * @brief FrameHepler class, which provides some static functions to set timestamp for frame objects + * FrameHepler inherited from the FrameFactory and the timestamp interface implement here both for compatibility purposes. + */ +class FrameHelper : public FrameFactory { +public: + /** + * @brief Set the device timestamp of the frame. + * + * @param frame The frame object. + * @param deviceTimestampUs The device timestamp to set in microseconds. + */ + static void setFrameDeviceTimestampUs(std::shared_ptr frame, uint64_t deviceTimestampUs) { + ob_error *error = nullptr; + auto impl = const_cast(frame->getImpl()); + ob_frame_set_timestamp_us(impl, deviceTimestampUs, &error); + Error::handle(&error); + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + static void setFrameSystemTimestamp(std::shared_ptr frame, uint64_t systemTimestamp) { + // In order to compile, some high-version compilers will warn that the function parameters are not used. + (void)frame; + (void)systemTimestamp; + } + + static void setFrameDeviceTimestamp(std::shared_ptr frame, uint64_t deviceTimestamp) { + // In order to compile, some high-version compilers will warn that the function parameters are not used. + (void)frame; + (void)deviceTimestamp; + } +}; + +// Define the is() template function for the Frame class +template bool Frame::is() const { + switch(this->getType()) { + case OB_FRAME_IR_LEFT: // Follow + case OB_FRAME_IR_RIGHT: // Follow + case OB_FRAME_IR: + return (typeid(T) == typeid(IRFrame) || typeid(T) == typeid(VideoFrame)); + case OB_FRAME_DEPTH: + return (typeid(T) == typeid(DepthFrame) || typeid(T) == typeid(VideoFrame)); + case OB_FRAME_COLOR: + return (typeid(T) == typeid(ColorFrame) || typeid(T) == typeid(VideoFrame)); + case OB_FRAME_GYRO: + return (typeid(T) == typeid(GyroFrame)); + case OB_FRAME_ACCEL: + return (typeid(T) == typeid(AccelFrame)); + case OB_FRAME_POINTS: + return (typeid(T) == typeid(PointsFrame)); + case OB_FRAME_SET: + return (typeid(T) == typeid(FrameSet)); + default: + std::cout << "ob::Frame::is() did not catch frame type: " << (int)this->getType() << std::endl; + break; + } + return false; +} + +} // namespace ob diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Pipeline.hpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Pipeline.hpp new file mode 100644 index 0000000..61009f1 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Pipeline.hpp @@ -0,0 +1,451 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Pipeline.hpp + * @brief The SDK's advanced API type can quickly implement switching streaming and frame synchronization + * operations. + */ +#pragma once + +#include "Frame.hpp" +#include "Device.hpp" +#include "StreamProfile.hpp" + +#include "libobsensor/h/Pipeline.h" +#include "libobsensor/hpp/Types.hpp" +#include "libobsensor/hpp/TypeHelper.hpp" + +#include +#include +namespace ob { + +/** + * @brief Config class for configuring pipeline parameters + * + * The Config class provides an interface for configuring pipeline parameters. + */ +class Config { +private: + ob_config_t *impl_; + +public: + /** + * @brief Construct a new Config object + */ + Config() { + ob_error *error = nullptr; + impl_ = ob_create_config(&error); + Error::handle(&error); + } + + explicit Config(ob_config_t *impl) : impl_(impl) {} + + /** + * @brief Destroy the Config object + */ + ~Config() noexcept { + ob_error *error = nullptr; + ob_delete_config(impl_, &error); + Error::handle(&error, false); + } + + ob_config_t *getImpl() const { + return impl_; + } + + /** + * @brief enable a stream with a specific stream type + * + * @param streamType The stream type to be enabled + */ + void enableStream(OBStreamType streamType) const { + ob_error *error = nullptr; + ob_config_enable_stream(impl_, streamType, &error); + Error::handle(&error); + } + + /** + * @brief Enable a stream with a specific sensor type + * @brief Will convert sensor type to stream type automatically. + * + * @param sensorType The sensor type to be enabled + */ + void enableStream(OBSensorType sensorType) const { + auto streamType = ob::TypeHelper::convertSensorTypeToStreamType(sensorType); + enableStream(streamType); + } + + /** + * @brief Enable a stream to be used in the pipeline + * + * @param streamProfile The stream configuration to be enabled + */ + void enableStream(std::shared_ptr streamProfile) const { + ob_error *error = nullptr; + auto c_stream_profile = streamProfile->getImpl(); + ob_config_enable_stream_with_stream_profile(impl_, c_stream_profile, &error); + Error::handle(&error); + } + + /** + * @brief Enable a video stream to be used in the pipeline. + * + * This function allows users to enable a video stream with customizable parameters. + * If no parameters are specified, the stream will be enabled with default resolution settings. + * Users who wish to set custom resolutions should refer to the product manual, as available resolutions vary by camera model. + * + * @param streamType The video stream type. + * @param width The video stream width (default is OB_WIDTH_ANY, which selects the default resolution). + * @param height The video stream height (default is OB_HEIGHT_ANY, which selects the default resolution). + * @param fps The video stream frame rate (default is OB_FPS_ANY, which selects the default frame rate). + * @param format The video stream format (default is OB_FORMAT_ANY, which selects the default format). + */ + void enableVideoStream(OBStreamType streamType, uint32_t width = OB_WIDTH_ANY, uint32_t height = OB_HEIGHT_ANY, uint32_t fps = OB_FPS_ANY, + OBFormat format = OB_FORMAT_ANY) const { + ob_error *error = nullptr; + ob_config_enable_video_stream(impl_, streamType, width, height, fps, format, &error); + Error::handle(&error); + } + + /** + * @brief Enable a video stream to be used in the pipeline. + * @brief Will convert sensor type to stream type automatically. + * + * @param sensorType The sensor type to be enabled. + * @param width The video stream width (default is OB_WIDTH_ANY, which selects the default resolution). + * @param height The video stream height (default is OB_HEIGHT_ANY, which selects the default resolution). + * @param fps The video stream frame rate (default is OB_FPS_ANY, which selects the default frame rate). + * @param format The video stream format (default is OB_FORMAT_ANY, which selects the default format). + */ + void enableVideoStream(OBSensorType sensorType, uint32_t width = OB_WIDTH_ANY, uint32_t height = OB_HEIGHT_ANY, uint32_t fps = OB_FPS_ANY, + OBFormat format = OB_FORMAT_ANY) const { + auto streamType = ob::TypeHelper::convertSensorTypeToStreamType(sensorType); + enableVideoStream(streamType, width, height, fps, format); + } + + /** + * @brief Enable an accelerometer stream to be used in the pipeline. + * + * This function allows users to enable an accelerometer stream with customizable parameters. + * If no parameters are specified, the stream will be enabled with default settings. + * Users who wish to set custom full-scale ranges or sample rates should refer to the product manual, as available settings vary by device model. + * + * @param fullScaleRange The full-scale range of the accelerometer (default is OB_ACCEL_FULL_SCALE_RANGE_ANY, which selects the default range). + * @param sampleRate The sample rate of the accelerometer (default is OB_ACCEL_SAMPLE_RATE_ANY, which selects the default rate). + */ + void enableAccelStream(OBAccelFullScaleRange fullScaleRange = OB_ACCEL_FULL_SCALE_RANGE_ANY, + OBAccelSampleRate sampleRate = OB_ACCEL_SAMPLE_RATE_ANY) const { + ob_error *error = nullptr; + ob_config_enable_accel_stream(impl_, fullScaleRange, sampleRate, &error); + Error::handle(&error); + } + + /** + * @brief Enable a gyroscope stream to be used in the pipeline. + * + * This function allows users to enable a gyroscope stream with customizable parameters. + * If no parameters are specified, the stream will be enabled with default settings. + * Users who wish to set custom full-scale ranges or sample rates should refer to the product manual, as available settings vary by device model. + * + * @param fullScaleRange The full-scale range of the gyroscope (default is OB_GYRO_FULL_SCALE_RANGE_ANY, which selects the default range). + * @param sampleRate The sample rate of the gyroscope (default is OB_GYRO_SAMPLE_RATE_ANY, which selects the default rate). + */ + void enableGyroStream(OBGyroFullScaleRange fullScaleRange = OB_GYRO_FULL_SCALE_RANGE_ANY, OBGyroSampleRate sampleRate = OB_GYRO_SAMPLE_RATE_ANY) const { + ob_error *error = nullptr; + ob_config_enable_gyro_stream(impl_, fullScaleRange, sampleRate, &error); + Error::handle(&error); + } + + /** + * @deprecated Use enableStream(std::shared_ptr streamProfile) instead + * @brief Enable all streams to be used in the pipeline + */ + void enableAllStream() { + ob_error *error = nullptr; + ob_config_enable_all_stream(impl_, &error); + Error::handle(&error); + } + + /** + * @brief Disable a stream to be used in the pipeline + * + * @param streamType The stream configuration to be disabled + */ + void disableStream(OBStreamType streamType) const { + ob_error *error = nullptr; + ob_config_disable_stream(impl_, streamType, &error); + Error::handle(&error); + } + + /** + * @brief Disable a sensor stream to be used in the pipeline. + * @brief Will convert sensor type to stream type automatically. + * + * @param sensorType The sensor configuration to be disabled + */ + void disableStream(OBSensorType sensorType) const { + auto streamType = ob::TypeHelper::convertSensorTypeToStreamType(sensorType); + disableStream(streamType); + } + + /** + * @brief Disable all streams to be used in the pipeline + */ + void disableAllStream() const { + ob_error *error = nullptr; + ob_config_disable_all_stream(impl_, &error); + Error::handle(&error); + } + + /** + * @brief Get the Enabled Stream Profile List + * + * @return std::shared_ptr + */ + std::shared_ptr getEnabledStreamProfileList() const { + ob_error *error = nullptr; + auto list = ob_config_get_enabled_stream_profile_list(impl_, &error); + Error::handle(&error); + return std::make_shared(list); + } + + /** + * @brief Set the alignment mode + * + * @param mode The alignment mode + */ + void setAlignMode(OBAlignMode mode) const { + ob_error *error = nullptr; + ob_config_set_align_mode(impl_, mode, &error); + Error::handle(&error); + } + + /** + * @brief Set whether the depth needs to be scaled after setting D2C + * + * @param enable Whether scaling is required + */ + void setDepthScaleRequire(bool enable) const { + ob_error *error = nullptr; + ob_config_set_depth_scale_after_align_require(impl_, enable, &error); + Error::handle(&error); + } + + /** + * @brief Set the frame aggregation output mode for the pipeline configuration + * @brief The processing strategy when the FrameSet generated by the frame aggregation function does not contain the frames of all opened streams (which + * can be caused by different frame rates of each stream, or by the loss of frames of one stream): drop directly or output to the user. + * + * @param mode The frame aggregation output mode to be set (default mode is @ref OB_FRAME_AGGREGATE_OUTPUT_ANY_SITUATION) + */ + void setFrameAggregateOutputMode(OBFrameAggregateOutputMode mode) const { + ob_error *error = nullptr; + ob_config_set_frame_aggregate_output_mode(impl_, mode, &error); + Error::handle(&error); + } +}; + +class Pipeline { +public: + /** + * @brief FrameSetCallback is a callback function type for frameset data arrival. + * + * @param frame The returned frameset data + */ + typedef std::function frame)> FrameSetCallback; + +private: + ob_pipeline_t *impl_; + FrameSetCallback callback_; + +public: + /** + * @brief Pipeline is a high-level interface for applications, algorithms related RGBD data streams. Pipeline can provide alignment inside and synchronized + * FrameSet. Pipeline() no parameter version, which opens the first device in the list of devices connected to the OS by default. If the application has + * obtained the device through the DeviceList, opening the Pipeline() at this time will throw an exception that the device has been created. + */ + Pipeline() { + ob_error *error = nullptr; + impl_ = ob_create_pipeline(&error); + Error::handle(&error); + } + + /** + * @brief + * Pipeline(std::shared_ptr< Device > device ) Function for multi-device operations. Multiple devices need to be obtained through DeviceList, and the device + * and pipeline are bound through this interface. + */ + explicit Pipeline(std::shared_ptr device) { + ob_error *error = nullptr; + impl_ = ob_create_pipeline_with_device(device->getImpl(), &error); + Error::handle(&error); + } + + /** + * @brief Destroy the pipeline object + */ + ~Pipeline() noexcept { + ob_error *error = nullptr; + ob_delete_pipeline(impl_, &error); + Error::handle(&error, false); + } + + /** + * @brief Start the pipeline with configuration parameters + * + * @param config The parameter configuration of the pipeline + */ + void start(std::shared_ptr config = nullptr) const { + ob_error *error = nullptr; + ob_config_t *config_impl = config == nullptr ? nullptr : config->getImpl(); + ob_pipeline_start_with_config(impl_, config_impl, &error); + Error::handle(&error); + } + + /** + * @brief Start the pipeline and set the frameset data callback + * + * @param config The configuration of the pipeline + * @param callback The callback to be triggered when all frame data in the frameset arrives + */ + void start(std::shared_ptr config, FrameSetCallback callback) { + callback_ = callback; + ob_error *error = nullptr; + ob_pipeline_start_with_callback(impl_, config ? config->getImpl() : nullptr, &Pipeline::frameSetCallback, this, &error); + Error::handle(&error); + } + + static void frameSetCallback(ob_frame_t *frameSet, void *userData) { + auto pipeline = static_cast(userData); + pipeline->callback_(std::make_shared(frameSet)); + } + + /** + * @brief Stop the pipeline + */ + void stop() const { + ob_error *error = nullptr; + ob_pipeline_stop(impl_, &error); + Error::handle(&error); + } + + /** + * @brief Get the pipeline configuration parameters + * @brief Returns the default configuration if the user has not configured it + * + * @return std::shared_ptr The configured parameters + */ + std::shared_ptr getConfig() const { + ob_error *error = nullptr; + auto config = ob_pipeline_get_config(impl_, &error); + Error::handle(&error); + return std::make_shared(config); + } + + /** + * @brief Wait for frameset + * + * @param timeoutMs The waiting timeout in milliseconds + * @return std::shared_ptr The waiting frameset data + */ + std::shared_ptr waitForFrameset(uint32_t timeoutMs = 1000) const { + ob_error *error = nullptr; + auto frameSet = ob_pipeline_wait_for_frameset(impl_, timeoutMs, &error); + if(frameSet == nullptr) { + return nullptr; + } + Error::handle(&error); + return std::make_shared(frameSet); + } + + /** + * @brief Get the device object + * + * @return std::shared_ptr The device object + */ + std::shared_ptr getDevice() const { + ob_error *error = nullptr; + auto device = ob_pipeline_get_device(impl_, &error); + Error::handle(&error); + return std::make_shared(device); + } + + /** + * @brief Get the stream profile of the specified sensor + * + * @param sensorType The type of sensor + * @return std::shared_ptr The stream profile list + */ + std::shared_ptr getStreamProfileList(OBSensorType sensorType) const { + ob_error *error = nullptr; + auto list = ob_pipeline_get_stream_profile_list(impl_, sensorType, &error); + Error::handle(&error); + return std::make_shared(list); + } + + /** + * @brief Get the stream profile list of supported depth-to-color alignments + * + * @param colorProfile The color stream profile, which is the target stream profile for the depth-to-color alignment. + * @param alignMode The alignment mode. + * + * @attention Currently, only ALIGN_D2C_HW_MODE supported. For other align modes, please using the AlignFilter interface. + * + * @return std::shared_ptr The stream profile list of supported depth-to-color alignments. + */ + std::shared_ptr getD2CDepthProfileList(std::shared_ptr colorProfile, OBAlignMode alignMode) { + ob_error *error = nullptr; + auto list = ob_get_d2c_depth_profile_list(impl_, colorProfile->getImpl(), alignMode, &error); + Error::handle(&error); + return std::make_shared(list); + } + + /** + * @brief Turn on frame synchronization + */ + void enableFrameSync() const { + ob_error *error = nullptr; + ob_pipeline_enable_frame_sync(impl_, &error); + Error::handle(&error); + } + + /** + * @brief Turn off frame synchronization + */ + void disableFrameSync() const { + ob_error *error = nullptr; + ob_pipeline_disable_frame_sync(impl_, &error); + Error::handle(&error); + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + + OBCameraParam getCameraParam() { + ob_error *error = nullptr; + OBCameraParam cameraParam = ob_pipeline_get_camera_param(impl_, &error); + Error::handle(&error); + return cameraParam; + } + + OBCameraParam getCameraParamWithProfile(uint32_t colorWidth, uint32_t colorHeight, uint32_t depthWidth, uint32_t depthHeight) { + ob_error *error = nullptr; + OBCameraParam cameraParam = ob_pipeline_get_camera_param_with_profile(impl_, colorWidth, colorHeight, depthWidth, depthHeight, &error); + Error::handle(&error); + return cameraParam; + } + + OBCalibrationParam getCalibrationParam(std::shared_ptr config) { + ob_error *error = nullptr; + OBCalibrationParam calibrationParam = ob_pipeline_get_calibration_param(impl_, config->getImpl(), &error); + Error::handle(&error); + return calibrationParam; + } + + std::shared_ptr waitForFrames(uint32_t timeoutMs = 1000) const { + return waitForFrameset(timeoutMs); + } +}; + +} // namespace ob diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/RecordPlayback.hpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/RecordPlayback.hpp new file mode 100644 index 0000000..37bea9c --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/RecordPlayback.hpp @@ -0,0 +1,188 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file RecordPlayback.hpp + * @brief Record and playback device-related types, including interfaces to create recording and playback devices, + record and playback streaming data, etc. + */ + +#pragma once + +#include "Types.hpp" +#include "Error.hpp" +#include "libobsensor/h/RecordPlayback.h" +#include "libobsensor/hpp/Device.hpp" + +namespace ob { + +typedef std::function PlaybackStatusChangeCallback; + +class RecordDevice { +private: + ob_record_device_t *impl_; + +public: + explicit RecordDevice(std::shared_ptr device, const std::string &file, bool compressionEnabled = true) { + ob_error *error = nullptr; + impl_ = ob_create_record_device(device->getImpl(), file.c_str(), compressionEnabled, &error); + Error::handle(&error); + } + + virtual ~RecordDevice() noexcept { + ob_error *error = nullptr; + ob_delete_record_device(impl_, &error); + Error::handle(&error, false); + } + + RecordDevice(RecordDevice &&other) { + if(this != &other) { + impl_ = other.impl_; + other.impl_ = nullptr; + } + } + + RecordDevice &operator=(RecordDevice &&other) { + if(this != &other) { + impl_ = other.impl_; + other.impl_ = nullptr; + } + + return *this; + } + + RecordDevice(const RecordDevice &) = delete; + RecordDevice &operator=(const RecordDevice &) = delete; + +public: + void pause() { + ob_error *error = nullptr; + ob_record_device_pause(impl_, &error); + Error::handle(&error); + } + + void resume() { + ob_error *error = nullptr; + ob_record_device_resume(impl_, &error); + Error::handle(&error); + } +}; + +class PlaybackDevice : public Device { +public: + explicit PlaybackDevice(const std::string &file) : Device(nullptr) { + ob_error *error = nullptr; + impl_ = ob_create_playback_device(file.c_str(), &error); + Error::handle(&error); + } + + virtual ~PlaybackDevice() noexcept = default; + + PlaybackDevice(PlaybackDevice &&other) : Device(std::move(other)) {} + + PlaybackDevice &operator=(PlaybackDevice &&other) { + Device::operator=(std::move(other)); + return *this; + } + + PlaybackDevice(const PlaybackDevice &) = delete; + PlaybackDevice &operator=(const PlaybackDevice &) = delete; + +public: + /** + * @brief Pause the streaming data from the playback device. + */ + void pause() { + ob_error *error = nullptr; + ob_playback_device_pause(impl_, &error); + Error::handle(&error); + } + + /** + * @brief Resume the streaming data from the playback device. + */ + void resume() { + ob_error *error = nullptr; + ob_playback_device_resume(impl_, &error); + Error::handle(&error); + } + + /** + * @brief Seek to a specific timestamp when playing back a recording. + * @param[in] timestamp The timestamp to seek to, in milliseconds. + */ + void seek(const int64_t timestamp) { + ob_error *error = nullptr; + ob_playback_device_seek(impl_, timestamp, &error); + Error::handle(&error); + } + + /** + * @brief Set the playback rate of the playback device. + * @param[in] rate The playback rate to set. + */ + void setPlaybackRate(const float rate) { + ob_error *error = nullptr; + ob_playback_device_set_playback_rate(impl_, rate, &error); + Error::handle(&error); + } + + /** + * @brief Set a callback function to be called when the playback status changes. + * @param[in] callback The callback function to set. + */ + void setPlaybackStatusChangeCallback(PlaybackStatusChangeCallback callback) { + callback_ = callback; + ob_error *error = nullptr; + ob_playback_device_set_playback_status_changed_callback(impl_, &PlaybackDevice::playbackStatusCallback, this, &error); + Error::handle(&error); + } + + /** + * @brief Get the current playback status of the playback device. + * @return The current playback status. + */ + OBPlaybackStatus getPlaybackStatus() const { + ob_error *error = nullptr; + OBPlaybackStatus status = ob_playback_device_get_current_playback_status(impl_, &error); + Error::handle(&error); + + return status; + } + + /** + * @brief Get the current position of the playback device. + * @return The current position of the playback device, in milliseconds. + */ + uint64_t getPosition() const { + ob_error *error = nullptr; + uint64_t position = ob_playback_device_get_position(impl_, &error); + Error::handle(&error); + + return position; + } + + /** + * @brief Get the duration of the playback device. + * @return The duration of the playback device, in milliseconds. + */ + uint64_t getDuration() const { + ob_error *error = nullptr; + uint64_t duration = ob_playback_device_get_duration(impl_, &error); + Error::handle(&error); + + return duration; + } + +private: + static void playbackStatusCallback(OBPlaybackStatus status, void *userData) { + auto *playbackDevice = static_cast(userData); + if(playbackDevice && playbackDevice->callback_) { + playbackDevice->callback_(status); + } + } + +private: + PlaybackStatusChangeCallback callback_; +}; +} // namespace ob \ No newline at end of file diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Sensor.hpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Sensor.hpp new file mode 100644 index 0000000..73345f2 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Sensor.hpp @@ -0,0 +1,236 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Sensor.hpp + * @brief Defines types related to sensors, which are used to obtain stream configurations, open and close streams, and set and get sensor properties. + */ +#pragma once + +#include "Types.hpp" +#include "libobsensor/hpp/Filter.hpp" +#include "libobsensor/h/Sensor.h" +#include "libobsensor/h/Filter.h" +#include "Error.hpp" +#include "StreamProfile.hpp" +#include "Device.hpp" +#include "Frame.hpp" +#include +#include +#include + +namespace ob { + +class Sensor { +public: + /** + * @brief Callback function for frame data. + * + * @param frame The frame data. + */ + typedef std::function frame)> FrameCallback; + +protected: + ob_sensor_t *impl_; + FrameCallback callback_; + +public: + explicit Sensor(ob_sensor_t *impl) : impl_(impl) {} + + Sensor(Sensor &&sensor) noexcept : impl_(sensor.impl_) { + sensor.impl_ = nullptr; + } + + Sensor &operator=(Sensor &&sensor) noexcept { + if(this != &sensor) { + ob_error *error = nullptr; + ob_delete_sensor(impl_, &error); + Error::handle(&error); + impl_ = sensor.impl_; + sensor.impl_ = nullptr; + } + return *this; + } + + Sensor(const Sensor &sensor) = delete; + Sensor &operator=(const Sensor &sensor) = delete; + + virtual ~Sensor() noexcept { + ob_error *error = nullptr; + ob_delete_sensor(impl_, &error); + Error::handle(&error, false); + } + + /** + * @brief Get the sensor type. + * + * @return OBSensorType The sensor type. + */ + OBSensorType getType() const { + ob_error *error = nullptr; + auto type = ob_sensor_get_type(impl_, &error); + Error::handle(&error); + return type; + } + + /** + * @brief Get the list of stream profiles. + * + * @return std::shared_ptr The stream profile list. + */ + std::shared_ptr getStreamProfileList() const { + ob_error *error = nullptr; + auto list = ob_sensor_get_stream_profile_list(impl_, &error); + Error::handle(&error); + return std::make_shared(list); + } + + /** + * @brief Create a list of recommended filters for the sensor. + * + * @return OBFilterList list of frame processing block + */ + std::vector> createRecommendedFilters() const { + ob_error *error = nullptr; + auto list = ob_sensor_create_recommended_filter_list(impl_, &error); + Error::handle(&error); + auto filter_count = ob_filter_list_get_count(list, &error); + + std::vector> filters; + for(uint32_t i = 0; i < filter_count; i++) { + auto filterImpl = ob_filter_list_get_filter(list, i, &error); + Error::handle(&error); + filters.push_back(std::make_shared(filterImpl)); + } + ob_delete_filter_list(list, &error); + Error::handle(&error, false); + return filters; + } + + /** + * @brief Open a frame data stream and set up a callback. + * + * @param streamProfile The stream configuration. + * @param callback The callback to set when frame data arrives. + */ + void start(std::shared_ptr streamProfile, FrameCallback callback) { + ob_error *error = nullptr; + callback_ = std::move(callback); + ob_sensor_start(impl_, const_cast(streamProfile->getImpl()), &Sensor::frameCallback, this, &error); + Error::handle(&error); + } + + /** + * @brief Stop the stream. + */ + void stop() const { + ob_error *error = nullptr; + ob_sensor_stop(impl_, &error); + Error::handle(&error); + } + + /** + * @brief Dynamically switch resolutions. + * + * @param streamProfile The resolution to switch to. + */ + void switchProfile(std::shared_ptr streamProfile) { + ob_error *error = nullptr; + ob_sensor_switch_profile(impl_, const_cast(streamProfile->getImpl()), &error); + Error::handle(&error); + } + +private: + static void frameCallback(ob_frame *frame, void *userData) { + auto sensor = static_cast(userData); + sensor->callback_(std::make_shared(frame)); + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + OBSensorType type() const { + return getType(); + } + + std::vector> getRecommendedFilters() const { + return createRecommendedFilters(); + } +}; + +class SensorList { +private: + ob_sensor_list_t *impl_ = nullptr; + +public: + explicit SensorList(ob_sensor_list_t *impl) : impl_(impl) {} + + ~SensorList() noexcept { + ob_error *error = nullptr; + ob_delete_sensor_list(impl_, &error); + Error::handle(&error, false); + } + + /** + * @brief Get the number of sensors. + * + * @return uint32_t The number of sensors. + */ + uint32_t getCount() const { + ob_error *error = nullptr; + auto count = ob_sensor_list_get_count(impl_, &error); + Error::handle(&error); + return count; + } + + /** + * @brief Get the type of the specified sensor. + * + * @param index The sensor index. + * @return OBSensorType The sensor type. + */ + OBSensorType getSensorType(uint32_t index) const { + ob_error *error = nullptr; + auto type = ob_sensor_list_get_sensor_type(impl_, index, &error); + Error::handle(&error); + return type; + } + + /** + * @brief Get a sensor by index number. + * + * @param index The sensor index. The range is [0, count-1]. If the index exceeds the range, an exception will be thrown. + * @return std::shared_ptr The sensor object. + */ + std::shared_ptr getSensor(uint32_t index) const { + ob_error *error = nullptr; + auto sensor = ob_sensor_list_get_sensor(impl_, index, &error); + Error::handle(&error); + return std::make_shared(sensor); + } + + /** + * @brief Get a sensor by sensor type. + * + * @param sensorType The sensor type to obtain. + * @return std::shared_ptr A sensor object. If the specified sensor type does not exist, it will return empty. + */ + std::shared_ptr getSensor(OBSensorType sensorType) const { + ob_error *error = nullptr; + auto sensor = ob_sensor_list_get_sensor_by_type(impl_, sensorType, &error); + Error::handle(&error); + return std::make_shared(sensor); + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + uint32_t count() const { + return getCount(); + } + + OBSensorType type(uint32_t index) const { + return getSensorType(index); + } +}; + +} // namespace ob + diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/StreamProfile.hpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/StreamProfile.hpp new file mode 100644 index 0000000..8452850 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/StreamProfile.hpp @@ -0,0 +1,521 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file StreamProfile.hpp + * @brief The stream profile related type is used to get information such as the width, height, frame rate, and format of the stream. + */ +#pragma once + +#include "Types.hpp" +#include "libobsensor/h/StreamProfile.h" +#include "libobsensor/h/Error.h" +#include +#include + +namespace ob { + +class StreamProfile : public std::enable_shared_from_this { +protected: + const ob_stream_profile_t *impl_ = nullptr; + +public: + StreamProfile(StreamProfile &streamProfile) = delete; + StreamProfile &operator=(StreamProfile &streamProfile) = delete; + + StreamProfile(StreamProfile &&streamProfile) noexcept : impl_(streamProfile.impl_) { + streamProfile.impl_ = nullptr; + } + + StreamProfile &operator=(StreamProfile &&streamProfile) noexcept { + if(this != &streamProfile) { + ob_error *error = nullptr; + ob_delete_stream_profile(impl_, &error); + Error::handle(&error); + impl_ = streamProfile.impl_; + streamProfile.impl_ = nullptr; + } + return *this; + } + + virtual ~StreamProfile() noexcept { + if(impl_) { + ob_error *error = nullptr; + ob_delete_stream_profile(impl_, &error); + Error::handle(&error); + } + } + + const ob_stream_profile *getImpl() const { + return impl_; + } + + /** + * @brief Get the format of the stream. + * + * @return OBFormat return the format of the stream. + */ + OBFormat getFormat() const { + ob_error *error = nullptr; + auto format = ob_stream_profile_get_format(impl_, &error); + Error::handle(&error); + return format; + } + + /** + * @brief Get the type of stream. + * + * @return OBStreamType return the type of the stream. + */ + OBStreamType getType() const { + ob_error *error = nullptr; + auto type = ob_stream_profile_get_type(impl_, &error); + Error::handle(&error); + return type; + } + + /** + * @brief Get the extrinsic parameters from current stream profile to the given target stream profile. + * + * @return OBExtrinsic Return the extrinsic parameters. + */ + OBExtrinsic getExtrinsicTo(std::shared_ptr target) const { + ob_error *error = nullptr; + auto extrinsic = ob_stream_profile_get_extrinsic_to(impl_, const_cast(target->getImpl()), &error); + Error::handle(&error); + return extrinsic; + } + + /** + * @brief Set the extrinsic parameters from current stream profile to the given target stream profile. + * + * @tparam target Target stream profile. + * @tparam extrinsic The extrinsic. + */ + void bindExtrinsicTo(std::shared_ptr target, const OBExtrinsic &extrinsic) { + ob_error *error = nullptr; + ob_stream_profile_set_extrinsic_to(const_cast(impl_), const_cast(target->getImpl()), extrinsic, &error); + Error::handle(&error); + } + + /** + * @brief Set the extrinsic parameters from current stream profile to the given target stream type. + * + * @tparam targetStreamType Target stream type. + * @tparam extrinsic The extrinsic. + */ + void bindExtrinsicTo(const OBStreamType &targetStreamType, const OBExtrinsic &extrinsic) { + ob_error *error = nullptr; + ob_stream_profile_set_extrinsic_to_type(const_cast(impl_),targetStreamType,extrinsic, &error); + Error::handle(&error); + } + + /** + * @brief Check if frame object is compatible with the given type. + * + * @tparam T Given type. + * @return bool return result. + */ + template bool is() const; + + /** + * @brief Converts object type to target type. + * + * @tparam T Target type. + * @return std::shared_ptr Return the result. Throws an exception if conversion is not possible. + */ + template std::shared_ptr as() { + if(!is()) { + throw std::runtime_error("Unsupported operation. Object's type is not the required type."); + } + + return std::dynamic_pointer_cast(shared_from_this()); + } + + /** + * @brief Converts object type to target type (const version). + * + * @tparam T Target type. + * @return std::shared_ptr Return the result. Throws an exception if conversion is not possible. + */ + template std::shared_ptr as() const { + if(!is()) { + throw std::runtime_error("Unsupported operation. Object's type is not the required type."); + } + + return std::static_pointer_cast(shared_from_this()); + } + + // The following interfaces are deprecated and are retained here for compatibility purposes. + OBFormat format() const { + return getFormat(); + } + + OBStreamType type() const { + return getType(); + } + +protected: + explicit StreamProfile(const ob_stream_profile_t *impl) : impl_(impl) {} +}; + +/** + * @brief Class representing a video stream profile. + */ +class VideoStreamProfile : public StreamProfile { +public: + explicit VideoStreamProfile(const ob_stream_profile_t *impl) : StreamProfile(impl) {} + + ~VideoStreamProfile() noexcept override = default; + + /** + * @brief Return the frame rate of the stream. + * + * @return uint32_t Return the frame rate of the stream. + */ + uint32_t getFps() const { + ob_error *error = nullptr; + auto fps = ob_video_stream_profile_get_fps(impl_, &error); + Error::handle(&error); + return fps; + } + + /** + * @brief Return the width of the stream. + * + * @return uint32_t Return the width of the stream. + */ + uint32_t getWidth() const { + ob_error *error = nullptr; + auto width = ob_video_stream_profile_get_width(impl_, &error); + Error::handle(&error); + return width; + } + + /** + * @brief Return the height of the stream. + * + * @return uint32_t Return the height of the stream. + */ + uint32_t getHeight() const { + ob_error *error = nullptr; + auto height = ob_video_stream_profile_get_height(impl_, &error); + Error::handle(&error); + return height; + } + + /** + * @brief Get the intrinsic parameters of the stream. + * + * @return OBCameraIntrinsic Return the intrinsic parameters. + */ + OBCameraIntrinsic getIntrinsic() const { + ob_error *error = nullptr; + auto intrinsic = ob_video_stream_profile_get_intrinsic(impl_, &error); + Error::handle(&error); + return intrinsic; + } + + /** + * @brief Set the intrinsic parameters of the stream. + * + * @param intrinsic The intrinsic parameters. + */ + void setIntrinsic(const OBCameraIntrinsic &intrinsic) { + ob_error *error = nullptr; + ob_video_stream_profile_set_intrinsic(const_cast(impl_), intrinsic, &error); + Error::handle(&error); + } + + /** + * @brief Get the distortion parameters of the stream. + * @brief Brown distortion model + * + * @return OBCameraDistortion Return the distortion parameters. + */ + OBCameraDistortion getDistortion() const { + ob_error *error = nullptr; + auto distortion = ob_video_stream_profile_get_distortion(impl_, &error); + Error::handle(&error); + return distortion; + } + + /** + * @brief Set the distortion parameters of the stream. + * + * @param distortion The distortion parameters. + */ + void setDistortion(const OBCameraDistortion &distortion) { + ob_error *error = nullptr; + ob_video_stream_profile_set_distortion(const_cast(impl_), distortion, &error); + Error::handle(&error); + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + uint32_t fps() const { + return getFps(); + } + + uint32_t width() const { + return getWidth(); + } + + uint32_t height() const { + return getHeight(); + } +}; + +/** + * @brief Class representing an accelerometer stream profile. + */ +class AccelStreamProfile : public StreamProfile { +public: + explicit AccelStreamProfile(const ob_stream_profile_t *impl) : StreamProfile(impl) {} + + ~AccelStreamProfile() noexcept override = default; + + /** + * @brief Return the full scale range. + * + * @return OBAccelFullScaleRange Return the scale range value. + */ + OBAccelFullScaleRange getFullScaleRange() const { + ob_error *error = nullptr; + auto fullScaleRange = ob_accel_stream_profile_get_full_scale_range(impl_, &error); + Error::handle(&error); + return fullScaleRange; + } + + /** + * @brief Return the sampling frequency. + * + * @return OBAccelFullScaleRange Return the sampling frequency. + */ + OBAccelSampleRate getSampleRate() const { + ob_error *error = nullptr; + auto sampleRate = ob_accel_stream_profile_get_sample_rate(impl_, &error); + Error::handle(&error); + return sampleRate; + } + + /** + * @brief get the intrinsic parameters of the stream. + * + * @return OBAccelIntrinsic Return the intrinsic parameters. + */ + OBAccelIntrinsic getIntrinsic() const { + ob_error *error = nullptr; + auto intrinsic = ob_accel_stream_profile_get_intrinsic(impl_, &error); + Error::handle(&error); + return intrinsic; + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + OBAccelFullScaleRange fullScaleRange() const { + return getFullScaleRange(); + } + + OBAccelSampleRate sampleRate() const { + return getSampleRate(); + } +}; + +/** + * @brief Class representing a gyroscope stream profile. + */ +class GyroStreamProfile : public StreamProfile { +public: + explicit GyroStreamProfile(const ob_stream_profile_t *impl) : StreamProfile(impl) {} + + ~GyroStreamProfile() noexcept override = default; + + /** + * @brief Return the full scale range. + * + * @return OBAccelFullScaleRange Return the scale range value. + */ + OBGyroFullScaleRange getFullScaleRange() const { + ob_error *error = nullptr; + auto fullScaleRange = ob_gyro_stream_profile_get_full_scale_range(impl_, &error); + Error::handle(&error); + return fullScaleRange; + } + + /** + * @brief Return the sampling frequency. + * + * @return OBAccelFullScaleRange Return the sampling frequency. + */ + OBGyroSampleRate getSampleRate() const { + ob_error *error = nullptr; + auto sampleRate = ob_gyro_stream_profile_get_sample_rate(impl_, &error); + Error::handle(&error); + return sampleRate; + } + + /** + * @brief get the intrinsic parameters of the stream. + * + * @return OBGyroIntrinsic Return the intrinsic parameters. + */ + OBGyroIntrinsic getIntrinsic() const { + ob_error *error = nullptr; + auto intrinsic = ob_gyro_stream_get_intrinsic(impl_, &error); + Error::handle(&error); + return intrinsic; + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + OBGyroFullScaleRange fullScaleRange() const { + return getFullScaleRange(); + } + + OBGyroSampleRate sampleRate() const { + return getSampleRate(); + } +}; + +template bool StreamProfile::is() const { + switch(this->getType()) { + case OB_STREAM_VIDEO: + case OB_STREAM_IR: + case OB_STREAM_IR_LEFT: + case OB_STREAM_IR_RIGHT: + case OB_STREAM_COLOR: + case OB_STREAM_DEPTH: + case OB_STREAM_RAW_PHASE: + return typeid(T) == typeid(VideoStreamProfile); + case OB_STREAM_ACCEL: + return typeid(T) == typeid(AccelStreamProfile); + case OB_STREAM_GYRO: + return typeid(T) == typeid(GyroStreamProfile); + default: + break; + } + return false; +} + +class StreamProfileFactory { +public: + static std::shared_ptr create(const ob_stream_profile_t *impl) { + ob_error *error = nullptr; + const auto type = ob_stream_profile_get_type(impl, &error); + Error::handle(&error); + switch(type) { + case OB_STREAM_IR: + case OB_STREAM_IR_LEFT: + case OB_STREAM_IR_RIGHT: + case OB_STREAM_DEPTH: + case OB_STREAM_COLOR: + case OB_STREAM_VIDEO: + return std::make_shared(impl); + case OB_STREAM_ACCEL: + return std::make_shared(impl); + case OB_STREAM_GYRO: + return std::make_shared(impl); + default: { + ob_error *err = ob_create_error(OB_STATUS_ERROR, "Unsupported stream type.", "StreamProfileFactory::create", "", OB_EXCEPTION_TYPE_INVALID_VALUE); + Error::handle(&err); + return nullptr; + } + } + } +}; + +class StreamProfileList { +protected: + const ob_stream_profile_list_t *impl_; + +public: + explicit StreamProfileList(ob_stream_profile_list_t *impl) : impl_(impl) {} + ~StreamProfileList() noexcept { + ob_error *error = nullptr; + ob_delete_stream_profile_list(impl_, &error); + Error::handle(&error, false); + } + + /** + * @brief Return the number of StreamProfile objects. + * + * @return uint32_t Return the number of StreamProfile objects. + */ + uint32_t getCount() const { + ob_error *error = nullptr; + auto count = ob_stream_profile_list_get_count(impl_, &error); + Error::handle(&error); + return count; + } + + /** + * @brief Return the StreamProfile object at the specified index. + * + * @param index The index of the StreamProfile object to be retrieved. Must be in the range [0, count-1]. Throws an exception if the index is out of range. + * @return std::shared_ptr Return the StreamProfile object. + */ + std::shared_ptr getProfile(uint32_t index) const { + ob_error *error = nullptr; + auto profile = ob_stream_profile_list_get_profile(impl_, index, &error); + Error::handle(&error); + return StreamProfileFactory::create(profile); + } + + /** + * @brief Match the corresponding video stream profile based on the passed-in parameters. If multiple Match are found, the first one in the list is + * returned by default. Throws an exception if no matching profile is found. + * + * @param width The width of the stream. Pass OB_WIDTH_ANY if no matching condition is required. + * @param height The height of the stream. Pass OB_HEIGHT_ANY if no matching condition is required. + * @param format The type of the stream. Pass OB_FORMAT_ANY if no matching condition is required. + * @param fps The frame rate of the stream. Pass OB_FPS_ANY if no matching condition is required. + * @return std::shared_ptr Return the matching resolution. + */ + std::shared_ptr getVideoStreamProfile(int width = OB_WIDTH_ANY, int height = OB_HEIGHT_ANY, OBFormat format = OB_FORMAT_ANY, + int fps = OB_FPS_ANY) const { + ob_error *error = nullptr; + auto profile = ob_stream_profile_list_get_video_stream_profile(impl_, width, height, format, fps, &error); + Error::handle(&error); + auto vsp = StreamProfileFactory::create(profile); + return vsp->as(); + } + + /** + * @brief Match the corresponding accelerometer stream profile based on the passed-in parameters. If multiple Match are found, the first one in the list + * is returned by default. Throws an exception if no matching profile is found. + * + * @param fullScaleRange The full scale range. Pass 0 if no matching condition is required. + * @param sampleRate The sampling frequency. Pass 0 if no matching condition is required. + */ + std::shared_ptr getAccelStreamProfile(OBAccelFullScaleRange fullScaleRange, OBAccelSampleRate sampleRate) const { + ob_error *error = nullptr; + auto profile = ob_stream_profile_list_get_accel_stream_profile(impl_, fullScaleRange, sampleRate, &error); + Error::handle(&error); + auto asp = StreamProfileFactory::create(profile); + return asp->as(); + } + + /** + * @brief Match the corresponding gyroscope stream profile based on the passed-in parameters. If multiple Match are found, the first one in the list is + * returned by default. Throws an exception if no matching profile is found. + * + * @param fullScaleRange The full scale range. Pass 0 if no matching condition is required. + * @param sampleRate The sampling frequency. Pass 0 if no matching condition is required. + */ + std::shared_ptr getGyroStreamProfile(OBGyroFullScaleRange fullScaleRange, OBGyroSampleRate sampleRate) const { + ob_error *error = nullptr; + auto profile = ob_stream_profile_list_get_gyro_stream_profile(impl_, fullScaleRange, sampleRate, &error); + Error::handle(&error); + auto gsp = StreamProfileFactory::create(profile); + return gsp->as(); + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + uint32_t count() const { + return getCount(); + } +}; + +} // namespace ob diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/TypeHelper.hpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/TypeHelper.hpp new file mode 100644 index 0000000..b35efec --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/TypeHelper.hpp @@ -0,0 +1,143 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +#pragma once + +#include +#include +#include "libobsensor/h/ObTypes.h" +#include "libobsensor/h/TypeHelper.h" + +#include + +namespace ob { +class TypeHelper { +public: + /** + * @brief Convert OBFormat to " string " type and then return. + * + * @param[in] type OBFormat type. + * @return OBFormat of "string" type. + */ + static std::string convertOBFormatTypeToString(const OBFormat &type) { + return ob_format_type_to_string(type); + } + + /** + * @brief Convert OBFrameType to " string " type and then return. + * + * @param[in] type OBFrameType type. + * @return OBFrameType of "string" type. + */ + static std::string convertOBFrameTypeToString(const OBFrameType &type) { + return ob_frame_type_to_string(type); + } + + /** + * @brief Convert OBStreamType to " string " type and then return. + * + * @param[in] type OBStreamType type. + * @return OBStreamType of "string" type. + */ + static std::string convertOBStreamTypeToString(const OBStreamType &type) { + return ob_stream_type_to_string(type); + } + + /** + * @brief Convert OBSensorType to " string " type and then return. + * + * @param[in] type OBSensorType type. + * @return OBSensorType of "string" type. + */ + static std::string convertOBSensorTypeToString(const OBSensorType &type) { + return ob_sensor_type_to_string(type); + } + + /** + * @brief Convert OBIMUSampleRate to " string " type and then return. + * + * @param[in] type OBIMUSampleRate type. + * @return OBIMUSampleRate of "string" type. + */ + static std::string convertOBIMUSampleRateTypeToString(const OBIMUSampleRate &type) { + return ob_imu_rate_type_to_string(type); + } + + /** + * @brief Convert OBGyroFullScaleRange to " string " type and then return. + * + * @param[in] type OBGyroFullScaleRange type. + * @return OBGyroFullScaleRange of "string" type. + */ + static std::string convertOBGyroFullScaleRangeTypeToString(const OBGyroFullScaleRange &type) { + return ob_gyro_range_type_to_string(type); + } + + /** + * @brief Convert OBAccelFullScaleRange to " string " type and then return. + * + * @param[in] type OBAccelFullScaleRange type. + * @return OBAccelFullScaleRange of "string" type. + */ + static std::string convertOBAccelFullScaleRangeTypeToString(const OBAccelFullScaleRange &type) { + return ob_accel_range_type_to_string(type); + } + + /** + * @brief Convert OBFrameMetadataType to " string " type and then return. + * + * @param[in] type OBFrameMetadataType type. + * @return OBFrameMetadataType of "string" type. + */ + static std::string convertOBFrameMetadataTypeToString(const OBFrameMetadataType &type) { + return ob_meta_data_type_to_string(type); + } + + /** + * @brief Convert OBSensorType to OBStreamType type and then return. + * + * @param[in] type OBSensorType type. + * @return OBStreamType type. + */ + static OBStreamType convertSensorTypeToStreamType(OBSensorType type) { + return ob_sensor_type_to_stream_type(type); + } + + /** + * @brief Check if the given sensor type is a video sensor. + * @brief Video sensors are sensors that produce video frames. + * @brief The following sensor types are considered video sensors: + * OB_SENSOR_COLOR, + * OB_SENSOR_DEPTH, + * OB_SENSOR_IR, + * OB_SENSOR_IR_LEFT, + * OB_SENSOR_IR_RIGHT, + * + * @param type The sensor type + * @return true + * @return false + */ + static bool isVideoSensorType(OBSensorType type) { + return ob_is_video_sensor_type(type); + } + + /** + * @brief Check if the given stream type is a video stream. + * @brief Video streams are streams that contain video frames. + * @brief The following stream types are considered video streams: + * OB_STREAM_VIDEO, + * OB_STREAM_DEPTH, + * OB_STREAM_COLOR, + * OB_STREAM_IR, + * OB_STREAM_IR_LEFT, + * OB_STREAM_IR_RIGHT, + * + * @param type The stream type to check. + * @return true if the given stream type is a video stream, false otherwise. + */ + static bool isVideoStreamType(OBStreamType type) { + return ob_is_video_stream_type(type); + } +}; +} // namespace ob + diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Types.hpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Types.hpp new file mode 100644 index 0000000..420f1a0 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Types.hpp @@ -0,0 +1,5 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +#pragma once +#include diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Utils.hpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Utils.hpp new file mode 100644 index 0000000..7a2a8cf --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Utils.hpp @@ -0,0 +1,190 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Utils.hpp + * @brief The SDK utils class + * + */ +#pragma once +#include "libobsensor/h/Utils.h" +#include "Device.hpp" +#include "Types.hpp" +#include "Frame.hpp" + +#include + +namespace ob { +class Device; + +class CoordinateTransformHelper { +public: + /** + * @brief Transform a 3d point of a source coordinate system into a 3d point of the target coordinate system. + * + * @param[in] source_point3f Source 3d point value + * @param[in] extrinsic Transformation matrix from source to target + * @param[out] target_point3f Target 3d point value + * + * @return bool Transform result + */ + static bool transformation3dto3d(const OBPoint3f source_point3f, OBExtrinsic extrinsic, OBPoint3f *target_point3f) { + ob_error *error = NULL; + bool result = ob_transformation_3d_to_3d(source_point3f, extrinsic, target_point3f, &error); + Error::handle(&error); + return result; + } + + /** + * @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into a 3d point of the target coordinate system. + * + * @param[in] source_intrinsic Source intrinsic parameters + * @param[in] source_point2f Source 2d point value + * @param[in] source_depth_pixel_value The depth of sourcePoint2f in millimeters + * @param[in] extrinsic Transformation matrix from source to target + * @param[out] target_point3f Target 3d point value + * + * @return bool Transform result + */ + static bool transformation2dto3d(const OBPoint2f source_point2f, const float source_depth_pixel_value, const OBCameraIntrinsic source_intrinsic, + OBExtrinsic extrinsic, OBPoint3f *target_point3f) { + ob_error *error = NULL; + bool result = ob_transformation_2d_to_3d(source_point2f, source_depth_pixel_value, source_intrinsic, extrinsic, target_point3f, &error); + Error::handle(&error); + return result; + } + + /** + * @brief Transform a 3d point of a source coordinate system into a 2d pixel coordinate of the target camera. + * + * @param[in] source_point3f Source 3d point value + * @param[in] target_intrinsic Target intrinsic parameters + * @param[in] target_distortion Target distortion parameters + * @param[in] extrinsic Transformation matrix from source to target + * @param[out] target_point2f Target 2d point value + * + * @return bool Transform result + */ + static bool transformation3dto2d(const OBPoint3f source_point3f, const OBCameraIntrinsic target_intrinsic, const OBCameraDistortion target_distortion, + OBExtrinsic extrinsic, OBPoint2f *target_point2f) { + ob_error *error = NULL; + bool result = ob_transformation_3d_to_2d(source_point3f, target_intrinsic, target_distortion, extrinsic, target_point2f, &error); + Error::handle(&error); + return result; + } + + /** + * @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into a 2d pixel coordinate of the target camera + * + * @param[in] source_intrinsic Source intrinsic parameters + * @param[in] source_distortion Source distortion parameters + * @param[in] source_point2f Source 2d point value + * @param[in] source_depth_pixel_value The depth of sourcePoint2f in millimeters + * @param[in] target_intrinsic Target intrinsic parameters + * @param[in] target_distortion Target distortion parameters + * @param[in] extrinsic Transformation matrix from source to target + * @param[out] target_point2f Target 2d point value + * + * @return bool Transform result + */ + static bool transformation2dto2d(const OBPoint2f source_point2f, const float source_depth_pixel_value, const OBCameraIntrinsic source_intrinsic, + const OBCameraDistortion source_distortion, const OBCameraIntrinsic target_intrinsic, + const OBCameraDistortion target_distortion, OBExtrinsic extrinsic, OBPoint2f *target_point2f) { + ob_error *error = NULL; + bool result = ob_transformation_2d_to_2d(source_point2f, source_depth_pixel_value, source_intrinsic, source_distortion, target_intrinsic, + target_distortion, extrinsic, target_point2f, &error); + Error::handle(&error); + return result; + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + static bool calibration3dTo3d(const OBCalibrationParam calibrationParam, const OBPoint3f sourcePoint3f, const OBSensorType sourceSensorType, + const OBSensorType targetSensorType, OBPoint3f *targetPoint3f) { + ob_error *error = NULL; + bool result = ob_calibration_3d_to_3d(calibrationParam, sourcePoint3f, sourceSensorType, targetSensorType, targetPoint3f, &error); + Error::handle(&error); + return result; + } + + static bool calibration2dTo3d(const OBCalibrationParam calibrationParam, const OBPoint2f sourcePoint2f, const float sourceDepthPixelValue, + const OBSensorType sourceSensorType, const OBSensorType targetSensorType, OBPoint3f *targetPoint3f) { + ob_error *error = NULL; + bool result = + ob_calibration_2d_to_3d(calibrationParam, sourcePoint2f, sourceDepthPixelValue, sourceSensorType, targetSensorType, targetPoint3f, &error); + Error::handle(&error); + return result; + } + + static bool calibration3dTo2d(const OBCalibrationParam calibrationParam, const OBPoint3f sourcePoint3f, const OBSensorType sourceSensorType, + const OBSensorType targetSensorType, OBPoint2f *targetPoint2f) { + ob_error *error = NULL; + bool result = ob_calibration_3d_to_2d(calibrationParam, sourcePoint3f, sourceSensorType, targetSensorType, targetPoint2f, &error); + Error::handle(&error); + return result; + } + + static bool calibration2dTo2d(const OBCalibrationParam calibrationParam, const OBPoint2f sourcePoint2f, const float sourceDepthPixelValue, + const OBSensorType sourceSensorType, const OBSensorType targetSensorType, OBPoint2f *targetPoint2f) { + ob_error *error = NULL; + bool result = + ob_calibration_2d_to_2d(calibrationParam, sourcePoint2f, sourceDepthPixelValue, sourceSensorType, targetSensorType, targetPoint2f, &error); + Error::handle(&error); + return result; + } + + static std::shared_ptr transformationDepthFrameToColorCamera(std::shared_ptr device, std::shared_ptr depthFrame, + uint32_t targetColorCameraWidth, uint32_t targetColorCameraHeight) { + ob_error *error = NULL; + + // unsafe operation, need to cast const to non-const + auto unConstImpl = const_cast(depthFrame->getImpl()); + + auto result = transformation_depth_frame_to_color_camera(device->getImpl(), unConstImpl, targetColorCameraWidth, targetColorCameraHeight, &error); + Error::handle(&error); + return std::make_shared(result); + } + + static bool transformationInitXYTables(const OBCalibrationParam calibrationParam, const OBSensorType sensorType, float *data, uint32_t *dataSize, + OBXYTables *xyTables) { + ob_error *error = NULL; + bool result = transformation_init_xy_tables(calibrationParam, sensorType, data, dataSize, xyTables, &error); + Error::handle(&error); + return result; + } + + static void transformationDepthToPointCloud(OBXYTables *xyTables, const void *depthImageData, void *pointCloudData) { + ob_error *error = NULL; + transformation_depth_to_pointcloud(xyTables, depthImageData, pointCloudData, &error); + Error::handle(&error, false); + } + + static void transformationDepthToRGBDPointCloud(OBXYTables *xyTables, const void *depthImageData, const void *colorImageData, void *pointCloudData) { + ob_error *error = NULL; + transformation_depth_to_rgbd_pointcloud(xyTables, depthImageData, colorImageData, pointCloudData, &error); + Error::handle(&error, false); + } +}; + +class PointCloudHelper { +public: + /** + * @brief save point cloud to ply file. + * + * @param[in] fileName Point cloud save path + * @param[in] frame Point cloud frame + * @param[in] saveBinary Binary or textual,true: binary, false: textual + * @param[in] useMesh Save mesh or not, true: save as mesh, false: not save as mesh + * @param[in] meshThreshold Distance threshold for creating faces in point cloud,default value :50 + * + * @return bool save point cloud result + */ + static bool savePointcloudToPly(const char *fileName, std::shared_ptr frame, bool saveBinary, bool useMesh, float meshThreshold) { + ob_error *error = NULL; + auto unConstImpl = const_cast(frame->getImpl()); + bool result = ob_save_pointcloud_to_ply(fileName, unConstImpl, saveBinary, useMesh, meshThreshold, &error); + Error::handle(&error, false); + return result; + } +}; +} // namespace ob diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Version.hpp b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Version.hpp new file mode 100644 index 0000000..21b5246 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/include/libobsensor/hpp/Version.hpp @@ -0,0 +1,62 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * @file Version.hpp + * @brief Provides functions to retrieve version information of the SDK. + */ +#pragma once + +#include "libobsensor/h/Version.h" + +namespace ob { +class Version { +public: + /** + * @brief Get the full version number of the SDK. + * @brief The full version number equals to: major * 10000 + minor * 100 + patch + * + * @return int The full version number of the SDK. + */ + static int getVersion() { + return ob_get_version(); + } + /** + * @brief Get the major version number of the SDK. + * + * @return int The major version number of the SDK. + */ + static int getMajor() { + return ob_get_major_version(); + } + + /** + * @brief Get the minor version number of the SDK. + * + * @return int The minor version number of the SDK. + */ + static int getMinor() { + return ob_get_minor_version(); + } + + /** + * @brief Get the patch version number of the SDK. + * + * @return int The patch version number of the SDK. + */ + static int getPatch() { + return ob_get_patch_version(); + } + + /** + * @brief Get the stage version of the SDK. + * @brief The stage version string is a vendor defined string for some special releases. + * + * @return char* The stage version string of the SDK. + */ + static const char *getStageVersion() { + return ob_get_stage_version(); + } +}; +} // namespace ob + diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/OrbbecSDKConfig-release.cmake b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/OrbbecSDKConfig-release.cmake new file mode 100644 index 0000000..5d7a67f --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/OrbbecSDKConfig-release.cmake @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "Release". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "ob::OrbbecSDK" for configuration "Release" +set_property(TARGET ob::OrbbecSDK APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(ob::OrbbecSDK PROPERTIES + IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libOrbbecSDK.so.2.4.3" + IMPORTED_SONAME_RELEASE "libOrbbecSDK.so.2" + ) + +list(APPEND _cmake_import_check_targets ob::OrbbecSDK ) +list(APPEND _cmake_import_check_files_for_ob::OrbbecSDK "${_IMPORT_PREFIX}/lib/libOrbbecSDK.so.2.4.3" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/OrbbecSDKConfig.cmake b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/OrbbecSDKConfig.cmake new file mode 100644 index 0000000..6a35f67 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/OrbbecSDKConfig.cmake @@ -0,0 +1,104 @@ +# Generated by CMake + +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8) + message(FATAL_ERROR "CMake >= 2.8.0 required") +endif() +if(CMAKE_VERSION VERSION_LESS "2.8.3") + message(FATAL_ERROR "CMake >= 2.8.3 required") +endif() +cmake_policy(PUSH) +cmake_policy(VERSION 2.8.3...3.28) +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Protect against multiple inclusion, which would fail when already imported targets are added once more. +set(_cmake_targets_defined "") +set(_cmake_targets_not_defined "") +set(_cmake_expected_targets "") +foreach(_cmake_expected_target IN ITEMS ob::OrbbecSDK) + list(APPEND _cmake_expected_targets "${_cmake_expected_target}") + if(TARGET "${_cmake_expected_target}") + list(APPEND _cmake_targets_defined "${_cmake_expected_target}") + else() + list(APPEND _cmake_targets_not_defined "${_cmake_expected_target}") + endif() +endforeach() +unset(_cmake_expected_target) +if(_cmake_targets_defined STREQUAL _cmake_expected_targets) + unset(_cmake_targets_defined) + unset(_cmake_targets_not_defined) + unset(_cmake_expected_targets) + unset(CMAKE_IMPORT_FILE_VERSION) + cmake_policy(POP) + return() +endif() +if(NOT _cmake_targets_defined STREQUAL "") + string(REPLACE ";" ", " _cmake_targets_defined_text "${_cmake_targets_defined}") + string(REPLACE ";" ", " _cmake_targets_not_defined_text "${_cmake_targets_not_defined}") + message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_cmake_targets_defined_text}\nTargets not yet defined: ${_cmake_targets_not_defined_text}\n") +endif() +unset(_cmake_targets_defined) +unset(_cmake_targets_not_defined) +unset(_cmake_expected_targets) + + +# Compute the installation prefix relative to this file. +get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +if(_IMPORT_PREFIX STREQUAL "/") + set(_IMPORT_PREFIX "") +endif() + +# Create imported target ob::OrbbecSDK +add_library(ob::OrbbecSDK SHARED IMPORTED) + +set_target_properties(ob::OrbbecSDK PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" +) + +# Load information for each installed configuration. +file(GLOB _cmake_config_files "${CMAKE_CURRENT_LIST_DIR}/OrbbecSDKConfig-*.cmake") +foreach(_cmake_config_file IN LISTS _cmake_config_files) + include("${_cmake_config_file}") +endforeach() +unset(_cmake_config_file) +unset(_cmake_config_files) + +# Cleanup temporary variables. +set(_IMPORT_PREFIX) + +# Loop over all imported files and verify that they actually exist +foreach(_cmake_target IN LISTS _cmake_import_check_targets) + if(CMAKE_VERSION VERSION_LESS "3.28" + OR NOT DEFINED _cmake_import_check_xcframework_for_${_cmake_target} + OR NOT IS_DIRECTORY "${_cmake_import_check_xcframework_for_${_cmake_target}}") + foreach(_cmake_file IN LISTS "_cmake_import_check_files_for_${_cmake_target}") + if(NOT EXISTS "${_cmake_file}") + message(FATAL_ERROR "The imported target \"${_cmake_target}\" references the file + \"${_cmake_file}\" +but this file does not exist. Possible reasons include: +* The file was deleted, renamed, or moved to another location. +* An install or uninstall procedure did not complete successfully. +* The installation package was faulty and contained + \"${CMAKE_CURRENT_LIST_FILE}\" +but not all the files it references. +") + endif() + endforeach() + endif() + unset(_cmake_file) + unset("_cmake_import_check_files_for_${_cmake_target}") +endforeach() +unset(_cmake_target) +unset(_cmake_import_check_targets) + +# This file does not depend on other imported targets which have +# been exported from the same project but in a separate export set. + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) +cmake_policy(POP) diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/OrbbecSDKConfig.md b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/OrbbecSDKConfig.md new file mode 100644 index 0000000..4950945 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/OrbbecSDKConfig.md @@ -0,0 +1,210 @@ +# Orbbec SDK Configuration File Introduction (OrbbecSDKConfig_v1.0.xml) + +The Orbbec SDK configuration file is an XML file that defines the global configuration of the Orbbec SDK. + +Upon initialization, the SDK Context will load a configuration file and apply as global configurations. If you have your own configuration file, you can specify it by entering the file path when calling the Context constructor. If you don't provide a path (or input an empty string), the SDK will look for a file named `OrbbecSDKConfig.xml` in the working directory. If neither the specified file nor the default file is found, the SDK will revert to using the built-in default configuration file. + +## Log Configuration + +Log configuration mainly sets the Log level, the Log level output to the console, the Log level output to a file, configures the path for saving Log files, sets the size of each Log file, and sets the number of Log files. + +```cpp + + + + + 0 + + 0 + + 1 + + + + 100 + + 3 + + false + +``` + +## Memory Configuration + +```cpp + + + true + + 2048 + + 10 + + 10 + +``` + +**Notes** + +1. The default size of the memory pool is 2GB (2048MB). +```cpp + 2048 +``` +2. The default number of frame buffere queue in the Pipeline is 10. If the host machine processes slowly, the SDK will buffer up to 10 frames internally, which may affect the delay time in retrieving frames by the user. If the delay is significant, you can reduce the number of buffers. +```cpp + 10 +``` + +3. The default number of queues in the internal processing unit (Processing unit) is 10. If the host machine processes slowly, the SDK will buffer up to 10 frames internally, which may affect the delay time in retrieving frames by the user. If the delay is significant, you can reduce the number of queues. +```cpp + 10 +``` + +## Global Timestamp + +Based on the device's timestamp and considering data transmission delays, the timestamp is converted to the system timestamp dimension through linear regression. It can be used to synchronize timestamps of multiple different devices. The implementation plan is as follows: + +1. Global timestamp fitter: Regularly obtain the device timestamp and the current system timestamp, and calculate the fitting equation parameters using a linear regression method. +2. Global timestamp converter: Convert the data frame timestamp unit to the same unit as the device timestamp, then calculate the overflow times according to the device timestamp to convert to a 64-bit timestamp, and then convert to a global timestamp according to the fitting parameters output by the global timestamp fitter. + +```cpp + + true + + 1000 + + 100 + +``` + +1. By default, the device time is obtained every eight seconds to update the global timestamp fitter. +```cpp + 1000 +``` + +2. The default queue size of the global timestamp fitter is 10. +```cpp + 100 +``` + +**Notes** + +1. The global timestamp mainly supports the Gemini 330 series. Gemini 2, Gemini 2L, Femto Mega, and Femto Bolt are also supported but not thoroughly tested. If there are stability issues with these devices, the global timestamp function can be turned off. +```cpp + false +``` + +## Pipeline Configuration + +```cpp + + + + + + true + + + true + + + + +``` + +1. Pipeline primarily sets which video streams to enable. By default, only Depth and Color streams are enabled. You can add to enable IR streams, left IR, and right IR as follows. +```cpp + + + true + + + true + + + true + +``` + +## Device Configuration + +```cpp + + + true + + LibUVC + + + + + 0 + + + + 0 + + 5000 + + 0 + + 2000 + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + +``` + +1. Set whether to enumerate network devices. Femto Mega and Gemini 2 XL support network functions. If you need to use the network functions of these two devices, you can set this to true. +```cpp + true +``` + +2. Set whether to use LibUVC or V4L2 to receive data on Linux or ARM. V4L2 is not supported by all devices, and we recommend using LibUVC. The Gemini 330 series devices support V4L2, but kernel patches are needed to obtain Metadata data. +```cpp + LibUVC +``` + +3. Set the resolution, frame rate, and data format. \ No newline at end of file diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/OrbbecSDKConfig.xml b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/OrbbecSDKConfig.xml new file mode 100644 index 0000000..177794c --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/OrbbecSDKConfig.xml @@ -0,0 +1,2332 @@ + + + + 1.1 + + + + + 5 + + 3 + + + + 100 + + 3 + + false + + + + + true + + 2048 + + 10 + + 10 + + + + + + + + true + + + true + + false + + 1920 + + 1080 + + 30 + + MJPG + ]]> + + + + + + + + + true + + + Auto + + + + V4L2 + + + false + + 1000 + + 100 + + + + + 640 + + 576 + + 30 + + Y16 + + + + + 1920 + + 1080 + + 30 + + MJPG + + + + + 640 + + 576 + + 30 + + Y16 + + + + + + false + + 1000 + + 100 + + + + + 640 + + 576 + + 30 + + Y16 + + + + + 1920 + + 1080 + + 30 + + MJPG + + + + + 640 + + 576 + + 30 + + Y16 + + + + + + LibUVC + + + false + + 1000 + + 100 + + + + + 640 + + 576 + + 30 + + Y16 + + + + + 1920 + + 1080 + + 30 + + MJPG + + + + + 640 + + 576 + + 30 + + Y16 + + + + + + + LibUVC + + + false + + 1000 + + 100 + + + + 0 + + + 1280 + + 800 + + 30 + RLE + + + + 1280 + + 720 + + 30 + MJPG + + + + 1280 + + 800 + + 30 + Y8 + + + + 1280 + + 800 + + 30 + Y8 + + + + 1280 + + 800 + + 30 + Y8 + + + + + + + + + + + + + + + + 640 + + 400 + + 30 + RLE + + + + 640 + + 400 + + 30 + Y8 + + + + + + + 640 + + 400 + + 15 + RLE + + + + + + 1920 + + 1080 + + 30 + MJPG + + + + 1280 + + 800 + + 30 + Y10 + + + + 1280 + + 800 + + 30 + Y10 + + + + + + + 1920 + + 1080 + + 30 + MJPG + + + + 1280 + + 800 + + 30 + Y8 + + + + 1280 + + 800 + + 30 + Y8 + + + + + + + + LibUVC + + + false + + 1000 + + 100 + + + + 0 + + + + 1280 + + 800 + + 30 + RLE + + + + 1280 + + 720 + + 30 + + MJPG + + + + 1280 + + 800 + + 30 + + Y8 + + + + 1280 + + 800 + + 30 + Y8 + + + + 1280 + + 800 + + 30 + Y8 + + + + + + + 640 + + 400 + + 30 + RLE + + + + 640 + + 400 + + 30 + Y8 + + + + + + 1920 + + 1080 + + 30 + MJPG + + + + 1280 + + 800 + + 30 + Y10 + + + + 1280 + + 800 + + 30 + Y10 + + + + + + + 1920 + + 1080 + + 30 + MJPG + + + + 1280 + + 800 + + 30 + Y8 + + + + 1280 + + 800 + + 30 + Y8 + + + + + + + + LibUVC + + + false + + 1000 + + 100 + + + + 0 + + + + + + 800 + + 600 + + 30 + RLE + + + + 1280 + + 720 + + 30 + MJPG + + + + 800 + + 600 + + 30 + Y8 + + + + + + 1600 + + 1200 + + 30 + RLE + + + + 1280 + + 720 + + 30 + MJPG + + + + 800 + + 600 + + 30 + Y8 + + + + + + 640 + + 480 + + 30 + RLE + + + + 1280 + + 720 + + 30 + MJPG + + + + 640 + + 480 + + 30 + Y8 + + + + + + + + LibUVC + + + false + + 1000 + + 100 + + + + 0 + + + + 1280 + + 800 + + 10 + RVL + + + + 1280 + + 800 + + 10 + MJPG + + + + 1280 + + 800 + + 10 + Y8 + + + + 1280 + + 800 + + 10 + Y8 + + + + + + + + + + + 1280 + + 800 + + 20 + MJPG + + + + 640 + + 400 + + 20 + RVL + + + + 640 + + 400 + + 20 + Y8 + + + + 640 + + 400 + + 20 + Y8 + + + + + + 1280 + + 800 + + 10 + MJPG + + + + 1280 + + 800 + + 10 + Y10 + + + + 1280 + + 800 + + 10 + Y10 + + + + + + 1280 + + 800 + + 10 + MJPG + + + + 1280 + + 800 + + 10 + Y8 + + + + 1280 + + 800 + + 10 + Y8 + + + + + + + + LibUVC + + + true + + 1000 + + 100 + + + + false + true + + + + 0 + + 1 + + + + + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + + LibUVC + + + true + + 1000 + + 100 + + + + false + true + + + + 0 + + 1 + + + + + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + LibUVC + + + true + + 1000 + + 100 + + + + false + true + + + + 0 + + 1 + + + + + + 0 + + 5000 + + 0 + + 2000 + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + + LibUVC + + + true + + 1000 + + 100 + + + + false + true + + + + 0 + + 1 + + + + + + 0 + + 5000 + + 0 + + 2000 + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + + LibUVC + + + true + + 1000 + + 100 + + + + false + true + + + + 0 + + 1 + + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + + 0 + + 1 + + + true + + 1000 + + 100 + + + + false + true + + + + 0 + + 1 + + + + + + 640 + + 400 + + 15 + Y16 + + + + 640 + + 400 + + 15 + MJPG + + + + 640 + + 400 + + 15 + Y8 + + + + 640 + + 400 + + 15 + Y8 + + + + + + + LibUVC + + + false + true + + + + true + + 1000 + + 100 + + + + 0 + + 1 + + + + + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + + LibUVC + + + false + true + + + + true + + 1000 + + 100 + + + + 0 + + 1 + + + + + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + + LibUVC + + + true + + 1000 + + 100 + + + + false + true + + + + 0 + + 1 + + + + 640 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 640 + + 480 + + 30 + Y8 + + + + 640 + + 480 + + 30 + Y8 + + + + 640 + + 480 + + 30 + Y8 + + + + + + LibUVC + + + true + + 1000 + + 100 + + + false + true + + + + 0 + + 1 + + + + 640 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 640 + + 480 + + 30 + Y8 + + + + 640 + + 480 + + 30 + Y8 + + + + 640 + + 480 + + 30 + Y8 + + + + + + + LibUVC + + + true + + 1000 + + 100 + + + false + true + + + + 0 + + 1 + + + + 640 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 640 + + 480 + + 30 + Y8 + + + + 640 + + 480 + + 30 + Y8 + + + + 640 + + 480 + + 30 + Y8 + + + + + + LibUVC + + + true + + 1000 + + 100 + + + false + true + + + + 0 + + 1 + + + + 640 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 640 + + 480 + + 30 + Y8 + + + + 640 + + 480 + + 30 + Y8 + + + + 640 + + 480 + + 30 + Y8 + + + + + + LibUVC + + + false + + 1000 + + 100 + + + + 0 + + + + 1280 + + 800 + + 15 + Y16 + + + + 1280 + + 720 + + 15 + + MJPG + + + + 1280 + + 800 + + 15 + + Y8 + + + + + + LibUVC + + + false + + 1000 + + 100 + + + + 0 + + + + 1280 + + 800 + + 15 + Y16 + + + + 1280 + + 720 + + 15 + + MJPG + + + + 1280 + + 800 + + 15 + + Y8 + + + + + + + LibUVC + + + false + true + + + + true + + 1000 + + 100 + + + + 0 + + 1 + + + + + + 0 + + 5000 + + 0 + + 2000 + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + + LibUVC + + + false + true + + + + true + + 1000 + + 100 + + + + 0 + + 1 + + + + + + 0 + + 5000 + + 0 + + 2000 + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + + LibUVC + + + 0 + + + 1.2 + + + + 15 + + 5000 + + 3000 + + 1280 + + 800 + + 10 + RVL + + + + 1280 + + 800 + + 10 + MJPG + + 15 + + 5000 + + 3000 + + + + 1280 + + 800 + + 10 + Y8 + + 15 + + 5000 + + 3000 + + + + 1280 + + 800 + + 10 + Y8 + + 15 + + 5000 + + 3000 + + + + + 0 + + 5000 + + 3000 + + + + 0 + + 5000 + + 3000 + + + + + + + 1280 + + 800 + + 20 + MJPG + + 0 + + 5 + + 5000 + + + + 640 + + 400 + + 20 + RVL + + 0 + + 5 + + 5000 + + + + 640 + + 400 + + 20 + Y8 + + 0 + + 5 + + 5000 + + + + 640 + + 400 + + 20 + Y8 + + 0 + + 5 + + 5000 + + + + + + 1280 + + 800 + + 10 + MJPG + + 0 + + 5 + + 5000 + + + + 1280 + + 800 + + 10 + Y10 + + 0 + + 5 + + 5000 + + + + 1280 + + 800 + + 10 + Y10 + + 0 + + 5 + + 5000 + + + + + + 1280 + + 800 + + 10 + MJPG + + 0 + + 5 + + 5000 + + + + 1280 + + 800 + + 10 + Y8 + + 0 + + 5 + + 5000 + + + + 1280 + + 800 + + 10 + Y8 + + 0 + + 5 + + 5000 + + + + + \ No newline at end of file diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/depthengine/libdepthengine.so b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/depthengine/libdepthengine.so new file mode 120000 index 0000000..745a98a --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/depthengine/libdepthengine.so @@ -0,0 +1 @@ +libdepthengine.so.2.0 \ No newline at end of file diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/depthengine/libdepthengine.so.2.0 b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/depthengine/libdepthengine.so.2.0 new file mode 100644 index 0000000..61c3e38 Binary files /dev/null and b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/depthengine/libdepthengine.so.2.0 differ diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/filters/libFilterProcessor.so b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/filters/libFilterProcessor.so new file mode 100644 index 0000000..f04e267 Binary files /dev/null and b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/filters/libFilterProcessor.so differ diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/filters/libob_priv_filter.so b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/filters/libob_priv_filter.so new file mode 100644 index 0000000..a0466da Binary files /dev/null and b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/filters/libob_priv_filter.so differ diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/firmwareupdater/libfirmwareupdater.so b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/firmwareupdater/libfirmwareupdater.so new file mode 100644 index 0000000..d76f36c Binary files /dev/null and b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/firmwareupdater/libfirmwareupdater.so differ diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/frameprocessor/libob_frame_processor.so b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/frameprocessor/libob_frame_processor.so new file mode 100644 index 0000000..cc13222 Binary files /dev/null and b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/extensions/frameprocessor/libob_frame_processor.so differ diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/libOrbbecSDK.so b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/libOrbbecSDK.so new file mode 120000 index 0000000..1e0e3c3 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/libOrbbecSDK.so @@ -0,0 +1 @@ +libOrbbecSDK.so.2 \ No newline at end of file diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/libOrbbecSDK.so.2 b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/libOrbbecSDK.so.2 new file mode 120000 index 0000000..06dfc7a --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/libOrbbecSDK.so.2 @@ -0,0 +1 @@ +libOrbbecSDK.so.2.4.3 \ No newline at end of file diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/libOrbbecSDK.so.2.4.3 b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/libOrbbecSDK.so.2.4.3 new file mode 100644 index 0000000..3bd9805 Binary files /dev/null and b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/lib/libOrbbecSDK.so.2.4.3 differ diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/setup.sh b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/setup.sh new file mode 100755 index 0000000..a8b4084 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/setup.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Copyright (c) Orbbec Inc. All Rights Reserved. +# Licensed under the MIT License. + +# restore current directory +current_dir=$(pwd) + +# cd to the directory where this script is located +cd "$(dirname "$0")" +project_dir=$(pwd) + +# set up environment variables +shared_dir=$project_dir/shared +examples_dir=$project_dir/examples + +# build the examples +if [ -d "$examples_dir" ] && [ -f "$project_dir/build_examples.sh" ]; then + $project_dir/build_examples.sh +fi + +# install udev rules +if [ -d "$shared_dir" ] && [ -f "$shared_dir/install_udev_rules.sh" ]; then + $shared_dir/install_udev_rules.sh +fi + +cd $current_dir diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/shared/99-obsensor-libusb.rules b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/shared/99-obsensor-libusb.rules new file mode 100644 index 0000000..f999f3f --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/shared/99-obsensor-libusb.rules @@ -0,0 +1,119 @@ +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0501", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Bootloader Device" + +# UVC Modules +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0635", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Femto" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0638", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Femto-w" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0668", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Femto-live" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0636", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Astra+" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0637", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Astra+s" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0536", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Astra+_rgb" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0537", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Astra+s_rgb" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0669", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Femto-mega" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="066b", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Femto Bolt" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0660", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Astra 2" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0670", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 2" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0671", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 2 XL" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0673", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 2 L" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0675", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 2 VL" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0800", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 335" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0801", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 330" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0802", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini dm330" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0803", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 336" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0804", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 335L" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0805", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 330L" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0806", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini dm330L" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0807", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 336L" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="080b", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 335Lg" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="080d", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 336Lg" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="080e", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 335Le" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0810", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 336Le" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0674", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 2 I" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0701", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Dabai DCL" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="069d", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Astra Pro2" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0808", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 215" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0809", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 210" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0a12", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Dabai A" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0a13", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Dabai AL" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0812", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 345" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0813", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="Gemini 345Lg" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0816", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="CAM-5330" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="2bc5", ATTRS{idProduct}=="0817", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="CAM-5530" + +# OpenNI Modules +SUBSYSTEM=="usb", ATTR{idProduct}=="0401", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra" +SUBSYSTEM=="usb", ATTR{idProduct}=="0402", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra_s" +SUBSYSTEM=="usb", ATTR{idProduct}=="0403", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra_pro" +SUBSYSTEM=="usb", ATTR{idProduct}=="0404", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra_mini" +SUBSYSTEM=="usb", ATTR{idProduct}=="0407", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra_mini_s" +SUBSYSTEM=="usb", ATTR{idProduct}=="0601", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra_NH_GLST" +SUBSYSTEM=="usb", ATTR{idProduct}=="060b", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="deeyea" +SUBSYSTEM=="usb", ATTR{idProduct}=="050b", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="deeyea_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="060e", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="petrel" +SUBSYSTEM=="usb", ATTR{idProduct}=="050e", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="petrel_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="060f", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astro_pro_plus" +SUBSYSTEM=="usb", ATTR{idProduct}=="050f", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astro_pro_plus_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="0610", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="bus_cl" +SUBSYSTEM=="usb", ATTR{idProduct}=="0603", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="atlas" +SUBSYSTEM=="usb", ATTR{idProduct}=="0510", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="atlas_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="0614", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="gemini" +SUBSYSTEM=="usb", ATTR{idProduct}=="0511", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="gemini_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="0616", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="u1s" +SUBSYSTEM=="usb", ATTR{idProduct}=="0516", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="u1s_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="0617", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="projector" +SUBSYSTEM=="usb", ATTR{idProduct}=="0517", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="projector_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="0618", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="butterfly" +SUBSYSTEM=="usb", ATTR{idProduct}=="0518", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="butterfly_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="061b", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="pavo" +SUBSYSTEM=="usb", ATTR{idProduct}=="051b", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="pavo_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="062b", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="petrel_pro" +SUBSYSTEM=="usb", ATTR{idProduct}=="052b", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="petrel_pro_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="062c", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="petrel_plus" +SUBSYSTEM=="usb", ATTR{idProduct}=="052c", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="petrel_plus_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="062d", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="pictor" +SUBSYSTEM=="usb", ATTR{idProduct}=="0632", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra+" +SUBSYSTEM=="usb", ATTR{idProduct}=="0532", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra+rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="0633", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra+s" +SUBSYSTEM=="usb", ATTR{idProduct}=="0533", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra+s_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="0634", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_petal_b" +SUBSYSTEM=="usb", ATTR{idProduct}=="0534", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_petal_b_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="0635", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="femto" +SUBSYSTEM=="usb", ATTR{idProduct}=="0636", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="jarvis" +SUBSYSTEM=="usb", ATTR{idProduct}=="0536", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="jarvis_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="0637", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="jarvis+s" +SUBSYSTEM=="usb", ATTR{idProduct}=="0537", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="jarvis+s_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="0638", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="femto_w" +SUBSYSTEM=="usb", ATTR{idProduct}=="0639", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="argus" +SUBSYSTEM=="usb", ATTR{idProduct}=="0539", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="argus_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="063a", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="u2" +SUBSYSTEM=="usb", ATTR{idProduct}=="0650", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="0651", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="0654", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="qi_long_zhu" +SUBSYSTEM=="usb", ATTR{idProduct}=="0554", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="qi_long_zhu_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="0655", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_plus" +SUBSYSTEM=="usb", ATTR{idProduct}=="0656", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_mini" +SUBSYSTEM=="usb", ATTR{idProduct}=="0657", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_dc1" +SUBSYSTEM=="usb", ATTR{idProduct}=="0557", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_dc1_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="0658", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_d1" +SUBSYSTEM=="usb", ATTR{idProduct}=="0657", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_dc1" +SUBSYSTEM=="usb", ATTR{idProduct}=="0557", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_dc1_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="0659", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_dcw" +SUBSYSTEM=="usb", ATTR{idProduct}=="0559", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_dcw_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="065a", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_dw" +SUBSYSTEM=="usb", ATTR{idProduct}=="065b", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra_mini_pro" +SUBSYSTEM=="usb", ATTR{idProduct}=="065c", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="gemini_e" +SUBSYSTEM=="usb", ATTR{idProduct}=="055c", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="gemini_e_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="065d", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="gemini_e_lite" +SUBSYSTEM=="usb", ATTR{idProduct}=="065e", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra_mini_s_pro" +SUBSYSTEM=="usb", ATTR{idProduct}=="0698", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="j1" +SUBSYSTEM=="usb", ATTR{idProduct}=="069c", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="TB2201" +SUBSYSTEM=="usb", ATTR{idProduct}=="06a0", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_dcw2" +SUBSYSTEM=="usb", ATTR{idProduct}=="0561", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_dcw2_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="069f", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_dw2" +SUBSYSTEM=="usb", ATTR{idProduct}=="069a", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_max" +SUBSYSTEM=="usb", ATTR{idProduct}=="069e", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_max_pro" +SUBSYSTEM=="usb", ATTR{idProduct}=="0560", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_max_pro_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="06aa", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_gemini_uw" +SUBSYSTEM=="usb", ATTR{idProduct}=="05aa", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="dabai_gemini_uw_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="06a6", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="gemini_ew" +SUBSYSTEM=="usb", ATTR{idProduct}=="05a6", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="gemini_ew_rgb" +SUBSYSTEM=="usb", ATTR{idProduct}=="06a7", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="gemini_ew_lite" diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/shared/OrbbecSDKConfig.md b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/shared/OrbbecSDKConfig.md new file mode 100644 index 0000000..4950945 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/shared/OrbbecSDKConfig.md @@ -0,0 +1,210 @@ +# Orbbec SDK Configuration File Introduction (OrbbecSDKConfig_v1.0.xml) + +The Orbbec SDK configuration file is an XML file that defines the global configuration of the Orbbec SDK. + +Upon initialization, the SDK Context will load a configuration file and apply as global configurations. If you have your own configuration file, you can specify it by entering the file path when calling the Context constructor. If you don't provide a path (or input an empty string), the SDK will look for a file named `OrbbecSDKConfig.xml` in the working directory. If neither the specified file nor the default file is found, the SDK will revert to using the built-in default configuration file. + +## Log Configuration + +Log configuration mainly sets the Log level, the Log level output to the console, the Log level output to a file, configures the path for saving Log files, sets the size of each Log file, and sets the number of Log files. + +```cpp + + + + + 0 + + 0 + + 1 + + + + 100 + + 3 + + false + +``` + +## Memory Configuration + +```cpp + + + true + + 2048 + + 10 + + 10 + +``` + +**Notes** + +1. The default size of the memory pool is 2GB (2048MB). +```cpp + 2048 +``` +2. The default number of frame buffere queue in the Pipeline is 10. If the host machine processes slowly, the SDK will buffer up to 10 frames internally, which may affect the delay time in retrieving frames by the user. If the delay is significant, you can reduce the number of buffers. +```cpp + 10 +``` + +3. The default number of queues in the internal processing unit (Processing unit) is 10. If the host machine processes slowly, the SDK will buffer up to 10 frames internally, which may affect the delay time in retrieving frames by the user. If the delay is significant, you can reduce the number of queues. +```cpp + 10 +``` + +## Global Timestamp + +Based on the device's timestamp and considering data transmission delays, the timestamp is converted to the system timestamp dimension through linear regression. It can be used to synchronize timestamps of multiple different devices. The implementation plan is as follows: + +1. Global timestamp fitter: Regularly obtain the device timestamp and the current system timestamp, and calculate the fitting equation parameters using a linear regression method. +2. Global timestamp converter: Convert the data frame timestamp unit to the same unit as the device timestamp, then calculate the overflow times according to the device timestamp to convert to a 64-bit timestamp, and then convert to a global timestamp according to the fitting parameters output by the global timestamp fitter. + +```cpp + + true + + 1000 + + 100 + +``` + +1. By default, the device time is obtained every eight seconds to update the global timestamp fitter. +```cpp + 1000 +``` + +2. The default queue size of the global timestamp fitter is 10. +```cpp + 100 +``` + +**Notes** + +1. The global timestamp mainly supports the Gemini 330 series. Gemini 2, Gemini 2L, Femto Mega, and Femto Bolt are also supported but not thoroughly tested. If there are stability issues with these devices, the global timestamp function can be turned off. +```cpp + false +``` + +## Pipeline Configuration + +```cpp + + + + + + true + + + true + + + + +``` + +1. Pipeline primarily sets which video streams to enable. By default, only Depth and Color streams are enabled. You can add to enable IR streams, left IR, and right IR as follows. +```cpp + + + true + + + true + + + true + +``` + +## Device Configuration + +```cpp + + + true + + LibUVC + + + + + 0 + + + + 0 + + 5000 + + 0 + + 2000 + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + +``` + +1. Set whether to enumerate network devices. Femto Mega and Gemini 2 XL support network functions. If you need to use the network functions of these two devices, you can set this to true. +```cpp + true +``` + +2. Set whether to use LibUVC or V4L2 to receive data on Linux or ARM. V4L2 is not supported by all devices, and we recommend using LibUVC. The Gemini 330 series devices support V4L2, but kernel patches are needed to obtain Metadata data. +```cpp + LibUVC +``` + +3. Set the resolution, frame rate, and data format. \ No newline at end of file diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/shared/OrbbecSDKConfig.xml b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/shared/OrbbecSDKConfig.xml new file mode 100644 index 0000000..177794c --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/shared/OrbbecSDKConfig.xml @@ -0,0 +1,2332 @@ + + + + 1.1 + + + + + 5 + + 3 + + + + 100 + + 3 + + false + + + + + true + + 2048 + + 10 + + 10 + + + + + + + + true + + + true + + false + + 1920 + + 1080 + + 30 + + MJPG + ]]> + + + + + + + + + true + + + Auto + + + + V4L2 + + + false + + 1000 + + 100 + + + + + 640 + + 576 + + 30 + + Y16 + + + + + 1920 + + 1080 + + 30 + + MJPG + + + + + 640 + + 576 + + 30 + + Y16 + + + + + + false + + 1000 + + 100 + + + + + 640 + + 576 + + 30 + + Y16 + + + + + 1920 + + 1080 + + 30 + + MJPG + + + + + 640 + + 576 + + 30 + + Y16 + + + + + + LibUVC + + + false + + 1000 + + 100 + + + + + 640 + + 576 + + 30 + + Y16 + + + + + 1920 + + 1080 + + 30 + + MJPG + + + + + 640 + + 576 + + 30 + + Y16 + + + + + + + LibUVC + + + false + + 1000 + + 100 + + + + 0 + + + 1280 + + 800 + + 30 + RLE + + + + 1280 + + 720 + + 30 + MJPG + + + + 1280 + + 800 + + 30 + Y8 + + + + 1280 + + 800 + + 30 + Y8 + + + + 1280 + + 800 + + 30 + Y8 + + + + + + + + + + + + + + + + 640 + + 400 + + 30 + RLE + + + + 640 + + 400 + + 30 + Y8 + + + + + + + 640 + + 400 + + 15 + RLE + + + + + + 1920 + + 1080 + + 30 + MJPG + + + + 1280 + + 800 + + 30 + Y10 + + + + 1280 + + 800 + + 30 + Y10 + + + + + + + 1920 + + 1080 + + 30 + MJPG + + + + 1280 + + 800 + + 30 + Y8 + + + + 1280 + + 800 + + 30 + Y8 + + + + + + + + LibUVC + + + false + + 1000 + + 100 + + + + 0 + + + + 1280 + + 800 + + 30 + RLE + + + + 1280 + + 720 + + 30 + + MJPG + + + + 1280 + + 800 + + 30 + + Y8 + + + + 1280 + + 800 + + 30 + Y8 + + + + 1280 + + 800 + + 30 + Y8 + + + + + + + 640 + + 400 + + 30 + RLE + + + + 640 + + 400 + + 30 + Y8 + + + + + + 1920 + + 1080 + + 30 + MJPG + + + + 1280 + + 800 + + 30 + Y10 + + + + 1280 + + 800 + + 30 + Y10 + + + + + + + 1920 + + 1080 + + 30 + MJPG + + + + 1280 + + 800 + + 30 + Y8 + + + + 1280 + + 800 + + 30 + Y8 + + + + + + + + LibUVC + + + false + + 1000 + + 100 + + + + 0 + + + + + + 800 + + 600 + + 30 + RLE + + + + 1280 + + 720 + + 30 + MJPG + + + + 800 + + 600 + + 30 + Y8 + + + + + + 1600 + + 1200 + + 30 + RLE + + + + 1280 + + 720 + + 30 + MJPG + + + + 800 + + 600 + + 30 + Y8 + + + + + + 640 + + 480 + + 30 + RLE + + + + 1280 + + 720 + + 30 + MJPG + + + + 640 + + 480 + + 30 + Y8 + + + + + + + + LibUVC + + + false + + 1000 + + 100 + + + + 0 + + + + 1280 + + 800 + + 10 + RVL + + + + 1280 + + 800 + + 10 + MJPG + + + + 1280 + + 800 + + 10 + Y8 + + + + 1280 + + 800 + + 10 + Y8 + + + + + + + + + + + 1280 + + 800 + + 20 + MJPG + + + + 640 + + 400 + + 20 + RVL + + + + 640 + + 400 + + 20 + Y8 + + + + 640 + + 400 + + 20 + Y8 + + + + + + 1280 + + 800 + + 10 + MJPG + + + + 1280 + + 800 + + 10 + Y10 + + + + 1280 + + 800 + + 10 + Y10 + + + + + + 1280 + + 800 + + 10 + MJPG + + + + 1280 + + 800 + + 10 + Y8 + + + + 1280 + + 800 + + 10 + Y8 + + + + + + + + LibUVC + + + true + + 1000 + + 100 + + + + false + true + + + + 0 + + 1 + + + + + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + + LibUVC + + + true + + 1000 + + 100 + + + + false + true + + + + 0 + + 1 + + + + + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + LibUVC + + + true + + 1000 + + 100 + + + + false + true + + + + 0 + + 1 + + + + + + 0 + + 5000 + + 0 + + 2000 + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + + LibUVC + + + true + + 1000 + + 100 + + + + false + true + + + + 0 + + 1 + + + + + + 0 + + 5000 + + 0 + + 2000 + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + + LibUVC + + + true + + 1000 + + 100 + + + + false + true + + + + 0 + + 1 + + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + + 0 + + 1 + + + true + + 1000 + + 100 + + + + false + true + + + + 0 + + 1 + + + + + + 640 + + 400 + + 15 + Y16 + + + + 640 + + 400 + + 15 + MJPG + + + + 640 + + 400 + + 15 + Y8 + + + + 640 + + 400 + + 15 + Y8 + + + + + + + LibUVC + + + false + true + + + + true + + 1000 + + 100 + + + + 0 + + 1 + + + + + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + + LibUVC + + + false + true + + + + true + + 1000 + + 100 + + + + 0 + + 1 + + + + + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + + LibUVC + + + true + + 1000 + + 100 + + + + false + true + + + + 0 + + 1 + + + + 640 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 640 + + 480 + + 30 + Y8 + + + + 640 + + 480 + + 30 + Y8 + + + + 640 + + 480 + + 30 + Y8 + + + + + + LibUVC + + + true + + 1000 + + 100 + + + false + true + + + + 0 + + 1 + + + + 640 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 640 + + 480 + + 30 + Y8 + + + + 640 + + 480 + + 30 + Y8 + + + + 640 + + 480 + + 30 + Y8 + + + + + + + LibUVC + + + true + + 1000 + + 100 + + + false + true + + + + 0 + + 1 + + + + 640 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 640 + + 480 + + 30 + Y8 + + + + 640 + + 480 + + 30 + Y8 + + + + 640 + + 480 + + 30 + Y8 + + + + + + LibUVC + + + true + + 1000 + + 100 + + + false + true + + + + 0 + + 1 + + + + 640 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 640 + + 480 + + 30 + Y8 + + + + 640 + + 480 + + 30 + Y8 + + + + 640 + + 480 + + 30 + Y8 + + + + + + LibUVC + + + false + + 1000 + + 100 + + + + 0 + + + + 1280 + + 800 + + 15 + Y16 + + + + 1280 + + 720 + + 15 + + MJPG + + + + 1280 + + 800 + + 15 + + Y8 + + + + + + LibUVC + + + false + + 1000 + + 100 + + + + 0 + + + + 1280 + + 800 + + 15 + Y16 + + + + 1280 + + 720 + + 15 + + MJPG + + + + 1280 + + 800 + + 15 + + Y8 + + + + + + + LibUVC + + + false + true + + + + true + + 1000 + + 100 + + + + 0 + + 1 + + + + + + 0 + + 5000 + + 0 + + 2000 + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + + LibUVC + + + false + true + + + + true + + 1000 + + 100 + + + + 0 + + 1 + + + + + + 0 + + 5000 + + 0 + + 2000 + + 848 + + 480 + + 30 + Y16 + + + + 1280 + + 720 + + 30 + MJPG + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + 848 + + 480 + + 30 + Y8 + + + + + + + LibUVC + + + 0 + + + 1.2 + + + + 15 + + 5000 + + 3000 + + 1280 + + 800 + + 10 + RVL + + + + 1280 + + 800 + + 10 + MJPG + + 15 + + 5000 + + 3000 + + + + 1280 + + 800 + + 10 + Y8 + + 15 + + 5000 + + 3000 + + + + 1280 + + 800 + + 10 + Y8 + + 15 + + 5000 + + 3000 + + + + + 0 + + 5000 + + 3000 + + + + 0 + + 5000 + + 3000 + + + + + + + 1280 + + 800 + + 20 + MJPG + + 0 + + 5 + + 5000 + + + + 640 + + 400 + + 20 + RVL + + 0 + + 5 + + 5000 + + + + 640 + + 400 + + 20 + Y8 + + 0 + + 5 + + 5000 + + + + 640 + + 400 + + 20 + Y8 + + 0 + + 5 + + 5000 + + + + + + 1280 + + 800 + + 10 + MJPG + + 0 + + 5 + + 5000 + + + + 1280 + + 800 + + 10 + Y10 + + 0 + + 5 + + 5000 + + + + 1280 + + 800 + + 10 + Y10 + + 0 + + 5 + + 5000 + + + + + + 1280 + + 800 + + 10 + MJPG + + 0 + + 5 + + 5000 + + + + 1280 + + 800 + + 10 + Y8 + + 0 + + 5 + + 5000 + + + + 1280 + + 800 + + 10 + Y8 + + 0 + + 5 + + 5000 + + + + + \ No newline at end of file diff --git a/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/shared/install_udev_rules.sh b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/shared/install_udev_rules.sh new file mode 100755 index 0000000..0c28d83 --- /dev/null +++ b/tools/multi-devices-sync/OrbbecSDK_v2.4.3_20250523_linux_aarch64/shared/install_udev_rules.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# Copyright (c) Orbbec Inc. All Rights Reserved. +# Licensed under the MIT License. + +# Check if user is root/running with sudo +if [ `whoami` != root ]; then + echo Please run this script with sudo + exit +fi + +ORIG_PATH=`pwd` +cd `dirname $0` +SCRIPT_PATH=`pwd` +cd $ORIG_PATH + +if [ "`uname -s`" != "Darwin" ]; then + # Install udev rules for USB device + cp ${SCRIPT_PATH}/99-obsensor-libusb.rules /etc/udev/rules.d/99-obsensor-libusb.rules + + # resload udev rules + udevadm control --reload && udevadm trigger + + echo "usb rules file install at /etc/udev/rules.d/99-obsensor-libusb.rules" +fi +echo "exit" diff --git a/tools/multi-devices-sync/ReadMe.md b/tools/multi-devices-sync/ReadMe.md index 6f4e15a..687fa16 100644 --- a/tools/multi-devices-sync/ReadMe.md +++ b/tools/multi-devices-sync/ReadMe.md @@ -8,28 +8,105 @@ The first is to set all devices as OB_MULTI_DEVICE_SYNC_MODE_SECONDARY mode and The second is to set all devices as OB_MULTI_DEVICE_SYNC_MODE_HARDWARE_TRIGGERING mode and synchronize them through PWM triggering. -PWM triggering source code please refer [ob_multi_devices_sync_gmsltrigger sample](https://github.com/orbbec/OrbbecSDK_v2/tree/main/examples/3.advanced.multi_devices_sync_gmsltrigger). -Multi devices sync source code please refer [ob_multi_devices_sync sample](https://github.com/orbbec/OrbbecSDK_v2/tree/main/examples/3.advanced.multi_devices_sync) +PWM triggering source code please refer [ob_multi_devices_sync_gmsltrigger sample](./OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync_gmsltrigger). +Multi devices sync source code please refer [ob_multi_devices_sync sample](./OrbbecSDK_v2.4.3_20250523_linux_aarch64/examples/src/3.advanced.multi_devices_sync/) - Notes: To make the multi devices sync sample simple and versatile, the PWM trigger has been separated into its own sample. GMSL2/FAKRA requires running two samples for testing. If you are developing your own application, you can combine these two functionalities into a single application. ## 2. How to test multi devices sync using C++ sample ### 2.1 Build -1. Extract the OrbbecSDK sample package OrbbecSDK_v2.4.3_20250523_linux_aarch64.zip to the current directory -2. Open a terminal and run cd to enter the extracted directory -3. Run the setup script to build and configure the environment: `sudo ./setup.sh` +1. Open a terminal and run cd to enter the OrbbecSDK_v2.4.3_20250523_linux_aarch64 directory +2. Run the setup script to build and configure the environment: `sudo ./setup.sh` ### 2.2 Multi-devices sync configuration -Using two Gemini 335Lg device as an example, the MultiDeviceSyncConfig.json is as follow: +Using eight Gemini 335Lg device as an example, If fewer than eight devices are connected, remove the extra devices from the JSON configuration file. Make sure the number of devices in the configuration file matches the actual number of connected devices, and please configure the correct serial numbers (SNs). the MultiDeviceSyncConfig.json is as follow: ~~~ { "version": "1.0.0", - "configTime": "2025/05/23", + "configTime": "2023/01/01", + "streamProfile": { + "color": { + "width": 1280, + "height": 800, + "format": "YUYV", + "fps": 30 + }, + "depth": { + "width": 1280, + "height": 800, + "format": "Y16", + "fps": 30 + } + }, + "sensorControl": { + "enable": true, + "depthPreset": "Default", + "laserPowerLevel": 6, + "laserOn": true, + "disparitySearchRange": "256", + "hardwareD2d": true, + "hardwareNoiseRemoval": true, + "softwareNoiseRemoval": false, + "colorAutoExposure": true, + "colorExposure": 50, + "colorGain": 16, + "irAutoExposure": false, + "irExposure": 7500, + "irGain": 16 + }, "devices": [ { - "sn": "CP4H74D0000Z", + "sn": "CP4R84P0008J", + "syncConfig": { + "syncMode": "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", + "depthDelayUs": 0, + "colorDelayUs": 0, + "trigger2ImageDelayUs": 0, + "triggerOutEnable": true, + "triggerOutDelayUs": 0, + "framesPerTrigger": 1 + } + }, + { + "sn": "CP4R84P000B5", + "syncConfig": { + "syncMode": "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", + "depthDelayUs": 0, + "colorDelayUs": 0, + "trigger2ImageDelayUs": 0, + "triggerOutEnable": true, + "triggerOutDelayUs": 0, + "framesPerTrigger": 1 + } + }, + { + "sn": "CP4R84P0006H", + "syncConfig": { + "syncMode": "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", + "depthDelayUs": 0, + "colorDelayUs": 0, + "trigger2ImageDelayUs": 0, + "triggerOutEnable": true, + "triggerOutDelayUs": 0, + "framesPerTrigger": 1 + } + }, + { + "sn": "CP4R84P000A3", + "syncConfig": { + "syncMode": "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", + "depthDelayUs": 0, + "colorDelayUs": 0, + "trigger2ImageDelayUs": 0, + "triggerOutEnable": true, + "triggerOutDelayUs": 0, + "framesPerTrigger": 1 + } + }, + { + "sn": "CP4H74D0002K", "syncConfig": { "syncMode": "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", "depthDelayUs": 0, @@ -41,7 +118,31 @@ Using two Gemini 335Lg device as an example, the MultiDeviceSyncConfig.json is a } }, { - "sn": "CP4H74D0004K", + "sn": "CP4H74D00041", + "syncConfig": { + "syncMode": "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", + "depthDelayUs": 0, + "colorDelayUs": 0, + "trigger2ImageDelayUs": 0, + "triggerOutEnable": true, + "triggerOutDelayUs": 0, + "framesPerTrigger": 1 + } + }, + { + "sn": "CP4H74D0003X", + "syncConfig": { + "syncMode": "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", + "depthDelayUs": 0, + "colorDelayUs": 0, + "trigger2ImageDelayUs": 0, + "triggerOutEnable": true, + "triggerOutDelayUs": 0, + "framesPerTrigger": 1 + } + }, + { + "sn": "CP4R84P0003W", "syncConfig": { "syncMode": "OB_MULTI_DEVICE_SYNC_MODE_SECONDARY", "depthDelayUs": 0, @@ -54,11 +155,12 @@ Using two Gemini 335Lg device as an example, the MultiDeviceSyncConfig.json is a } ] } -~~~ +~~~ -- sn: Replace with the actual serial number of the device. +- sn: Replace with the actual serial number of the device,you can use device enumerate sample to obtain SN. +![obtain SN](images/device_enumerate.png) - syncMode: Can be set to either OB_MULTI_DEVICE_SYNC_MODE_SECONDARY or OB_MULTI_DEVICE_SYNC_MODE_HARDWARE_TRIGGERING. @@ -69,6 +171,30 @@ The differences between the two sync modes are as follows: - OB_MULTI_DEVICE_SYNC_MODE_HARDWARE_TRIGGERING: Sets the device to hardware triggering mode. In this mode, the PWM trigger signal must not exceed half of the streaming frame rate. For example, if the streaming frame rate is set to 30 fps, and the PWM trigger signal exceeds 15, the camera will still only capture images at 15 fps. In other words, when the streaming frame rate is 30 fps, the valid range for the PWM trigger signal is 1 to 15 fps. +~~~ + "sensorControl": { + "enable": true, + "depthPreset": "Default", + "laserPowerLevel": 6, + "laserOn": true, + "disparitySearchRange": "256", + "hardwareD2d": true, + "hardwareNoiseRemoval": true, + "softwareNoiseRemoval": false, + "colorAutoExposure": true, + "colorExposure": 50, + "colorGain": 16, + "irAutoExposure": false, + "irExposure": 7500, + "irGain": 16 + } +~~~ + +- enable =true: indicates the following parameters will be set; false: the following parameters will not be set. +- hardwareD2d: true: use hardware d2d ; false: use software d2d. +- hardwareNoiseRemoval: true: enable hardware noise removal filter; false: disable hardware noise removal filter. +- softwareNoiseRemoval: true: enable software noise removal filter; false: disable software noise removal filter. + **1. Open the first terminal and run the multi-devices sync sample** ~~~ ```cpp diff --git a/tools/multi-devices-sync/images/device_enumerate.png b/tools/multi-devices-sync/images/device_enumerate.png new file mode 100644 index 0000000..24f21b5 Binary files /dev/null and b/tools/multi-devices-sync/images/device_enumerate.png differ diff --git a/tools/multi-devices-sync/images/multi-devices-sync.png b/tools/multi-devices-sync/images/multi-devices-sync.png index f75bc29..47ed17d 100644 Binary files a/tools/multi-devices-sync/images/multi-devices-sync.png and b/tools/multi-devices-sync/images/multi-devices-sync.png differ