diff --git a/.gitignore b/.gitignore index 4d942ee4..0c8d7cb9 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ debian/ # Compiled Dynamic libraries *.so +!orbbec_camera/SDK/**/*.so *.dylib *.dll diff --git a/orbbec_camera/CMakeLists.txt b/orbbec_camera/CMakeLists.txt index d3e514fc..9b5709a1 100644 --- a/orbbec_camera/CMakeLists.txt +++ b/orbbec_camera/CMakeLists.txt @@ -127,8 +127,9 @@ elseif((${MACHINES} MATCHES "aarch64") AND (${MACHINES_BIT} MATCHES "64")) set(HOST_PLATFORM "arm64") endif() -set(ORBBEC_LIBS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/SDK/lib/${HOST_PLATFORM}) -set(ORBBEC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/SDK/include/) +set(ORBBEC_SDK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/SDK/${HOST_PLATFORM}") +set(ORBBEC_LIBS_DIR "${ORBBEC_SDK_DIR}/lib") +set(ORBBEC_INCLUDE_DIR "${ORBBEC_SDK_DIR}/include/") set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}:${ORBBEC_LIBS_DIR}") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${ORBBEC_LIBS_DIR}") diff --git a/orbbec_camera/SDK/include/libobsensor/ObSensor.h b/orbbec_camera/SDK/arm64/include/libobsensor/ObSensor.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/ObSensor.h rename to orbbec_camera/SDK/arm64/include/libobsensor/ObSensor.h diff --git a/orbbec_camera/SDK/include/libobsensor/ObSensor.hpp b/orbbec_camera/SDK/arm64/include/libobsensor/ObSensor.hpp similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/ObSensor.hpp rename to orbbec_camera/SDK/arm64/include/libobsensor/ObSensor.hpp diff --git a/orbbec_camera/SDK/include/libobsensor/h/Advanced.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/Advanced.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/Advanced.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/Advanced.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/ApplicationConfig.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/ApplicationConfig.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/ApplicationConfig.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/ApplicationConfig.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/Context.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/Context.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/Context.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/Context.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/Device.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/Device.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/Device.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/Device.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/Error.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/Error.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/Error.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/Error.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/Export.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/Export.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/Export.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/Export.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/Filter.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/Filter.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/Filter.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/Filter.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/Frame.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/Frame.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/Frame.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/Frame.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/MultipleDevices.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/MultipleDevices.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/MultipleDevices.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/MultipleDevices.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/ObTypes.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/ObTypes.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/ObTypes.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/ObTypes.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/Pipeline.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/Pipeline.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/Pipeline.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/Pipeline.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/Property.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/Property.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/Property.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/Property.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/RecordPlayback.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/RecordPlayback.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/RecordPlayback.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/RecordPlayback.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/Sensor.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/Sensor.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/Sensor.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/Sensor.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/StreamProfile.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/StreamProfile.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/StreamProfile.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/StreamProfile.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/TypeHelper.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/TypeHelper.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/TypeHelper.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/TypeHelper.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/Utils.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/Utils.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/Utils.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/Utils.h diff --git a/orbbec_camera/SDK/include/libobsensor/h/Version.h b/orbbec_camera/SDK/arm64/include/libobsensor/h/Version.h similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/h/Version.h rename to orbbec_camera/SDK/arm64/include/libobsensor/h/Version.h diff --git a/orbbec_camera/SDK/include/libobsensor/hpp/ApplicationConfig.hpp b/orbbec_camera/SDK/arm64/include/libobsensor/hpp/ApplicationConfig.hpp similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/hpp/ApplicationConfig.hpp rename to orbbec_camera/SDK/arm64/include/libobsensor/hpp/ApplicationConfig.hpp diff --git a/orbbec_camera/SDK/include/libobsensor/hpp/Context.hpp b/orbbec_camera/SDK/arm64/include/libobsensor/hpp/Context.hpp similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/hpp/Context.hpp rename to orbbec_camera/SDK/arm64/include/libobsensor/hpp/Context.hpp diff --git a/orbbec_camera/SDK/include/libobsensor/hpp/Device.hpp b/orbbec_camera/SDK/arm64/include/libobsensor/hpp/Device.hpp similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/hpp/Device.hpp rename to orbbec_camera/SDK/arm64/include/libobsensor/hpp/Device.hpp diff --git a/orbbec_camera/SDK/include/libobsensor/hpp/Error.hpp b/orbbec_camera/SDK/arm64/include/libobsensor/hpp/Error.hpp similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/hpp/Error.hpp rename to orbbec_camera/SDK/arm64/include/libobsensor/hpp/Error.hpp diff --git a/orbbec_camera/SDK/include/libobsensor/hpp/Filter.hpp b/orbbec_camera/SDK/arm64/include/libobsensor/hpp/Filter.hpp similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/hpp/Filter.hpp rename to orbbec_camera/SDK/arm64/include/libobsensor/hpp/Filter.hpp diff --git a/orbbec_camera/SDK/include/libobsensor/hpp/Frame.hpp b/orbbec_camera/SDK/arm64/include/libobsensor/hpp/Frame.hpp similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/hpp/Frame.hpp rename to orbbec_camera/SDK/arm64/include/libobsensor/hpp/Frame.hpp diff --git a/orbbec_camera/SDK/include/libobsensor/hpp/Pipeline.hpp b/orbbec_camera/SDK/arm64/include/libobsensor/hpp/Pipeline.hpp similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/hpp/Pipeline.hpp rename to orbbec_camera/SDK/arm64/include/libobsensor/hpp/Pipeline.hpp diff --git a/orbbec_camera/SDK/include/libobsensor/hpp/RecordPlayback.hpp b/orbbec_camera/SDK/arm64/include/libobsensor/hpp/RecordPlayback.hpp similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/hpp/RecordPlayback.hpp rename to orbbec_camera/SDK/arm64/include/libobsensor/hpp/RecordPlayback.hpp diff --git a/orbbec_camera/SDK/include/libobsensor/hpp/Sensor.hpp b/orbbec_camera/SDK/arm64/include/libobsensor/hpp/Sensor.hpp similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/hpp/Sensor.hpp rename to orbbec_camera/SDK/arm64/include/libobsensor/hpp/Sensor.hpp diff --git a/orbbec_camera/SDK/include/libobsensor/hpp/StreamProfile.hpp b/orbbec_camera/SDK/arm64/include/libobsensor/hpp/StreamProfile.hpp similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/hpp/StreamProfile.hpp rename to orbbec_camera/SDK/arm64/include/libobsensor/hpp/StreamProfile.hpp diff --git a/orbbec_camera/SDK/include/libobsensor/hpp/TypeHelper.hpp b/orbbec_camera/SDK/arm64/include/libobsensor/hpp/TypeHelper.hpp similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/hpp/TypeHelper.hpp rename to orbbec_camera/SDK/arm64/include/libobsensor/hpp/TypeHelper.hpp diff --git a/orbbec_camera/SDK/include/libobsensor/hpp/Types.hpp b/orbbec_camera/SDK/arm64/include/libobsensor/hpp/Types.hpp similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/hpp/Types.hpp rename to orbbec_camera/SDK/arm64/include/libobsensor/hpp/Types.hpp diff --git a/orbbec_camera/SDK/include/libobsensor/hpp/Utils.hpp b/orbbec_camera/SDK/arm64/include/libobsensor/hpp/Utils.hpp similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/hpp/Utils.hpp rename to orbbec_camera/SDK/arm64/include/libobsensor/hpp/Utils.hpp diff --git a/orbbec_camera/SDK/include/libobsensor/hpp/Version.hpp b/orbbec_camera/SDK/arm64/include/libobsensor/hpp/Version.hpp similarity index 100% rename from orbbec_camera/SDK/include/libobsensor/hpp/Version.hpp rename to orbbec_camera/SDK/arm64/include/libobsensor/hpp/Version.hpp diff --git a/orbbec_camera/SDK/lib/arm64/OrbbecSDKConfig-release.cmake b/orbbec_camera/SDK/arm64/lib/OrbbecSDKConfig-release.cmake similarity index 100% rename from orbbec_camera/SDK/lib/arm64/OrbbecSDKConfig-release.cmake rename to orbbec_camera/SDK/arm64/lib/OrbbecSDKConfig-release.cmake diff --git a/orbbec_camera/SDK/lib/arm64/OrbbecSDKConfig.cmake b/orbbec_camera/SDK/arm64/lib/OrbbecSDKConfig.cmake similarity index 100% rename from orbbec_camera/SDK/lib/arm64/OrbbecSDKConfig.cmake rename to orbbec_camera/SDK/arm64/lib/OrbbecSDKConfig.cmake diff --git a/orbbec_camera/SDK/lib/arm64/OrbbecSDKVersion.cmake b/orbbec_camera/SDK/arm64/lib/OrbbecSDKVersion.cmake similarity index 100% rename from orbbec_camera/SDK/lib/arm64/OrbbecSDKVersion.cmake rename to orbbec_camera/SDK/arm64/lib/OrbbecSDKVersion.cmake diff --git a/orbbec_camera/SDK/lib/arm64/extensions/depthengine/libdepthengine.so b/orbbec_camera/SDK/arm64/lib/extensions/depthengine/libdepthengine.so similarity index 100% rename from orbbec_camera/SDK/lib/arm64/extensions/depthengine/libdepthengine.so rename to orbbec_camera/SDK/arm64/lib/extensions/depthengine/libdepthengine.so diff --git a/orbbec_camera/SDK/lib/arm64/extensions/depthengine/libdepthengine.so.2.0 b/orbbec_camera/SDK/arm64/lib/extensions/depthengine/libdepthengine.so.2.0 similarity index 100% rename from orbbec_camera/SDK/lib/arm64/extensions/depthengine/libdepthengine.so.2.0 rename to orbbec_camera/SDK/arm64/lib/extensions/depthengine/libdepthengine.so.2.0 diff --git a/orbbec_camera/SDK/lib/arm64/extensions/filters/enhanced_depth_filter/libengine_infer_encry.so b/orbbec_camera/SDK/arm64/lib/extensions/filters/enhanced_depth_filter/libengine_infer_encry.so similarity index 100% rename from orbbec_camera/SDK/lib/arm64/extensions/filters/enhanced_depth_filter/libengine_infer_encry.so rename to orbbec_camera/SDK/arm64/lib/extensions/filters/enhanced_depth_filter/libengine_infer_encry.so diff --git a/orbbec_camera/SDK/lib/arm64/extensions/filters/enhanced_depth_filter/libenhanced_depth_filter.so b/orbbec_camera/SDK/arm64/lib/extensions/filters/enhanced_depth_filter/libenhanced_depth_filter.so similarity index 100% rename from orbbec_camera/SDK/lib/arm64/extensions/filters/enhanced_depth_filter/libenhanced_depth_filter.so rename to orbbec_camera/SDK/arm64/lib/extensions/filters/enhanced_depth_filter/libenhanced_depth_filter.so diff --git a/orbbec_camera/SDK/lib/arm64/extensions/filters/libFilterProcessor.so b/orbbec_camera/SDK/arm64/lib/extensions/filters/libFilterProcessor.so similarity index 100% rename from orbbec_camera/SDK/lib/arm64/extensions/filters/libFilterProcessor.so rename to orbbec_camera/SDK/arm64/lib/extensions/filters/libFilterProcessor.so diff --git a/orbbec_camera/SDK/lib/arm64/extensions/filters/libob_priv_filter.so b/orbbec_camera/SDK/arm64/lib/extensions/filters/libob_priv_filter.so similarity index 100% rename from orbbec_camera/SDK/lib/arm64/extensions/filters/libob_priv_filter.so rename to orbbec_camera/SDK/arm64/lib/extensions/filters/libob_priv_filter.so diff --git a/orbbec_camera/SDK/lib/arm64/extensions/firmwareupdater/libfirmwareupdater.so b/orbbec_camera/SDK/arm64/lib/extensions/firmwareupdater/libfirmwareupdater.so similarity index 100% rename from orbbec_camera/SDK/lib/arm64/extensions/firmwareupdater/libfirmwareupdater.so rename to orbbec_camera/SDK/arm64/lib/extensions/firmwareupdater/libfirmwareupdater.so diff --git a/orbbec_camera/SDK/lib/arm64/extensions/frameprocessor/libob_frame_processor.so b/orbbec_camera/SDK/arm64/lib/extensions/frameprocessor/libob_frame_processor.so similarity index 100% rename from orbbec_camera/SDK/lib/arm64/extensions/frameprocessor/libob_frame_processor.so rename to orbbec_camera/SDK/arm64/lib/extensions/frameprocessor/libob_frame_processor.so diff --git a/orbbec_camera/SDK/lib/arm64/libOrbbecSDK.so b/orbbec_camera/SDK/arm64/lib/libOrbbecSDK.so similarity index 100% rename from orbbec_camera/SDK/lib/arm64/libOrbbecSDK.so rename to orbbec_camera/SDK/arm64/lib/libOrbbecSDK.so diff --git a/orbbec_camera/SDK/lib/arm64/libOrbbecSDK.so.2 b/orbbec_camera/SDK/arm64/lib/libOrbbecSDK.so.2 similarity index 100% rename from orbbec_camera/SDK/lib/arm64/libOrbbecSDK.so.2 rename to orbbec_camera/SDK/arm64/lib/libOrbbecSDK.so.2 diff --git a/orbbec_camera/SDK/lib/arm64/libOrbbecSDK.so.2.9.3 b/orbbec_camera/SDK/arm64/lib/libOrbbecSDK.so.2.9.3 similarity index 100% rename from orbbec_camera/SDK/lib/arm64/libOrbbecSDK.so.2.9.3 rename to orbbec_camera/SDK/arm64/lib/libOrbbecSDK.so.2.9.3 diff --git a/orbbec_camera/SDK/x64/include/libobsensor/ObSensor.h b/orbbec_camera/SDK/x64/include/libobsensor/ObSensor.h new file mode 100644 index 00000000..88f82a62 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/ObSensor.h @@ -0,0 +1,24 @@ +// 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 SDK library. + * It includes all necessary header files for SDK usage. + */ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/orbbec_camera/SDK/x64/include/libobsensor/ObSensor.hpp b/orbbec_camera/SDK/x64/include/libobsensor/ObSensor.hpp new file mode 100644 index 00000000..5fe97d5a --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/ObSensor.hpp @@ -0,0 +1,22 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +/** + * \file ObSensor.hpp + * \brief This is the main entry point for the SDK 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 +#include diff --git a/orbbec_camera/SDK/x64/include/libobsensor/h/Advanced.h b/orbbec_camera/SDK/x64/include/libobsensor/h/Advanced.h new file mode 100644 index 00000000..abff49dc --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/Advanced.h @@ -0,0 +1,419 @@ +// 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 + * + * @param[in] device The device object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @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); + +/** + * @brief Get the depth work mode count that ob_depth_work_mode_list hold + * + * @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. + * + * @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); + +/** + * @brief 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[in] device The device object. + * @param[out] 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[in] device The device object. + * @param[in] 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[out] 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[in] device The device object. + * @param[in] json_file_path The json file path. + * @param[out] 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 @p 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[in] device The device object. + * @param[in] presetName The name of the custome preset. + * @param[in] data The custom preset data. + * @param[in] size The size of the custom preset data. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +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[in] device The device object. + * @param[in] json_file_path The json file path. + * @param[out] 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 @p 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[in] device The device object. + * @param[in] presetName The name of the custome preset. + * @param[out] data Return the preset json data. + * @param[out] dataSize Return the size of the preset json data. + * @param[out] 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_data(ob_device *device, const char *presetName, const uint8_t **data, uint32_t *dataSize, + ob_error **error); + +/** + * @brief Get the available preset list. + * + * @param[in] device The device object. + * @param[out] 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[in] preset_list The available preset list. + * @param[out] 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[in] preset_list The available preset list. + * @param[out] 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[in] preset_list The available preset list. + * @param[in] index The index of the preset in the preset list. + * @param[out] 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[in] preset_list The available preset list. + * @param[in] preset_name The name of the preset. + * @param[out] 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[in] device The device object. + * @param[out] 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 interleave name. + * + * @param[in] device The device object. + * @param[in] frame_interleave_name The name should be one of the frame interleave names returned by @ref ob_device_get_available_frame_interleave_list. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_load_frame_interleave(ob_device *device, const char *frame_interleave_name, ob_error **error); + +/** + * + * @brief Get current frame interleave name. + * + * @param[in] device The device object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return const char* return the current frame interleave name. + * Returns an empty string ("") if no interleave is loaded. + * Returns nullptr if an error occurs. + */ +OB_EXPORT const char *ob_device_get_current_frame_interleave_name(const ob_device *device, ob_error **error); + +/** + * @brief Get the available frame interleave list. + * + * @param[in] device The device object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @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[in] frame_interleave_list The available frame interleave list. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +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[in] frame_interleave_list The available frame interleave list. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @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[in] frame_interleave_list The available frame interleave list. + * @param[in] index The index of frame interleave in the frame interleave list. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @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[in] frame_interleave_list The available interleave ae list. + * @param[in] frame_interleave_name The name of the interleave ae. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @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); + +/** + * @brief Get the available preset resolution config list. + * + * @param[in] device The device object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return The available frame resolution config list. + */ +OB_EXPORT ob_preset_resolution_config_list *ob_device_get_available_preset_resolution_config_list(ob_device *device, ob_error **error); + +/** + * @brief Get the number of preset resolution in the preset resolution list. + * + * @param[in] ob_preset_resolution_config_list The available preset resolution list. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return The number of preset resolution in the preset resolution list. + */ +OB_EXPORT uint32_t ob_device_preset_resolution_config_get_count(ob_preset_resolution_config_list *ob_preset_resolution_config_list, ob_error **error); + +/** + * @brief Get the preset resolution in the preset resolution list. + * + * @param[in] ob_preset_resolution_config_list The available preset resolution list. + * @param[in] index The index of preset resolution in the preset resolution list. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return The preset resolution in the preset resolution list. + */ +OB_EXPORT OBPresetResolutionConfig ob_device_preset_resolution_config_list_get_item(const ob_preset_resolution_config_list *ob_preset_resolution_config_list, + uint32_t index, ob_error **error); + +/** + * @brief Delete the available preset resolution list. + * + * @param[in] ob_preset_resolution_config_list The available preset resolution list. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_delete_preset_resolution_config_list(ob_preset_resolution_config_list *ob_preset_resolution_config_list, ob_error **error); + +/** + * @brief Check if the device supports color preset. + * + * @param[in] device The device object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return bool Returns true if the device supports color preset. + */ +OB_EXPORT bool ob_device_is_color_preset_supported(const ob_device *device, ob_error **error); + +/** + * @brief Get the current color preset name. + * + * @param[in] device The device object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return const char* The current color preset name. + */ +OB_EXPORT const char *ob_device_get_current_color_preset_name(const ob_device *device, ob_error **error); + +/** + * @brief Switch the color preset by name. + * + * @param[in] device The device object. + * @param[in] preset_name The color preset name. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_switch_color_preset(ob_device *device, const char *preset_name, ob_error **error); + +/** + * @brief Get the available color preset list. + * + * @param[in] device The device object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return ob_color_preset_list* The color preset list. + */ +OB_EXPORT ob_color_preset_list *ob_device_get_color_preset_list(const ob_device *device, ob_error **error); + +/** + * @brief Get the number of color preset in the list. + * + * @param[in] list The color preset list. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return uint32_t The number of color preset in the list. + */ +OB_EXPORT uint32_t ob_color_preset_list_get_count(const ob_color_preset_list *list, ob_error **error); + +/** + * @brief Get the name of color preset at the specified index. + * + * @param[in] list The color preset list. + * @param[in] index The index of the color preset. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return const char* The name of the color preset. + */ +OB_EXPORT const char *ob_color_preset_list_get_name(const ob_color_preset_list *list, uint32_t index, ob_error **error); + +/** + * @brief Delete the color preset list. + * + * @param[in] list The color preset list. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_delete_color_preset_list(ob_color_preset_list *list, 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/orbbec_camera/SDK/x64/include/libobsensor/h/ApplicationConfig.h b/orbbec_camera/SDK/x64/include/libobsensor/h/ApplicationConfig.h new file mode 100644 index 00000000..b3cdfc7e --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/ApplicationConfig.h @@ -0,0 +1,267 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +#pragma once + +#include "ObTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Application configuration key. + * Each key has a fixed value type and item usage. + * Keys must stay within the low 32 bits because @ref OBAppConfigItem stores the key in bits 0-31. + */ +typedef enum { + OB_APP_CONFIG_SENSORS = 0, /**< array, sensor list. Use @ref ob_application_config_get_count to get sensor count. */ + OB_APP_CONFIG_SENSOR_TYPE = 1, /**< int32_t, sensor item: OBSensorType. */ + OB_APP_CONFIG_STREAM_ENABLED = 2, /**< bool, sensor item: whether the sensor stream should be started. */ + OB_APP_CONFIG_STREAM_PROFILE = 3, /**< ob_stream_profile, sensor item: stream profile. */ + OB_APP_CONFIG_UNDISTORTION_ENABLED = 4, /**< bool, sensor item: whether undistortion should be enabled. */ + + OB_APP_CONFIG_DEVICE_DECIMATION_ENABLED = 5, /**< bool, global item: whether device-level decimation should be applied. */ + OB_APP_CONFIG_DEVICE_DECIMATION = 6, /**< OBPresetResolutionConfig, global item: device-level decimation configuration. */ + /**< Currently applied only by Gemini 435Le. */ + // Point cloud + OB_APP_CONFIG_POINTCLOUD_ENABLED = 100, /**< bool, global item: whether point cloud output should be enabled. */ + OB_APP_CONFIG_POINTCLOUD_FORMAT = 101, /**< int32_t, global item: OBFormat, point cloud output format. */ + OB_APP_CONFIG_POINTCLOUD_DECIMATION_FACTOR = 102, /**< int32_t, global item: point cloud decimation factor. */ + OB_APP_CONFIG_POINTCLOUD_ALIGN_MODE = 103, /**< int32_t, global item: OBAlignMode. */ + OB_APP_CONFIG_POINTCLOUD_FRAME_SYNC = 104, /**< bool, global item: whether frame sync should be enabled. */ + OB_APP_CONFIG_POINTCLOUD_ALL_FRAME_TYPE_REQUIRED = 105, /**< bool, global item: false: output on any situation, true: require all frame types. */ + OB_APP_CONFIG_POINTCLOUD_MATCH_TARGET_RESOLUTION = 106, /**< bool, global item: whether to match target resolution. */ + // HDR Merge + OB_APP_CONFIG_HDR_MERGE_ENABLED = 200, /**< bool, global item: whether HDR merge should be enabled. */ + OB_APP_CONFIG_HDR_MERGE_IR_ENABLED = 201, /**< bool, global item: whether IR frame should be enabled for HDR merge. */ +} OBAppConfigKey, + ob_app_config_key; + +/** + * @brief Application configuration item. + * An item combines a configuration key and an optional array index. + * Non-array keys use @ref OB_APP_CONFIG_ITEM. + * Array keys use @ref OB_APP_CONFIG_ARRAY_ITEM. + * The key is stored in bits 0-31 and the index is stored in bits 32-63. + */ +typedef uint64_t OBAppConfigItem, ob_app_config_item; + +#define OB_APP_CONFIG_INDEX_NONE (0u) +#define OB_APP_CONFIG_ITEM(key) ((OBAppConfigItem)(uint32_t)(key)) +#define OB_APP_CONFIG_ARRAY_ITEM(key, index) ((((OBAppConfigItem)(uint32_t)(index)) << 32) | (OBAppConfigItem)(uint32_t)(key)) +#define OB_APP_CONFIG_ITEM_KEY(item) ((OBAppConfigKey)((uint32_t)((item) & 0xFFFFFFFFu))) +#define OB_APP_CONFIG_ITEM_INDEX(item) ((uint32_t)(((item) >> 32) & 0xFFFFFFFFu)) + +/** + * @brief Application configuration value type. + */ +typedef enum { + OB_APP_CONFIG_VALUE_BOOL, /**< Boolean value. */ + OB_APP_CONFIG_VALUE_INT, /**< int32_t value. */ + OB_APP_CONFIG_VALUE_FLOAT, /**< float value. */ + OB_APP_CONFIG_VALUE_STRING, /**< String value. The returned pointer is owned by the config object. */ + OB_APP_CONFIG_VALUE_STRUCT, /**< Fixed-size SDK structure value. */ +} OBAppConfigValueType, + ob_app_config_value_type; + +/** + * @brief Get the application runtime configuration cache for 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 ob_application_config* The application configuration object cached by the device. + * @attention If the device has no application configuration cache, the SDK creates one with default values. + * @attention Changes made through the returned config update the device cache directly. + * @attention The returned config should be released by calling @ref ob_delete_application_config. + */ +OB_EXPORT ob_application_config *ob_device_get_application_config(ob_device *device, ob_error **error); + +/** + * @brief Get the application configuration carried by an externally imported preset, by preset name. + * + * @param[in] device The device object. + * @param[in] preset_name The preset name to query. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return ob_application_config* The application configuration imported with the given preset, or NULL for + * built-in presets or presets that carry no application configuration. + * @attention The returned config is owned by the device; it should still be released by calling + * @ref ob_delete_application_config (releasing the handle does not destroy the cached object). + */ +OB_EXPORT ob_application_config *ob_device_get_application_config_by_preset(ob_device *device, const char *preset_name, ob_error **error); + +/** + * @brief Delete an application configuration object. + * + * @param[in] config The application configuration 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_application_config(ob_application_config *config, ob_error **error); + +/** + * @brief Check whether the current device supports application runtime configuration import/export. + * + * @param[in] device The device object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return bool Return true if application configuration import/export is supported, false otherwise. + */ +OB_EXPORT bool ob_device_is_application_config_supported(ob_device *device, ob_error **error); + +/** + * @brief Reset an application configuration object to default values. + * + * @param[in] config The application configuration object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_application_config_reset(ob_application_config *config, ob_error **error); + +/** + * @brief Set a bool value. + * + * @param[in] config The application configuration object. + * @param[in] item The configuration item to update. Use @ref OB_APP_CONFIG_ITEM or @ref OB_APP_CONFIG_ARRAY_ITEM to build it. + * @param[in] value The bool value to be set. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_application_config_set_bool(ob_application_config *config, OBAppConfigItem item, bool value, ob_error **error); + +/** + * @brief Get a bool value. + * + * @param[in] config The application configuration object. + * @param[in] item The configuration item to read. Use @ref OB_APP_CONFIG_ITEM or @ref OB_APP_CONFIG_ARRAY_ITEM to build it. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return bool The bool value. + */ +OB_EXPORT bool ob_application_config_get_bool(const ob_application_config *config, OBAppConfigItem item, ob_error **error); + +/** + * @brief Set an int32_t value. + * + * @param[in] config The application configuration object. + * @param[in] item The configuration item to update. Use @ref OB_APP_CONFIG_ITEM or @ref OB_APP_CONFIG_ARRAY_ITEM to build it. + * @param[in] value The int32_t value to be set. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_application_config_set_int(ob_application_config *config, OBAppConfigItem item, int32_t value, ob_error **error); + +/** + * @brief Get an int32_t value. + * + * @param[in] config The application configuration object. + * @param[in] item The configuration item to read. Use @ref OB_APP_CONFIG_ITEM or @ref OB_APP_CONFIG_ARRAY_ITEM to build it. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return int32_t The int32_t value. + */ +OB_EXPORT int32_t ob_application_config_get_int(const ob_application_config *config, OBAppConfigItem item, ob_error **error); + +/** + * @brief Set a float value. + * + * @param[in] config The application configuration object. + * @param[in] item The configuration item to update. Use @ref OB_APP_CONFIG_ITEM or @ref OB_APP_CONFIG_ARRAY_ITEM to build it. + * @param[in] value The float value to be set. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_application_config_set_float(ob_application_config *config, OBAppConfigItem item, float value, ob_error **error); + +/** + * @brief Get a float value. + * + * @param[in] config The application configuration object. + * @param[in] item The configuration item to read. Use @ref OB_APP_CONFIG_ITEM or @ref OB_APP_CONFIG_ARRAY_ITEM to build it. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return float The float value. + */ +OB_EXPORT float ob_application_config_get_float(const ob_application_config *config, OBAppConfigItem item, ob_error **error); + +/** + * @brief Set a string value. + * + * @param[in] config The application configuration object. + * @param[in] item The configuration item to update. Use @ref OB_APP_CONFIG_ITEM or @ref OB_APP_CONFIG_ARRAY_ITEM to build it. + * @param[in] value The string value to be set. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_application_config_set_string(ob_application_config *config, OBAppConfigItem item, const char *value, ob_error **error); + +/** + * @brief Get a string value. + * + * @param[in] config The application configuration object. + * @param[in] item The configuration item to read. Use @ref OB_APP_CONFIG_ITEM or @ref OB_APP_CONFIG_ARRAY_ITEM to build it. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return const char* The string value. + * @attention The returned pointer is owned by the config object and becomes invalid after the config is modified or deleted. + */ +OB_EXPORT const char *ob_application_config_get_string(const ob_application_config *config, OBAppConfigItem item, ob_error **error); + +/** + * @brief Set a fixed-size SDK structure value. + * + * @param[in] config The application configuration object. + * @param[in] item The configuration item to update. Use @ref OB_APP_CONFIG_ITEM or @ref OB_APP_CONFIG_ARRAY_ITEM to build it. + * @param[in] value Pointer to the structure value to be copied. + * @param[in] valueSize Size of the structure value in bytes. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_application_config_set_struct(ob_application_config *config, OBAppConfigItem item, const void *value, uint32_t valueSize, ob_error **error); + +/** + * @brief Get a fixed-size SDK structure value. + * + * @param[in] config The application configuration object. + * @param[in] item The configuration item to read. Use @ref OB_APP_CONFIG_ITEM or @ref OB_APP_CONFIG_ARRAY_ITEM to build it. + * @param[out] value Pointer to the buffer that receives the structure value. + * @param[in] valueSize Size of the output buffer in bytes. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_application_config_get_struct(const ob_application_config *config, OBAppConfigItem item, void *value, uint32_t valueSize, ob_error **error); + +/** + * @brief Set the stream profile for a sensor item. + * + * @param[in] config The application configuration object. + * @param[in] item The sensor stream profile item to update. Use @ref OB_APP_CONFIG_ARRAY_ITEM with @ref OB_APP_CONFIG_STREAM_PROFILE. + * @param[in] profile The stream profile to be copied into the config object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @attention The config object clones the profile. The caller still owns and should release the input profile. + */ +OB_EXPORT void ob_application_config_set_profile(ob_application_config *config, OBAppConfigItem item, const ob_stream_profile *profile, ob_error **error); + +/** + * @brief Get the stream profile from a sensor item. + * + * @param[in] config The application configuration object. + * @param[in] item The sensor stream profile item to read. Use @ref OB_APP_CONFIG_ARRAY_ITEM with @ref OB_APP_CONFIG_STREAM_PROFILE. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return ob_stream_profile* The stream profile stored in the sensor item. + * @attention The returned profile should be released by calling @ref ob_delete_stream_profile. + */ +OB_EXPORT ob_stream_profile *ob_application_config_get_profile(const ob_application_config *config, OBAppConfigItem item, ob_error **error); + +/** + * @brief Get the number of items in an array key. + * + * Currently only @ref OB_APP_CONFIG_SENSORS is supported. + * + * @param[in] config The application configuration object. + * @param[in] key The array key to count. Refer to @ref OBAppConfigKey for available keys. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return uint32_t The number of items in the array key. + */ +OB_EXPORT uint32_t ob_application_config_get_count(const ob_application_config *config, OBAppConfigKey key, ob_error **error); + +#ifdef __cplusplus +} +#endif diff --git a/orbbec_camera/SDK/x64/include/libobsensor/h/Context.h b/orbbec_camera/SDK/x64/include/libobsensor/h/Context.h new file mode 100644 index 00000000..3c84c5be --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/Context.h @@ -0,0 +1,323 @@ +// 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 "Force" a static IP address configuration in a device identified by its MAC Address. + * + * @param[in] macAddress MAC address of the network device. + * You can obtain it from @ref ob_device_info_get_uid, or specify it manually + * in the format xx:xx:xx:xx:xx:xx, where each xx is a two-digit hexadecimal value. + * @param[in] config The new IP configuration. + * @param[out] error Pointer to an error object that will be populated if an error occurs. + * + * @return bool true if the configuration command was processed successfully, false otherwise. + * @note This applies to all GVCP devices + */ +OB_EXPORT bool ob_force_ip_config(const char *macAddress, ob_net_ip_config config, ob_error **error); + +/** + * @brief Set the GVCP port scheme used for network device discovery and control. + * + * @param[in] context Pointer to the context object. + * @param[in] scheme Target GVCP port scheme. + * Return error if the specified scheme is invalid or unsupported. + * @param[out] error Pointer to an error object that will be populated if an error occurs. + * + * @note This change affects only the current session and is not persisted. + * @note Switching to a different scheme will force disconnection of all currently connected network devices. + */ +OB_EXPORT void ob_set_gvcp_port_scheme(ob_context *context, ob_gvcp_port_scheme scheme, ob_error **error); + +/** + * @brief Get the current GVCP port scheme. + * + * @param[in] context Pointer to the context object + * @param[out] error Pointer to an error object that will be populated if an error occurs. + * + * @return Current GVCP port scheme. + */ +OB_EXPORT ob_gvcp_port_scheme ob_get_gvcp_port_scheme(ob_context *context, 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 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[in] accessMode Device access mode. @ref ob_device_access_mode. + * If the device does not support setting the Access Mode, the default OB_DEVICE_DEFAULT_ACCESS is used. + * Applies only on first device creation or after release and re-creation; subsequent calls ignore it. + * @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_ex(ob_context *context, const char *address, uint16_t port, ob_device_access_mode accessMode, ob_error **error); + +/** + * @brief Set a device plug-in callback function + * + * @deprecated This function is deprecated. Please use ob_register_device_changed_callback() instead. + * + * @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 Register a device plug-in callback function. + * + * This function registers a callback that will be triggered whenever a device is plugged in or unplugged. + * + * @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. + * + * @return A ob_callback_id that uniquely identifies the registered callback. + * This ID can be used later to unregister the callback with ob_unregister_device_changed_callback(). + * Returns INVALID_DEVICE_CHANGED_CALLBACK_ID if the registration fails. + */ +OB_EXPORT ob_callback_id ob_register_device_changed_callback(ob_context *context, ob_device_changed_callback callback, void *user_data, ob_error **error); + +/** + * @brief Unregister a previously registered device plug-in callback function. + * + * This function removes a callback that was registered by ob_register_device_changed_callback(). + * + * @param[in] context Pointer to the context object. + * @param[in] callback_id The callback ID returned by ob_register_device_changed_callback(). + * @param[out] error Pointer to an error object that will be populated if an error occurs during callback function setting. + */ +OB_EXPORT void ob_unregister_device_changed_callback(ob_context *context, ob_callback_id callback_id, 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 Synchronize the device time (synchronize hardwarePPS time to all created devices) + * + * @param[in] context Pointer to the context object + * @param[in] hardware_pps_time unit: ms. + * @param[out] error Pointer to an error object that will be populated if an error occurs during execution + */ +OB_EXPORT void ob_sync_device_hardware_pps_time(ob_context *context, uint64_t hardware_pps_time, 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 empty, the existing configuration is used; + * if the existing configuration is also empty, + * the value from the config file or the default configuration will be used. + * @param[out] error Pointer to an error object that will be populated if an error occurs during log output setting + * + * @note Other settings, such as log file name, remain unchanged. + */ +OB_EXPORT void ob_set_logger_to_file(ob_log_severity severity, const char *directory, ob_error **error); + +/** + * @brief Set the log file name for file output + * + * @param[in] file_name Log file name. Must not be empty. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @note Other settings, such as log level and output directory, remain unchanged. + */ +OB_EXPORT void ob_set_logger_file_name(const char *file_name, 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 Logs a message with severity, file, function, and line info. + * + * @param[in] severity Log level, see @ref ob_log_severity for details + * @param[in] module The module or component the log belongs to + * @param[in] message Message string to log + * @param[in] file Source file name, e.g., __FILE__ + * @param[in] func Function name, e.g., __func__ + * @param[in] line Line number, e.g., __LINE__ + * @param[out] error Pointer to an error object that will be populated if an error occurs during log output setting + */ +OB_EXPORT void ob_log_external_message(ob_log_severity severity, const char *module, const char *message, const char *file, const char *func, int line, + 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[in] directory Path to the extensions directory. If the path is empty, extensions path will be set to the current working directory. + * @param[out] 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); + + +/** + * @brief Set the host-side timestamp clock type for the current context. + * + * @attention All ob::Context instances share the same underlying SDK runtime and clock type. + * @attention Switching affects frame system and global timestamps; avoid switching during streaming. + * @attention It is recommended to synchronize device timestamps after switching. + * + * @param[in] context Pointer to the context object + * @param[in] clock_type The clock type to use for host-side timestamps + * @param[out] error Pointer to an error object that will be populated if an error occurs + */ +OB_EXPORT void ob_context_set_timestamp_clock_type(ob_context *context, ob_clock_type clock_type, ob_error **error); + +/** + * @brief Get the current host-side timestamp clock type for the context. + * + * @param[in] context Pointer to the context object + * @param[out] error Pointer to an error object that will be populated if an error occurs + * + * @return ob_clock_type The current clock type + */ +OB_EXPORT ob_clock_type ob_context_get_timestamp_clock_type(const ob_context *context, 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/orbbec_camera/SDK/x64/include/libobsensor/h/Device.h b/orbbec_camera/SDK/x64/include/libobsensor/h/Device.h new file mode 100644 index 00000000..bb1d7ebe --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/Device.h @@ -0,0 +1,1068 @@ +// 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 Check whether the device supports license authorization. + * + * This function only reports whether the device provides the license authorization + * capability. It does not read or validate the license information. + * + * @param[in] device The device object. + * @param[out] error Log error messages. + * @return true if the device supports license authorization, false otherwise. + */ +OB_EXPORT bool ob_device_is_license_authorization_supported(const ob_device *device, ob_error **error); + +/** + * @brief Write signed device license information. + * + * The license_info_json is a UTF-8 JSON string with the following structure. All + * binary fields are lowercase hex strings without a "0x" prefix and with a fixed + * length. Before writing, the SDK reads the currently connected device and compares + * it against "devInfo" to prevent writing a license to the wrong device; it does NOT + * verify the signature or recompute deviceHash (signature and device-binding checks + * are performed by the consumer/filter at runtime). + * + * { + * "formatVersion": 1, // license_info envelope version + * "devInfo": { // plaintext, NOT signed; used only to + * "deviceSn": "SN123456789", // guard against mis-writing to the + * "vid": "2BC5", // wrong device. vid/pid are 4-char + * "pid": "0660" // uppercase hex. + * }, + * "licenseInfo": { // signed authorization credential + * "schemaVersion": 1, // credential schema version + * "keyVersion": 1, // 16-bit signing public key id + * "featureFlags": "0000000000000001",// 8 bytes, 16-char lowercase hex + * "expireDate": 4294967295, // YYYYMMDD; 0xFFFFFFFF = permanent + * "deviceHash": "00112233445566778899aabbccddeeff", // 16 bytes, 32-char hex + * "signature": "...", // ECDSA P-256 r||s, 64 bytes, 128-char hex + * "vendorLicense": "..." // third-party vendor blob, lowercase hex (235 bytes) + * } + * } + * + * @param[in] device The device object. + * @param[in] license_info_json The SDK license_info JSON string described above. + * @param[in] license_info_json_size The byte size of license_info_json, excluding any trailing null terminator. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_write_license_info(ob_device *device, const char *license_info_json, uint32_t license_info_json_size, ob_error **error); + +/** + * @brief Read signed device license information as SDK license_info JSON. + * + * @param[in] device The device object. + * @param[out] license_info_json The output buffer for SDK license_info JSON, null-terminated on success. + * @param[in] license_info_json_size Size of the output buffer in bytes. Must be large enough to hold the JSON string and a trailing null terminator; 512 + * bytes is sufficient for the current schema. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_read_license_info(const ob_device *device, char *license_info_json, uint32_t license_info_json_size, ob_error **error); + +/** + * @brief Clear license information stored on the device. + * + * Erases the device license storage area so that the device returns to the + * "no license" state. Intended for internal repair, re-activation or debugging + * builds and should be gated by caller-side confirmation. + * + * @param[in] device The device object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_clear_license_info(ob_device *device, 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[in] device The device object. + * @param[in] enable Whether to enable global timestamp. + * @param[out] 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 Update the device optional depth presets from data loaded in memory. + * + * @param[in] device The device object. + * @param[in] data_list A list of preset data blocks, each holding a data pointer and its size. + * @param[in] count The number of the preset data blocks. + * @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_from_data(ob_device *device, const ob_data_view *data_list, uint8_t 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[out] 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 Enable or disable the device firmware log. + * + * @param[in] device The device object. + * @param[in] enable Whether to enable the firmware log. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_device_enable_firmware_log(ob_device *device, bool enable, ob_error **error); + +/** + * @brief Check whether the device firmware log is enabled. + * + * @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 firmware log is enabled. + */ +OB_EXPORT bool ob_device_is_firmware_log_enabled(ob_device *device, ob_error **error); + +/** + * @brief Synchronize the device time (synchronize hardwarePPS time to device) + * + * @param[in] device The device object. + * @param[in] hardware_pps_time unit: ms. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return bool Whether the synchronisation is successful. + */ +OB_EXPORT bool ob_device_sync_hardware_pps_time(ob_device *device, uint64_t hardware_pps_time, 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[out] 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", "GMSL2" + */ +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[in] info Device Information + * @param[out] 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 network device subnet mask + * + * @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 subnet mask, such as "255.255.255.0" + */ +OB_EXPORT const char *ob_device_info_get_subnet_mask(const ob_device_info *info, ob_error **error); + +/** + * @brief Get the network device gateway address + * + * @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 gateway address, such as "192.168.1.1" + */ +OB_EXPORT const char *ob_device_info_get_gateway(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[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 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", "GMSL2" + */ +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[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 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 subnet mask + * + * @attention Only valid for network devices, otherwise it will return "0.0.0.0". + * + * @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 subnet mask, such as "255.255.255.0" + */ +OB_EXPORT const char *ob_device_list_get_device_subnet_mask(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Get device gateway + * + * @attention Only valid for network devices, otherwise it will return "0.0.0.0". + * + * @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 gateway, such as "192.168.1.1" + */ +OB_EXPORT const char *ob_device_list_get_device_gateway(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Get the MAC address of the host network interface corresponding to the network device. + * + * @attention Only valid for network devices. Returns "0:0:0:0:0:0" for non-network devices. + * + * @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 MAC address of the host network interface associated with the device. + */ +OB_EXPORT const char *ob_device_list_get_device_local_mac(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Get the IP address of the host network interface corresponding to the network device. + * + * @attention Only valid for network devices. Returns "0.0.0.0" for non-network devices. + * + * @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 IP address of the host network interface associated with the device. + */ +OB_EXPORT const char *ob_device_list_get_device_local_ip(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Get the subnet length of the host network interface corresponding to the network device. + * + * @attention Only valid for network devices. Returns 0 for non-network devices. + * + * @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 uint8_t The subnet length (0~32) of the host network interface associated with the device. + */ +OB_EXPORT uint8_t ob_device_list_get_device_local_subnet_length(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Get the gateway of the host network interface corresponding to the network device. + * + * @attention Only valid for network devices. Returns "0.0.0.0" for non-network devices. + * + * @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 gateway of the host network interface associated with the device. + */ +OB_EXPORT const char *ob_device_list_get_device_local_gateway(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Get the name of the host network interface corresponding to the device. + * + * @attention Primarily for network devices. Returns "unknown" for USB or other non-network devices. + * + * @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 host network interface name (e.g., "eth0", "en0"). Returns "unknown" for non-network devices. + */ +OB_EXPORT const char *ob_device_list_get_device_local_net_if_name(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Get the current GVCP IP configuration status of the device at the specified index. + * + * @attention This function is valid primarily for Ethernet Vision devices. + * For non-Ethernet devices (e.g., USB), it will return OB_IP_SOURCE_NONE. + * + * @param[in] list The device list object. + * @param[in] index The index of the device in the list. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return The active IP configuration mode (e.g., DHCP, LLA, Persistent IP). + * Returns OB_IP_SOURCE_NONE if the device is not a Ethernet device. + */ +OB_EXPORT ob_ip_source_type ob_device_list_get_device_ip_source_type(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Get the user-defined name of the device at the specified index. + * + * @attention This function is valid primarily for Ethernet Vision devices. + * For non-Ethernet devices (e.g., USB), it will return "unknown". + * + * @param[in] list The device list object. + * @param[in] index The index of the device in the list. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return const char* The user-defined name string. Returns "unknown" for non-Ethernet devices or if not set. + */ +OB_EXPORT const char *ob_device_list_get_device_user_name(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Query the current device access state without opening the device. + * + * @attention This is a non-invasive GVCP CCP query for supported Ethernet devices. It reports device-side CCP state, not the owner process or host. + * For non-Ethernet devices or Ethernet devices without CCP support, it returns OB_DEVICE_ACCESS_STATE_UNSUPPORTED. + * CONTROLLED means monitor access may still be available, while default/control access may still fail. + * This call is synchronous and blocks while waiting for the device's GVCP response over the network; querying an unreachable device blocks until the + * underlying retry logic gives up, so prefer calling it off the UI thread when querying multiple devices. + * The returned state reflects the device access state only at the moment of the query and does not guarantee that a subsequent access (such as creating or + * opening the device) will succeed, as another client may change the state in between. + * + * @param[in] list Device list object. + * @param[in] index The index of the device. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return The current access state of the device. + */ +OB_EXPORT ob_device_access_state ob_device_list_query_device_access_state(const ob_device_list *list, uint32_t index, ob_error **error); + +/** + * @brief Query the current device access state by serial number without opening the device. + * + * @attention This is a non-invasive GVCP CCP query for supported Ethernet devices. It reports device-side CCP state, not the owner process or host. + * For non-Ethernet devices or Ethernet devices without CCP support, it returns OB_DEVICE_ACCESS_STATE_UNSUPPORTED. + * CONTROLLED means monitor access may still be available, while default/control access may still fail. + * This call is synchronous and blocks while waiting for the device's GVCP response over the network; querying an unreachable device blocks until the + * underlying retry logic gives up, so prefer calling it off the UI thread when querying multiple devices. + * The returned state reflects the device access state only at the moment of the query and does not guarantee that a subsequent access (such as creating or + * opening the device) will succeed, as another client may change the state in between. + * If no device in the list matches the given serial number, an error is set via the error parameter. + * + * @param[in] list Device list object. + * @param[in] serial_number The serial number of the device. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return The current access state of the device. + */ +OB_EXPORT ob_device_access_state ob_device_list_query_device_access_state_by_serial_number(const ob_device_list *list, const char *serial_number, + 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. + * + * @note Default access mode is OB_DEVICE_DEFAULT_ACCESS + */ +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] index The index of the device to create. + * @param[in] accessMode Device access mode. @ref ob_device_access_mode. + * If the device does not support setting the Access Mode, the default OB_DEVICE_DEFAULT_ACCESS is used. + * Applies only on first device creation or after release and re-creation; subsequent calls ignore it. + * @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_ex(const ob_device_list *list, uint32_t index, ob_device_access_mode accessMode, 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. + * + * @note Default access mode is OB_DEVICE_DEFAULT_ACCESS + */ +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 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[in] accessMode Device access mode. @ref ob_device_access_mode. + * If the device does not support setting the Access Mode, the default OB_DEVICE_DEFAULT_ACCESS is used. + * Applies only on first device creation or after release and re-creation; subsequent calls ignore it. + * @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_ex(const ob_device_list *list, const char *serial_number, ob_device_access_mode accessMode, + 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. + * + * @note Default access mode is OB_DEVICE_DEFAULT_ACCESS + */ +OB_EXPORT ob_device *ob_device_list_get_device_by_uid(const ob_device_list *list, const char *uid, 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[in] accessMode Device access mode. @ref ob_device_access_mode. + * If the device does not support setting the Access Mode, the default OB_DEVICE_DEFAULT_ACCESS is used. + * Applies only on first device creation or after release and re-creation; subsequent calls ignore it. + * @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_ex(const ob_device_list *list, const char *uid, ob_device_access_mode accessMode, 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/orbbec_camera/SDK/x64/include/libobsensor/h/Error.h b/orbbec_camera/SDK/x64/include/libobsensor/h/Error.h new file mode 100644 index 00000000..79991b6b --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/Error.h @@ -0,0 +1,85 @@ +// 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[in] status The error status. + * @param[in] message The error message. + * @param[in] function The name of the API function that caused the error. + * @param[in] args The error parameters. + * @param[in] 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/orbbec_camera/SDK/x64/include/libobsensor/h/Export.h b/orbbec_camera/SDK/x64/include/libobsensor/h/Export.h new file mode 100644 index 00000000..a8fb41f0 --- /dev/null +++ b/orbbec_camera/SDK/x64/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/orbbec_camera/SDK/x64/include/libobsensor/h/Filter.h b/orbbec_camera/SDK/x64/include/libobsensor/h/Filter.h new file mode 100644 index 00000000..71614428 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/Filter.h @@ -0,0 +1,283 @@ +// 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[in] name The name of the filter. + * @param[out] 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[in] filter ob_filter object + * @param[out] 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[in] name The name of the filter. + * @param[out] 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[in] name The name of the filter. + * @param[in] activation_key The activation key of the filter. + * @param[out] 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 Activate a private filter object with a specific device. + * + * @param[in] filter The private filter object. + * @param[in] device The device to associate with the activation. + * @param[in] options Optional extensible activation options (may be NULL). See @ref ob_priv_filter_activate_options. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_filter_activate_private_ex(ob_filter *filter, ob_device *device, const ob_priv_filter_activate_options *options, 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[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 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[in] config_schema_list The list of filter config schema items to delete. + * @param[out] 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[in] config_schema_list Filter config schema list + * @param[out] 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[in] config_schema_list Filter config schema list + * @param[in] index Config schema item index + * @param[out] 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. + * @brief It is useful when the align target stream dose not started (without any frame to get intrinsics and extrinsics). + * + * @param[in] filter A filter object. + * @param[in] align_to_stream_profile The align target stream profile. + * @param[out] 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/orbbec_camera/SDK/x64/include/libobsensor/h/Frame.h b/orbbec_camera/SDK/x64/include/libobsensor/h/Frame.h new file mode 100644 index 00000000..e24cd3e8 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/Frame.h @@ -0,0 +1,715 @@ +// 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[in] frame_type The frame object type. + * @param[in] format The frame object format. + * @param[in] data_size The size of the frame object data. + * @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(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[in] stream_profile The stream profile to create the new frame object according to. + * @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_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[in] frame Frame object + * @param[in] system_timestamp_us frame system 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_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[in] frame frame 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 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[in] frame frame object + * @param[in] stream_profile The stream profile to set for the frame. + * @param[out] 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[in] 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 the auth token carried by the frame. + * + * @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 auth token value. + */ +OB_EXPORT uint64_t ob_frame_get_token(const ob_frame *frame, ob_error **error); + +/** + * @brief Set the auth token carried by the frame. + * + * @param[in] frame Frame object. + * @param[in] token The auth token value. + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_frame_set_token(ob_frame *frame, uint64_t token, ob_error **error); + +/** + * @brief Get the device information attached to the frame. + * + * @param[in] frame Frame object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return ob_device_info* Return the attached device information, or NULL if not available. + */ +OB_EXPORT ob_device_info *ob_frame_get_device_info(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[in] frame Frame object + * @param[out] 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[in] frame Frame object + * @param[in] pixel_type the pixel format of the frame + * @param[out] 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 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/orbbec_camera/SDK/x64/include/libobsensor/h/MultipleDevices.h b/orbbec_camera/SDK/x64/include/libobsensor/h/MultipleDevices.h new file mode 100644 index 00000000..912e80e2 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/MultipleDevices.h @@ -0,0 +1,131 @@ +// 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 ob_multi_device_sync_config::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_SOFTWARE_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/orbbec_camera/SDK/x64/include/libobsensor/h/ObTypes.h b/orbbec_camera/SDK/x64/include/libobsensor/h/ObTypes.h new file mode 100644 index 00000000..ecb87703 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/ObTypes.h @@ -0,0 +1,2288 @@ +// 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_application_config_t ob_application_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; +typedef struct ob_preset_resolution_config_list_t ob_preset_resolution_config_list; +typedef struct ob_color_preset_list_t ob_color_preset_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 +#define OB_LIDAR_SCAN_ANY OB_LIDAR_SCAN_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 (success) */ + OB_STATUS_ERROR = 1, /**< Status error (legacy failure) */ + OB_ERROR_UNKNOWN = 1, /**< Alias for OB_STATUS_ERROR */ + + // // 00001 ~ 0999: Common errors (reserved range) + OB_ERROR_INVALID_PARAMETER = 100, /**< One or more parameters are invalid */ + OB_ERROR_INVALID_DATA = 101, /**< Data is invalid or corrupted */ + OB_ERROR_INVALID_DATA_LEN = 102, /**< Data length is invalid */ + OB_ERROR_BUFFER_TOO_SMALL = 103, /**< Target buffer is too small to hold data */ + OB_ERROR_MEMORY = 104, /**< Memory allocation or access failure */ + OB_ERROR_WAIT_TIMEOUT = 105, /**< Operation timed out */ + OB_ERROR_NOT_IMPLEMENTED = 106, /**< Functionality not implemented in SDK */ + OB_ERROR_UNSUPPORTED_OPERATION = 107, /**< Functionality not implemented in SDK */ + OB_ERROR_WRONG_API_CALL_SEQUENCE = 108, /**< API called in an invalid order or state */ + OB_ERROR_NO_DEVICE = 109, /**< No available device found */ + OB_ERROR_DEVICE_CONNECT_FAILED = 110, /**< Failed to connect to device */ + OB_ERROR_DEVICE_ACCESS_DENIED = 111, /**< Access to device denied */ + OB_ERROR_DEVICE_DISCONNECTED = 112, /**< Device was disconnected */ + OB_ERROR_DEVICE_UNAVAILABLE = 113, /**< Device was unavailable */ + OB_ERROR_ITEM_NOT_FOUND = 114, /**< Specified item or component not found */ + OB_ERROR_IO_FAILURE = 115, /**< I/O operation failed */ + OB_ERROR_RESOURCE_BUSY = 116, /**< Resource is busy or locked by another operation */ + + // - Pipeline/Frame + OB_ERROR_FRAME_QUEUE_OVERFLOW = 200, /**< Frame queue overflow */ + OB_ERROR_FRAME_DATA = 201, /**< Frame data is invalid or corrupted */ + OB_ERROR_FRAME_DATA_LEN = 202, /**< Frame data length is invalid */ + + // 1000 ~ 1999: Device errors + OB_ERROR_DEVICE_UNKNOWN = 1000, /**< Unknown device error */ + OB_ERROR_DEVICE_RESPONSE_BAD_MAGIC = 1001, /**< Device response has invalid magic number */ + OB_ERROR_DEVICE_RESPONSE_WRONG_ID = 1002, /**< Device response contains incorrect ID */ + OB_ERROR_DEVICE_RESPONSE_WRONG_OPCODE = 1003, /**< Device response contains incorrect opcode */ + OB_ERROR_DEVICE_RESPONSE_WRONG_DATA_SIZE = 1004, /**< Device response has incorrect data size */ + OB_ERROR_DEVICE_RESPONSE_ERROR = 1005, /**< Device response indicates an error */ + OB_ERROR_DEVICE_RESPONSE_WARNING = 1006, /**< Device response indicates a warning */ + OB_ERROR_DEVICE_RESPONSE_CHANNEL_FAILURE = 1007, /**< Device response channel failure, unable to communicate with the device */ + +} OBStatus, + OBErrorCode, ob_status, ob_error_code; + +/** + * @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 */ + OB_EXCEPTION_TYPE_ACCESS_DENIED, /**< Device access denied */ + OB_EXCEPTION_TYPE_DEVICE_UNAVAILABLE, /**< Camera or Device is not available */ + OB_EXCEPTION_TYPE_INVALID_DATA, /**< Runtime data is invalid, check data content or size */ + OB_EXCEPTION_TYPE_NOT_FOUND, /**< The requested item was not found */ + OB_EXCEPTION_TYPE_RESOURCE_BUSY, /**< Resource is busy or locked by another operation */ + OB_EXCEPTION_TYPE_LICENSE_VERIFY_FAILED, /**< License verification failed, the device/feature license is missing, invalid or expired */ +} 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 GVCP port scheme + */ +typedef enum { + OB_GVCP_PORT_SCHEME_STANDARD = 0, /**< Standard GVCP port (3956) */ + OB_GVCP_PORT_SCHEME_B = 1, /**< Vendor-defined GVCP port scheme */ +} OBGvcpPortScheme, + ob_gvcp_port_scheme; + +/** + * @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_CONFIDENCE = 9, /**< Confidence */ + OB_SENSOR_LIDAR = 10, /**< LiDAR */ + OB_SENSOR_COLOR_LEFT = 11, /**< Left Color */ + OB_SENSOR_COLOR_RIGHT = 12, /**< Right Color */ + 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_CONFIDENCE = 9, /**< Confidence Stream*/ + OB_STREAM_LIDAR = 10, /**< LiDAR Stream for LiDAR device*/ + OB_STREAM_COLOR_LEFT = 11, /**< Left Color stream */ + OB_STREAM_COLOR_RIGHT = 12, /**< Right Color 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_CONFIDENCE = 11, /**< Confidence frame*/ + OB_FRAME_LIDAR_POINTS = 12, /**< LiDAR point3d cloud frame*/ + OB_FRAME_COLOR_LEFT = 13, /**< Left Color frame */ + OB_FRAME_COLOR_RIGHT = 14, /**< Right Color 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 */ + OB_FORMAT_Y12C4 = 34, /**< Y12C4 format */ + OB_FORMAT_LIDAR_POINT = 35, /**< XYZ 3D coordinate point format with LiDAR information, @ref OBLiDARPoint */ + OB_FORMAT_LIDAR_SPHERE_POINT = 36, /**< Spherical coordinate point format with LiDAR information, @ref OBLiDARSpherePoint */ + OB_FORMAT_LIDAR_SCAN = 37, /**< LiDAR single-line scan mode data format, @ref OBLiDARScanPoint */ + OB_FORMAT_LIDAR_CALIBRATION = 38, /**< LiDAR calibration mode point 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_REBOOT_AND_REUPDATE = 7, /**< update completed and device requires manual reboot and a second update*/ + 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 */ + ERR_FILE_READ = -12, /**< Read image file error */ + ERR_TRANSFER = -13 /**< Transfer failed */ +} 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 A read-only, non-owning view over a byte buffer (a data pointer plus its size) + */ +typedef struct { + const uint8_t *data; ///< Pointer to the data + uint32_t dataSize; ///< Size of the data in bytes +} OBDataView, ob_data_view; + +/** + * @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; + +typedef struct { + int16_t width; ///< width + int16_t height; ///< height + int irDecimationFactor; ///< ir decimation factor + int depthDecimationFactor; ///< depth decimation factor +} OBPresetResolutionConfig, ob_preset_resolution_ratio_config; + +/** + * @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 */ + ALIGN_C2D_SW_MODE, /**< Software C2D 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 Data structures for LiDAR scan rate + */ +typedef enum { + OB_LIDAR_SCAN_UNKNOWN = 0, + OB_LIDAR_SCAN_5HZ = 1, + OB_LIDAR_SCAN_10HZ = 2, + OB_LIDAR_SCAN_15HZ = 3, + OB_LIDAR_SCAN_20HZ = 4, + OB_LIDAR_SCAN_25HZ = 5, + OB_LIDAR_SCAN_30HZ = 6, + OB_LIDAR_SCAN_40HZ = 7, +} OBLiDARScanRate, + ob_lidar_scan_rate, OB_LIDAR_SCAN_RATE; + +/** + * @brief Device state + */ +typedef uint64_t OBDeviceState, ob_device_state; + +/** + * @brief Pipeline issue location flags observed during streaming. + */ +typedef enum { + OB_PIPELINE_ISSUE_NONE = 0x00, /**< No issue observed */ + OB_PIPELINE_ISSUE_SDK = 0x01, /**< Issue observed in SDK */ + OB_PIPELINE_ISSUE_DRIVER = 0x02, /**< Issue observed in driver */ + OB_PIPELINE_ISSUE_FW = 0x04, /**< Issue observed in device firmware */ + OB_PIPELINE_ISSUE_HW = 0x08, /**< Issue observed in device hardware */ +} OBPipelineIssue, + ob_pipeline_issue; + +/** + * @brief SDK-defined pipeline status bits observed during streaming. + */ +#define OB_SDK_STATUS_FRAME_DROP_DATA (1ULL << 0) /**< Frame dropped due to data error */ +#define OB_SDK_STATUS_FRAME_DROP_TIMESTAMP (1ULL << 1) /**< Frame dropped due to timestamp error */ +#define OB_SDK_STATUS_FRAME_DROP_MATCH (1ULL << 2) /**< Frame dropped due to aggregation match failure */ +#define OB_SDK_STATUS_FRAME_QUEUE_OVERFLOW (1ULL << 3) /**< Frame dropped due to queue overflow */ +#define OB_SDK_STATUS_FRAME_WAIT_TIMEOUT (1ULL << 4) /**< Wait for frame timeout */ +#define OB_SDK_STATUS_STREAM_NO_FRAME (1ULL << 5) /**< A stream has not received any frame for a prolonged period */ + +/** + * @brief Pipeline status observed during streaming. + */ +typedef struct { + OBPipelineIssue issue; /**< Issue location flags */ + uint64_t sdkStatus; /**< SDK-defined bitmask composed of OB_SDK_STATUS_* macros */ + uint64_t devStatus; /**< Device-specific diagnostic bits (not for application logic) */ + uint64_t drvStatus; /**< Driver-specific diagnostic bits (not for application logic) */ + uint64_t reserved[3]; /**< Reserved for future use */ +} OBPipelineStatus, ob_pipeline_status; + +/** + * @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 3D point structure with LiDAR information + */ +typedef struct { + float angle; ///< angle, unit: degrees + float distance; ///< distance, unit: mm + uint16_t intensity; ///< intensity, 0~2000 +} OBLiDARScanPoint, ob_lidar_scan_point; + +/** + * @brief 3D point structure with LiDAR information + */ +typedef struct { + float x; ///< X coordinate, unit mm + float y; ///< Y coordinate, unit mm + float z; ///< Z coordinate, unit mm + uint8_t reflectivity; ///< reflectivity + uint8_t tag; ///< point state +} OBLiDARPoint, ob_lidar_point; + +/** + * @brief 3D point structure with LiDAR information + */ +typedef struct { + float distance; ///< distance, unit: mm + float theta; ///< azimuth angle, unit: degrees + float phi; ///< zenith angle, unit: degrees + uint8_t reflectivity; ///< reflectivity + uint8_t tag; ///< tag +} OBLiDARSpherePoint, ob_lidar_sphere_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 radius; // window_size +} OBSpatialFastFilterParams, ob_spatial_fast_filter_params; + +typedef struct { + uint8_t radius; // window_size + uint8_t magnitude; // magnitude + uint16_t disp_diff; // smooth_delta +} OBSpatialModerateFilterParams, ob_spatial_moderate_filter_params; + +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; + +/** + * @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; + +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 +} OBEdgeNoiseRemovalFilterParams, ob_edge_noise_removal_filter_params; + +/** + * @brief Configuration parameters for the MGC noise removal filter + */ +typedef struct { + int max_width_left; ///< Left chamfer threshold settings + int max_width_right; ///< Right chamfer threshold settings + int max_radius; ///< Chamfer radius threshold settings + 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; ///< Depth map width the above parameters correspond to + uint32_t height; ///< Depth map height the above parameters correspond to +} OBMgcNoiseRemovalFilterParams, ob_mgc_noise_removal_filter_params; + +/** + * @brief Configuration parameters for the LUT noise removal filter + */ +typedef struct { + uint16_t max_lut[16]; ///< LUT max size of noise pixels (4x4 LUT, 16 entries total) + uint16_t min_diff; ///< Difference threshold between neighbor pixels + uint32_t width; ///< Depth map width the above parameters correspond to + uint32_t height; ///< Depth map height the above parameters correspond to +} OBLutNoiseRemovalFilterParams, ob_lut_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), used with property OB_STRUCT_DEVICE_IP_ADDR_CONFIG. + * + * @note Device support: + * - Femto Mega / Femto Mega I: only this structure is supported. + * - Gemini 335Le / Gemini 435Le with older firmware: only this structure is supported. + * - Gemini 335Le / Gemini 435Le with newer firmware: both this structure and @ref OBNetIpConfigV2 are supported; + * it is recommended to use @ref OBNetIpConfigV2 (property OB_STRUCT_DEVICE_IP_ADDR_CONFIG_V2) instead. + * + * @note How to choose between OBNetIpConfig and OBNetIpConfigV2: + * First check whether OB_STRUCT_DEVICE_IP_ADDR_CONFIG_V2 is supported by the device. If yes, use @ref OBNetIpConfigV2; + * otherwise fall back to this structure. + * Example: + * @code + * bool v2Supported = ob_device_is_property_supported(dev, OB_STRUCT_DEVICE_IP_ADDR_CONFIG_V2, + * OB_PERMISSION_READ_WRITE, &error); + * if(v2Supported) { + * // Use OBNetIpConfigV2 with OB_STRUCT_DEVICE_IP_ADDR_CONFIG_V2 + * } else { + * // Use OBNetIpConfig with OB_STRUCT_DEVICE_IP_ADDR_CONFIG + * } + * @endcode + */ +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 + +// IP bit masks +#define OB_NET_IP_FLAG_DHCP (0x01u) +#define OB_NET_IP_FLAG_PERSISTENT (0x02u) + +/** + * @brief IP address configuration v2 for network devices (IPv4), used with property OB_STRUCT_DEVICE_IP_ADDR_CONFIG_V2. + * + * @note This is the recommended structure for Gemini 335Le / Gemini 435Le devices with newer firmware. + * It extends @ref OBNetIpConfig by replacing the single @c dhcp field with a @c flags bitmask that supports + * both DHCP mode and Persistent IP mode. + * + * @note Device support: + * - Femto Mega / Femto Mega I: NOT supported; use @ref OBNetIpConfig instead. + * - Gemini 335Le / Gemini 435Le with older firmware: NOT supported; use @ref OBNetIpConfig instead. + * - Gemini 335Le / Gemini 435Le with newer firmware: supported and recommended. + * + * @note Before using this structure, verify support at runtime: + * @code + * bool v2Supported = ob_device_is_property_supported(dev, OB_STRUCT_DEVICE_IP_ADDR_CONFIG_V2, + * OB_PERMISSION_READ_WRITE, &error); + * @endcode + */ +typedef struct { + uint16_t flags; ///< IP configuration mode flags + ///< bit0: DHCP enable (1=on, 0=off) + ///< bit1: Persistent IP enable (1=on, 0=off) + ///< bit[2:15]: reserved, must be 0 + uint8_t address[4]; ///< IP address (IPv4, big-endian, e.g. 192.168.1.1 -> address[0]=192) + uint8_t mask[4]; ///< Subnet mask (big-endian) + uint8_t gateway[4]; ///< Gateway (big-endian) +} OBNetIpConfigV2, ob_net_ip_config_v2, DEVICE_IP_ADDR_CONFIG_V2; + +/** + * @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 Color camera preset + */ +typedef enum { + /** + * @brief Suitable for standard single-color-temperature lighting environments (e.g., typical indoor white LED or office lighting). + * This strategy serves as the system's default mode to achieve a balanced and natural white balance effect. + */ + OB_DEFAULT = 0, + + /** + * @brief Warm Biased AWB for mixed lighting is designed for mixed illumination combining standard white light and low-CCT sources (warm/yellow/red). + * This profile applies a controlled warm bias after AWB convergence to reduce blue cast in white-lit regions and deliver a more consistent, + * warm-leaning appearance in mixed-light scenes. + */ + OB_WARM_BIASED_AWB = 1, +} OBColorPreset, + ob_color_preset; + +/** + * @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 + * OBMultiDeviceSyncConfig::colorDelayUs, @ref OBMultiDeviceSyncConfig::depthDelayUs or @ref OBMultiDeviceSyncConfig::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 + * OBMultiDeviceSyncConfig::colorDelayUs, @ref OBMultiDeviceSyncConfig::depthDelayUs or @ref OBMultiDeviceSyncConfig::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 + * OBMultiDeviceSyncConfig::colorDelayUs, @ref OBMultiDeviceSyncConfig::depthDelayUs or @ref OBMultiDeviceSyncConfig::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 + * OBMultiDeviceSyncConfig::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 + * OBMultiDeviceSyncConfig::colorDelayUs, @ref OBMultiDeviceSyncConfig::depthDelayUs or @ref OBMultiDeviceSyncConfig::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 OBMultiDeviceSyncConfig::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 + * OBMultiDeviceSyncConfig::colorDelayUs, @ref OBMultiDeviceSyncConfig::depthDelayUs or @ref OBMultiDeviceSyncConfig::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, + + /** + * @brief The device captures data in software synchronization mode, starting acquisition based on the system time. + */ + OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_SYNCED = 1 << 8, +} 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 Extensible options for activating a private filter instance. + * @brief Passed to @ref ob_filter_activate_private_ex / @ref ob_priv_filter_activate_ex. New fields must only be + * appended at the end. The caller sets @ref struct_size to sizeof(ob_priv_filter_activate_options); the callee + * uses it to detect which fields a (possibly older) caller actually provided, keeping the ABI compatible as the + * struct grows. This is the single extension point for future activation parameters. + */ +typedef struct ob_priv_filter_activate_options { + uint32_t struct_size; ///< Size of this struct in bytes, set by the caller to sizeof(ob_priv_filter_activate_options). + const char *model_path; ///< Path to the inference model file. NULL or empty selects the filter's default model. +}OBPrivFilterActivateOptions, ob_priv_filter_activate_options; + +/** + * @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; + +/** + * @details Defines the original resolution and hardware decimation factor. + */ +typedef struct { + uint32_t originWidth; ///< Origin width + uint32_t originHeight; ///< Origin height + uint32_t factor; ///< Decimation factor +} OBHardwareDecimationConfig, ob_hardware_decimation_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; + +/** + * @brief Intra-camera Sync Reference based on the exposure start time, the exposure middle time, or the exposure end time. + */ +typedef enum { + OB_START_OF_EXPOSURE = 0, /**< start of exposure */ + OB_MIDDLE_OF_EXPOSURE, /**< middle of exposure */ + OB_END_OF_EXPOSURE, /**< end of exposure */ +} ob_intra_camera_sync_reference, + OBIntraCameraSyncReference; + +// 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 +#define START_OF_EXPOSURE OB_START_OF_EXPOSURE +#define MIDDLE_OF_EXPOSURE OB_MIDDLE_OF_EXPOSURE +#define END_OF_EXPOSURE OB_END_OF_EXPOSURE + +/** + * @brief Device access mode for GVCP device + */ +typedef enum { + OB_DEVICE_ACCESS_DENIED = 0, ///< No access. This value is only used as a return value + OB_DEVICE_EXCLUSIVE_ACCESS = 1, ///< Exclusive access: full read/write, no other application allowed; can preempt existing monitor access + OB_DEVICE_CONTROL_ACCESS = 2, ///< Control access: read/write allowed; other applications permitted read-only monitor access + OB_DEVICE_MONITOR_ACCESS = 3, ///< Monitor access: read-only; no write or control privileges + OB_DEVICE_DEFAULT_ACCESS = 4, ///< Default access: control access for capable devices, ignored otherwise +} ob_device_access_mode, + OBDeviceAccessMode; + +/** + * @brief Device access state queried from GVCP CCP without opening the device. + */ +typedef enum { + OB_DEVICE_ACCESS_STATE_UNKNOWN = 0, ///< The access state cannot be determined + OB_DEVICE_ACCESS_STATE_UNSUPPORTED = 1, ///< The device or current build does not support access-state query + OB_DEVICE_ACCESS_STATE_AVAILABLE = 2, ///< The device is available for control access + OB_DEVICE_ACCESS_STATE_CONTROLLED = 3, ///< The device has a controller; monitor access may still be available + OB_DEVICE_ACCESS_STATE_EXCLUSIVE = 4, ///< The device is held exclusively and cannot be accessed + OB_DEVICE_ACCESS_STATE_UNREACHABLE = 5, ///< The device did not respond or the network path is unreachable + OB_DEVICE_ACCESS_STATE_FW_NOT_SUPPORTED = 6, ///< The device supports CCP, but the firmware version is too old +} ob_device_access_state, + OBDeviceAccessState; + +typedef enum { + OB_IP_SOURCE_NONE = 0, ///< No IP configuration active (e.g. USB device). + OB_IP_SOURCE_LLA = 1, ///< LLA (Link-Local Address / Auto IP). + OB_IP_SOURCE_DHCP = 2, ///< DHCP (Dynamic Host Configuration Protocol). + OB_IP_SOURCE_PERSISTENT = 3, ///< Persistent IP (Static IP stored in memory). +} ob_ip_source_type, + OBIpSourceType; + +/** + * @brief Host-side timestamp clock type for device. + */ +typedef enum { + OB_CLOCK_TYPE_REALTIME = 0, /**< Wall clock (system_clock), epoch-based. Default. */ + OB_CLOCK_TYPE_MONOTONIC = 1, /**< System monotonic clock, non-epoch. */ +} OBClockType, + ob_clock_type; + +/** + * @brief Callback for file transfer + * + * @param[in] state Transmission status + * @param[in] message Transfer status information + * @param[in] percent Transfer progress percentage + * @param[in] 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[in] state Upgrade status + * @param[in] message Upgrade status information + * @param[in] percent Upgrade progress percentage + * @param[in] 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[in] state Device status + * @param[in] message Device status information + * @param[in] 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[in] state Write data status + * @param[in] percent Write data percentage + * @param[in] 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[in] state Read data status + * @param[in] dataChunk Read the returned data block + * @param[in] 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[in] state Condition + * @param[in] user_data User-defined data + */ +typedef void (*ob_media_state_callback)(ob_media_state state, void *user_data); + +/** + * @brief Callback for device change + * + * @param[in] removed List of deleted (dropped) devices + * @param[in] added List of added (online) devices + * @param[in] 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[in] frame Frame object + * @param[in] 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[in] frameset Frameset object + * @param[in] user_data User-defined data + */ +typedef void (*ob_frameset_callback)(ob_frame *frameset, void *user_data); + +/** + * @brief Customize the delete callback + * + * @param[in] buffer Data that needs to be deleted + * @param[in] user_data User-defined data + */ +typedef void(ob_frame_destroy_callback)(uint8_t *buffer, void *user_data); + +/** + * @brief Callback for receiving log + * + * @param[in] severity Current log level + * @param[in] message Log message + * @param[in] user_data User-defined data + */ +typedef void(ob_log_callback)(ob_log_severity severity, const char *message, void *user_data); + +/** + * @brief Callback for playback status notification + * + * @param[in] status Playback status + * @param[in] user_data User-defined data + */ +typedef void (*ob_playback_status_changed_callback)(ob_playback_status status, void *user_data); + +/** + * @brief Callback for pipeline status notification + * + * @param[in] status Pipeline status + * @param[in] user_data User-defined data + */ +typedef void (*ob_pipeline_status_callback)(ob_pipeline_status status, void *user_data); + +/** + * @brief Callback Id + */ +typedef uint64_t OBCallbackId, ob_callback_id; +#define INVALID_CALLBACK_ID (0) + +/** + * @brief Check if the sensor_type is a video sensor + * + * @param[in] 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_COLOR_LEFT || sensor_type == OB_SENSOR_COLOR_RIGHT || sensor_type == OB_SENSOR_DEPTH \ + || sensor_type == OB_SENSOR_IR || sensor_type == OB_SENSOR_IR_LEFT || sensor_type == OB_SENSOR_IR_RIGHT || sensor_type == OB_SENSOR_CONFIDENCE) + +/** + * @brief check if the stream_type is a video stream + * + * @param[in] 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_COLOR_LEFT || stream_type == OB_STREAM_COLOR_RIGHT || 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 \ + || stream_type == OB_STREAM_CONFIDENCE) + +/** + * @brief Check if sensor_type is an IR sensor + * + * @param[in] 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 sensor_type is an Color sensor + * + * @param sensor_type Sensor type to check + * @return True if sensor_type is an Color sensor, false otherwise + */ +#define is_color_sensor(sensor_type) (sensor_type == OB_SENSOR_COLOR || sensor_type == OB_SENSOR_COLOR_LEFT || sensor_type == OB_SENSOR_COLOR_RIGHT) +#define isColorSensor is_color_sensor + +/** + * @brief Check if stream_type is an IR stream + * + * @param[in] 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 stream_type is an Color stream + * + * @param stream_type Stream type to check + * @return True if stream_type is an Color stream, false otherwise + */ +#define is_color_stream(stream_type) (stream_type == OB_STREAM_COLOR || stream_type == OB_STREAM_COLOR_LEFT || stream_type == OB_STREAM_COLOR_RIGHT) +#define isColorStream is_color_stream + +/** + * @brief Check if frame_type is an IR frame + * + * @param[in] 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 Check if frame_type is an Color frame + * + * @param frame_type Frame type to check + * @return True if frame_type is an Color frame, false otherwise + */ +#define is_color_frame(frame_type) (frame_type == OB_FRAME_COLOR || frame_type == OB_FRAME_COLOR_LEFT || frame_type == OB_FRAME_COLOR_RIGHT) +#define isColorFrame is_color_frame + +/** + * @brief The default Decrypt Key + */ +#define OB_DEFAULT_DECRYPT_KEY (nullptr) + +#ifdef __cplusplus +} +#endif + +#pragma pack(pop) diff --git a/orbbec_camera/SDK/x64/include/libobsensor/h/Pipeline.h b/orbbec_camera/SDK/x64/include/libobsensor/h/Pipeline.h new file mode 100644 index 00000000..67280b71 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/Pipeline.h @@ -0,0 +1,411 @@ +// 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 + * @ref 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 a video stream using a decimation configuration. + * + * @attention The stream_type should be a video stream type, such as OB_STREAM_IR, 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] decimation_config The decimation configuration for the 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_by_decimation_config(ob_config *config, ob_stream_type stream_type, + ob_hardware_decimation_config decimation_config, 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 Enable LiDAR stream with specified parameters + * + * @param[in] config The pipeline configuration object + * @param[in] scan_rate The scan rate of LiDAR + * @param[in] format The format of the LiDAR stream + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_config_enable_lidar_stream(ob_config *config, ob_lidar_scan_rate scan_rate, ob_format format, ob_error **error); + +/** + * @brief Get the enabled stream profile list 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. + * + * @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); + +/** + * @brief Get the current pipeline status observed during streaming. + * + * @note This function returns the accumulated status since the last call or since the pipeline was (re)started. + * The status is reset after each call. It is recommended to call this when no frames have been received + * for a period of time. If the status indicates a data error or no-frame condition, the SDK will also + * attempt to fetch device and driver status (with throttling to avoid excessive device communication). + * + * @param[in] pipeline The pipeline object + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return ob_pipeline_status Pipeline status reflecting events observed since the previous call. + */ +OB_EXPORT ob_pipeline_status ob_pipeline_get_status(ob_pipeline *pipeline, ob_error **error); + +/** + * @brief Enable pipeline health monitor with periodic status polling. + * + * @note When enabled, an internal polling thread will periodically check the pipeline status (including SDK frame + * drops, device error state, and driver status). If any abnormal status is detected, the callback will be + * invoked. The callback is invoked from an internal thread; avoid blocking operations in the callback. + * + * @param[in] pipeline The pipeline object + * @param[in] callback The callback function to be invoked when abnormal status is detected + * @param[in] user_data User-defined data passed to the callback + * @param[in] interval_ms Polling interval in milliseconds (recommended: 3000-5000) + * @param[out] error Pointer to an error object that will be set if an error occurs. + */ +OB_EXPORT void ob_pipeline_enable_health_monitor(ob_pipeline *pipeline, ob_pipeline_status_callback callback, void *user_data, uint32_t interval_ms, + ob_error **error); + +/** + * @brief Disable pipeline health monitor. + * + * @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_health_monitor(ob_pipeline *pipeline, 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/orbbec_camera/SDK/x64/include/libobsensor/h/Property.h b/orbbec_camera/SDK/x64/include/libobsensor/h/Property.h new file mode 100644 index 00000000..43896ad2 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/Property.h @@ -0,0 +1,1160 @@ +// 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 Depth outliers filter switch + */ + OB_PROP_DEPTH_OUTLIERS_FILTER_BOOL = 25, + + /** + * @brief Depth outliers filter search range mode + */ + OB_PROP_DEPTH_OUTLIERS_FILTER_SEARCH_MODE_INT = 26, + + /** + * @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: positive 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 cpu temperature correction . true: calibrate temperature + */ + OB_PROP_CPU_TEMPERATURE_CALIBRATION_BOOL = 199, + + /** + * @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 Depth with confidence stream enable + */ + OB_PROP_DEPTH_WITH_CONFIDENCE_STREAM_ENABLE_BOOL = 224, + + /** + * @brief Enable or disable confidence stream filter + */ + OB_PROP_CONFIDENCE_STREAM_FILTER_BOOL = 226, + + /** + * @brief Confidence stream filter threshold, range [0, 255] + */ + OB_PROP_CONFIDENCE_STREAM_FILTER_THRESHOLD_INT = 227, + + /** + * @brief Confidence stream mirror enable + */ + OB_PROP_CONFIDENCE_MIRROR_BOOL = 229, + + /** + * @brief Confidence stream flip enable + */ + OB_PROP_CONFIDENCE_FLIP_BOOL = 230, + + /** + * @brief Confidence stream rotate angle{0, 90, 180, 270} + */ + OB_PROP_CONFIDENCE_ROTATE_INT = 231, + + /** + * @brief Intra-camera Sync Reference based on the exposure start time, the exposure middle time, or the exposure end time. the definition in @ref + * OBIntraCameraSyncReference + */ + OB_PROP_INTRA_CAMERA_SYNC_REFERENCE_INT = 236, + + /** + * @brief Right Color sensor rotation, angle{0, 90, 180, 270} + */ + OB_PROP_COLOR_RIGHT_ROTATE_INT = 242, + + /** + * @brief Right Color mirror + */ + OB_PROP_COLOR_RIGHT_MIRROR_BOOL = 243, + + /** + * @brief Right Color flip + */ + OB_PROP_COLOR_RIGHT_FLIP_BOOL = 244, + + /** + * @brief Device AE reference source + * - 0: Depth based + * - 1: Color based + */ + OB_PROP_DEVICE_AE_REFERENCE_INT = 247, + + /** + * @brief Device AE strategy + * - 0: Default + * - 1: Motion + */ + OB_PROP_DEVICE_AE_STRATEGY_INT = 248, + + /** + * @brief Color camera ROI brightness adjustment + */ + OB_PROP_COLOR_ROI_BRIGHTNESS_INT = 249, + + /** + * @brief Left Color sensor rotation, angle{0, 90, 180, 270} + */ + OB_PROP_COLOR_LEFT_ROTATE_INT = 251, + + /** + * @brief Left Color mirror + */ + OB_PROP_COLOR_LEFT_MIRROR_BOOL = 252, + + /** + * @brief Left Color flip + */ + OB_PROP_COLOR_LEFT_FLIP_BOOL = 253, + + /** + * @brief Color camera preset priority + */ + OB_PROP_COLOR_PRESET_PRIORITY_INT = 255, + + /** + * @brief LLA (Link Local Address) switch + * + * @deprecated The property is deprecated + */ + OB_PROP_DEVICE_NETWORK_LLA_BOOL = 257, + + /** + * @brief Color anti-flicker switch + */ + OB_PROP_COLOR_ANTI_FLICKER_BOOL = 259, + + /** + * @brief Device IP mode + * @param value + * - 0: AMR Sensor Mode. + * Typically configured for ehternet interface sensors for AMRs. + * When DHCP is enabled and the device fails to obtain a valid IP address, it falls back to Persistent IP. + * If neither of Persistent IP and DHCP is specified, Persistent IP is enabled by default. + * + * - 1: Industrial Sensor Mode. + * Typically configured for ehternet interface sensors for industrial applications. + * When DHCP is enabled and the device fails to obtain a valid IP address, it falls back to LLA (Link-Local Address). + * If Persistent IP and DHCP are both enabled, the sensor starts with the attemp to used the specified persistent IP + * and falls back to DHCP if Persistent IP fails. + */ + OB_PROP_DEVICE_IP_MODE_INT = 260, + + /** + * @brief DHCP assign IP timeout, unit: second + */ + OB_PROP_DHCP_ASSIGN_IP_TIMEOUT_INT = 261, + + /** + * @brief USB sync I/O voltage level + */ + OB_PROP_USB_SYNC_VOLTAGE_LEVEL_INT = 270, + + /** + * @brief Get the current disparity search range mode value + * + * @attention read only + */ + OB_PROP_CURRENT_DISP_SEARCH_RANGE_MODE_INT = 271, + + /** + * @brief Get the current disparity search offset value + * + * @attention read only + */ + OB_PROP_CURRENT_DISP_SEARCH_OFFSET_INT = 272, + + /** + * @brief Enable FPS boost in trigger mode + */ + OB_PROP_FPS_BOOST_BOOL = 275, + + /** + * @brief MJPEG encoding quality factor + */ + OB_PROP_MJPEG_QUALITY_INT = 277, + + /** + * @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 + * @see OBNetIpConfig + */ + 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 + * @see OBNetIpConfig + * + * @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 Preset resolution ratio configuration + */ + OB_STRUCT_PRESET_RESOLUTION_CONFIG = 1069, + + /** + * @brief Color sensor synchronized exposure parameter structure + */ + OB_STRUCT_COLOR_SYNCED_EXPOSURE_PARAM = 1077, + + /** + * @brief Device IP address configuration v2 + * @see OBNetIpConfigV2 + */ + OB_STRUCT_DEVICE_IP_ADDR_CONFIG_V2 = 1088, + + /** + * @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 AE max gain + */ + OB_PROP_COLOR_AE_MAX_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 Depth Stream Industry Working Mode Settings, currently only supported by DCW2. + */ + OB_PROP_DEPTH_INDUSTRY_MODE_INT = 3024, + + /** + * @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, + + /** + * @brief Color camera CCI denoising level. 0: Auto; 1-8: higher values indicate stronger denoising. + * @note This setting has no effect when AE (Auto Exposure) is disabled. + */ + OB_PROP_COLOR_DENOISING_LEVEL_INT = 5525, + + /** + * @brief Indicates whether the device will go offline after applying IP configuration. + * This property does not represent an actual command; it is a capability flag only, + * used to identify whether the current device has the behavior of going offline after IP config is applied. + */ + OB_PROP_DEVICE_OFFLINE_AFTER_IP_CONFIG_APPLY = 5555, + + /* + * @brief LiDAR: set/get IP address + */ + OB_RAW_DATA_LIDAR_IP_ADDRESS = 8000, + + /** + * @brief LiDAR: set/get port + */ + OB_PROP_LIDAR_PORT_INT = 8001, + + /** + * @brief LiDAR: set/get MAC address + */ + OB_RAW_DATA_LIDAR_MAC_ADDRESS = 8002, + + /** + * @brief LiDAR: set/get subnet mask + */ + OB_RAW_DATA_LIDAR_SUBNET_MASK = 8003, + + /** + * @brief LiDAR: set/get work mode + */ + OB_PROP_LIDAR_WORK_MODE_INT = 8004, + + /** + * @brief LiDAR: apply configs + */ + OB_PROP_LIDAR_APPLY_CONFIGS_INT = 8005, + + /** + * @brief LiDAR: set/get tail filter level + */ + OB_PROP_LIDAR_TAIL_FILTER_LEVEL_INT = 8006, + + /** + * @brief LiDAR: set/get mems fov size + */ + OB_PROP_LIDAR_MEMS_FOV_SIZE_FLOAT = 8007, + + /** + * @brief LiDAR: set/get mems frequency + */ + OB_PROP_LIDAR_MEMS_FRENQUENCY_FLOAT = 8008, + + /** + * @brief LiDAR: get product model + */ + OB_RAW_DATA_LIDAR_PRODUCT_MODEL = 8009, + + /** + * @brief LiDAR: get firmware version + */ + OB_RAW_DATA_LIDAR_FIRMWARE_VERSION = 8010, + + /** + * @brief LiDAR: get fpga version + */ + OB_RAW_DATA_LIDAR_FPGA_VERSION = 8011, + + /** + * @brief LiDAR: get warning info + */ + OB_PROP_LIDAR_WARNING_INFO_INT = 8012, + + /** + * @brief LiDAR: get realtime motor spin speed, unit:0.01rpm + */ + OB_PROP_LIDAR_MOTOR_SPIN_SPEED_INT = 8013, + + /** + * @brief LiDAR: get mcu temperature, uint: 0.01degrees delsius + */ + OB_PROP_LIDAR_MCU_TEMPERATURE_INT = 8014, + + /** + * @brief LiDAR: get apd temperature, uint: 0.01degrees delsius + */ + OB_PROP_LIDAR_APD_TEMPERATURE_INT = 8015, + + /** + * @brief LiDAR: get/set specific mode + */ + OB_PROP_LIDAR_SPECIFIC_MODE_INT = 8016, + + /** + * @brief LiDAR: get/set repetitive scan mode + */ + OB_PROP_LIDAR_REPETITIVE_SCAN_MODE_INT = 8017 +} 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/orbbec_camera/SDK/x64/include/libobsensor/h/RecordPlayback.h b/orbbec_camera/SDK/x64/include/libobsensor/h/RecordPlayback.h new file mode 100644 index 00000000..6102c2b1 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/RecordPlayback.h @@ -0,0 +1,141 @@ +// 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[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 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/orbbec_camera/SDK/x64/include/libobsensor/h/Sensor.h b/orbbec_camera/SDK/x64/include/libobsensor/h/Sensor.h new file mode 100644 index 00000000..4e1fc1fd --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/Sensor.h @@ -0,0 +1,138 @@ +// 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/orbbec_camera/SDK/x64/include/libobsensor/h/StreamProfile.h b/orbbec_camera/SDK/x64/include/libobsensor/h/StreamProfile.h new file mode 100644 index 00000000..e5a014ce --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/StreamProfile.h @@ -0,0 +1,505 @@ +// 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[in] type Stream type + * @param[in] format Stream format + * @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 gyro 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 Create a LiDAR stream profile object + * + * @param[in] scan_rate The scan rate of LiDAR + * @param[in] format The format of the LiDAR stream + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return ob_stream_profile* return the LiDAR stream profile object + */ +OB_EXPORT ob_stream_profile *ob_create_lidar_stream_profile(ob_lidar_scan_rate scan_rate, ob_format format, 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[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_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 Get the decimation configuration 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_hardware_decimation_config Return the decimation configuration of the stream. + */ +OB_EXPORT ob_hardware_decimation_config ob_video_stream_profile_get_decimation_config(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 scan rate of the LiDAR stream. + * + * @param[in] profile Stream profile object. If the profile is not for the LiDAR stream, an error will be returned. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * @return The scan rate of the LiDAR stream. + */ +OB_EXPORT ob_lidar_scan_rate ob_lidar_stream_profile_get_scan_rate(const ob_stream_profile *profile, 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 based on the provided decimation configuration. If multiple profiles match, the first profile in the list + * is returned by default. If no matched profile is found, an error will be returned. + * + * @attention The stream profile returned by this function should be released with @ref ob_delete_stream_profile() when it is no longer needed. + * + * @param[in] profile_list The list of stream profiles. + * @param[in] decimation_config Decimation configuration. The actual resolution is determined by original resolution and the scale factor. + * @param[in] format Stream format. If no matching condition is required, pass OB_FORMAT_ANY. + * @param[in] fps Frame rate. If no matching condition is required, pass OB_FPS_ANY. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return The matched stream profile. + */ +OB_EXPORT ob_stream_profile *ob_stream_profile_list_get_video_stream_profile_by_decimation_config(const ob_stream_profile_list *profile_list, + ob_hardware_decimation_config decimation_config, + 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 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] scan_rate The scan rate of LiDAR. If you don't need to add matching conditions, you can pass OB_LIDAR_SCAN_ANY. + * @param[in] format The format of the LiDAR stream. If you don't need to add matching conditions, you can pass OB_FORMAT_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_lidar_stream_profile(const ob_stream_profile_list *profile_list, ob_lidar_scan_rate scan_rate, + ob_format format, 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/orbbec_camera/SDK/x64/include/libobsensor/h/TypeHelper.h b/orbbec_camera/SDK/x64/include/libobsensor/h/TypeHelper.h new file mode 100644 index 00000000..2a72ad50 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/TypeHelper.h @@ -0,0 +1,165 @@ +// 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 OBIMUSampleRate to its numeric frequency value in Hz. + * + * @param[in] type OBIMUSampleRate type. + * + * @return IMU sample rate value in Hz. Returns 0 for unknown values. + */ +OB_EXPORT float ob_imu_rate_type_to_value(OBIMUSampleRate type); + +/** + * @brief Convert a numeric IMU sample rate value in Hz to OBIMUSampleRate. + * + * @param[in] value IMU sample rate value in Hz. + * + * @return Matching OBIMUSampleRate. Returns OB_SAMPLE_RATE_UNKNOWN when no exact SDK rate matches. + */ +OB_EXPORT OBIMUSampleRate ob_imu_rate_value_to_type(float value); + +/** + * @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 OBLiDARScanRate to " char* " type and then return. + * + * @param[in] type OBLiDARScanRate type. + * @return OBLiDARScanRate of "char*" type. + */ +OB_EXPORT const char *ob_lidar_scan_rate_type_to_string(OBLiDARScanRate 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 OBSensorType to OBStreamType. + * + * @param[in] type The sensor type to convert. + * + * @return The corresponding stream type. + */ +OB_EXPORT OBStreamType ob_sensor_type_to_stream_type(OBSensorType type); + +/** + * @brief Convert OBStreamType to OBSensorType. + * + * @param[in] type The stream type to convert. + * + * @return The corresponding sensor type. + */ +OB_EXPORT OBSensorType ob_stream_type_to_sensor_type(OBStreamType type); + +/** + * @brief Convert OBStreamType to OBFrameType. + * + * @param[in] type The stream type to convert. + * + * @return The corresponding frame type. + */ +OB_EXPORT OBFrameType ob_stream_type_to_frame_type(OBStreamType type); + +/** + * @brief Convert OBFrameType to OBStreamType. + * + * @param[in] type The frame type to convert. + * + * @return The corresponding stream type. + */ +OBStreamType ob_frame_type_to_stream_type(OBFrameType type); + +/** + * @brief Convert OBFrameType to OBSensorType. + * + * @param[in] type The frame type to convert. + * + * @return The corresponding sensor type. + */ +OB_EXPORT OBSensorType ob_frame_type_to_sensor_type(OBFrameType type); + +/** + * @brief Convert OBFormat to " char* " type and then return. + * + * @param[in] format The OBFormat to convert. + * + * @return The string. + */ +OB_EXPORT const char *ob_format_to_string(OBFormat format); +#ifdef __cplusplus +} +#endif diff --git a/orbbec_camera/SDK/x64/include/libobsensor/h/Utils.h b/orbbec_camera/SDK/x64/include/libobsensor/h/Utils.h new file mode 100644 index 00000000..ae7f7007 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/Utils.h @@ -0,0 +1,136 @@ +// 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); + +/** + * @brief save LiDAR point cloud to ply file. + * + * @param[in] file_name Point cloud save path + * @param[in] frame LiDAR point cloud frame + * @param[in] save_binary Binary or textual,true: binary, false: textual + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return bool save LiDAR point cloud result + */ +OB_EXPORT bool ob_save_lidar_pointcloud_to_ply(const char *file_name, ob_frame *frame, bool save_binary, ob_error **error); +#ifdef __cplusplus +} +#endif diff --git a/orbbec_camera/SDK/x64/include/libobsensor/h/Version.h b/orbbec_camera/SDK/x64/include/libobsensor/h/Version.h new file mode 100644 index 00000000..c5e3dc8a --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/h/Version.h @@ -0,0 +1,56 @@ +// 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(void); + +/** + * @brief Get the SDK major version number. + * + * @return int The SDK major version number. + */ +OB_EXPORT int ob_get_major_version(void); + +/** + * @brief Get the SDK minor version number. + * + * @return int The SDK minor version number. + */ +OB_EXPORT int ob_get_minor_version(void); + +/** + * @brief Get the SDK patch version number. + * + * @return int The SDK patch version number. + */ +OB_EXPORT int ob_get_patch_version(void); + +/** + * @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(void); + +#ifdef __cplusplus +} +#endif diff --git a/orbbec_camera/SDK/x64/include/libobsensor/hpp/ApplicationConfig.hpp b/orbbec_camera/SDK/x64/include/libobsensor/hpp/ApplicationConfig.hpp new file mode 100644 index 00000000..17bf7138 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/hpp/ApplicationConfig.hpp @@ -0,0 +1,404 @@ +// Copyright (c) Orbbec Inc. All Rights Reserved. +// Licensed under the MIT License. + +#pragma once + +#include "Device.hpp" +#include "StreamProfile.hpp" +#include "Error.hpp" +#include "libobsensor/h/Advanced.h" +#include "libobsensor/h/ApplicationConfig.h" + +#include +#include +#include + +namespace ob { + +class ApplicationSensorConfig { +public: + explicit ApplicationSensorConfig(OBSensorType sensorType) : sensorType_(sensorType) {} + + OBSensorType sensorType() const { + return sensorType_; + } + + void enableStream(bool enabled) { + streamEnabled_ = enabled; + } + + bool isStreamEnabled() const { + return streamEnabled_; + } + + void setStreamProfile(const std::shared_ptr &profile) { + streamProfile_ = profile; + } + + std::shared_ptr streamProfile() const { + return streamProfile_; + } + + void enableUndistortion(bool enabled) { + undistortionEnabled_ = enabled; + } + + bool isUndistortionEnabled() const { + return undistortionEnabled_; + } + +private: + OBSensorType sensorType_{ OB_SENSOR_UNKNOWN }; + bool streamEnabled_ = { false }; + std::shared_ptr streamProfile_; + bool undistortionEnabled_ = { false }; +}; + +class ApplicationPointCloudConfig { +public: + void enable(bool enabled) { + enabled_ = enabled; + } + + bool isEnabled() const { + return enabled_; + } + + void setFormat(OBFormat format) { + format_ = format; + } + + OBFormat format() const { + return format_; + } + + void setDecimationFactor(int32_t factor) { + decimationFactor_ = factor; + } + + int32_t decimationFactor() const { + return decimationFactor_; + } + + void setAlignMode(OBAlignMode mode) { + alignMode_ = mode; + } + + OBAlignMode alignMode() const { + return alignMode_; + } + + void enableFrameSync(bool enabled) { + frameSync_ = enabled; + } + + bool isFrameSyncEnabled() const { + return frameSync_; + } + + void setAllFrameTypeRequired(bool enabled) { + allFrameTypeRequired_ = enabled; + } + + bool isAllFrameTypeRequired() const { + return allFrameTypeRequired_; + } + + void enableMatchTargetResolution(bool enabled) { + matchTargetResolution_ = enabled; + } + + bool isMatchTargetResolutionEnabled() const { + return matchTargetResolution_; + } + +private: + bool enabled_{ false }; + OBFormat format_{ OB_FORMAT_POINT }; + int32_t decimationFactor_{ 0 }; + OBAlignMode alignMode_{ ALIGN_DISABLE }; + bool frameSync_{ false }; + bool allFrameTypeRequired_{ false }; + bool matchTargetResolution_{ false }; +}; + +class ApplicationHDRMergeConfig { +public: + void enable(bool enabled) { + enabled_ = enabled; + } + + bool isEnabled() const { + return enabled_; + } + + void enableIR(bool enabled) { + enableIRforHDR_ = enabled; + } + + bool isIREnabled() const { + return enableIRforHDR_; + } + +private: + bool enabled_{ false }; + bool enableIRforHDR_{ true }; +}; + +class ApplicationDevDecimationConfig { +public: + void enable(bool enabled) { + enabled_ = enabled; + } + + bool isEnabled() const { + return enabled_; + } + + void setPresetResolutionConfig(const OBPresetResolutionConfig &config) { + config_ = config; + } + + const OBPresetResolutionConfig &presetResolutionConfig() const { + return config_; + } + +private: + bool enabled_{ false }; + OBPresetResolutionConfig config_; +}; + +class ApplicationConfig { +public: + static bool isSupported(const std::shared_ptr &device) { + ob_error *error = nullptr; + auto ret = ob_device_is_application_config_supported(device->getImpl(), &error); + Error::handle(&error); + return ret; + } + + static std::shared_ptr get(const std::shared_ptr &device) { + ob_error *error = nullptr; + auto handle = ob_device_get_application_config(device->getImpl(), &error); + Error::handle(&error); + return std::make_shared(handle); + } + + /** + * @brief Get the application config carried by an externally imported preset, by preset name. + * @return nullptr for built-in presets or presets that carry no application config. + */ + static std::shared_ptr get(const std::shared_ptr &device, const std::string &presetName) { + ob_error *error = nullptr; + auto handle = ob_device_get_application_config_by_preset(device->getImpl(), presetName.c_str(), &error); + Error::handle(&error); + if(!handle) { + return nullptr; + } + return std::make_shared(handle); + } + + explicit ApplicationConfig(ob_application_config *handle) : handle_(handle) {} + + ~ApplicationConfig() noexcept { + if(handle_) { + ob_error *error = nullptr; + ob_delete_application_config(handle_, &error); + Error::handle(&error, false); + } + } + + ob_application_config *handle() const { + return handle_; + } + + void reset() { + ob_error *error = nullptr; + ob_application_config_reset(handle_, &error); + Error::handle(&error); + } + + std::vector> sensors() const { + std::vector> result; + ob_error *error = nullptr; + auto count = ob_application_config_get_count(handle_, OB_APP_CONFIG_SENSORS, &error); + Error::handle(&error); + for(uint32_t i = 0; i < count; ++i) { + auto sensorType = static_cast(ob_application_config_get_int(handle_, OB_APP_CONFIG_ARRAY_ITEM(OB_APP_CONFIG_SENSOR_TYPE, i), &error)); + Error::handle(&error); + auto sensorConfig = std::make_shared(sensorType); + // enable + auto enable = ob_application_config_get_bool(handle_, OB_APP_CONFIG_ARRAY_ITEM(OB_APP_CONFIG_STREAM_ENABLED, i), &error); + Error::handle(&error); + sensorConfig->enableStream(enable); + // profile + auto profile = ob_application_config_get_profile(handle_, OB_APP_CONFIG_ARRAY_ITEM(OB_APP_CONFIG_STREAM_PROFILE, i), &error); + Error::handle(&error); + sensorConfig->setStreamProfile(StreamProfileFactory::create(profile)); + result.emplace_back(sensorConfig); + // undistortion + enable = ob_application_config_get_bool(handle_, OB_APP_CONFIG_ARRAY_ITEM(OB_APP_CONFIG_UNDISTORTION_ENABLED, i), &error); + Error::handle(&error, false); // optional + sensorConfig->enableUndistortion(enable); + } + return result; + } + + void setSensors(const std::vector> &sensors) { + for(const auto &sensor: sensors) { + setSensor(sensor); + } + } + + void setSensor(const std::shared_ptr &sensor) { + if(!sensor) { + return; + } + ob_error *error = nullptr; + auto index = sensorIndex(sensor->sensorType()); + // enable + ob_application_config_set_bool(handle_, OB_APP_CONFIG_ARRAY_ITEM(OB_APP_CONFIG_STREAM_ENABLED, index), sensor->isStreamEnabled(), &error); + Error::handle(&error); + // profile + auto profile = sensor->streamProfile(); + if(!profile) { + throw std::runtime_error("ApplicationSensorConfig: stream profile must not be null"); + } + ob_application_config_set_profile(handle_, OB_APP_CONFIG_ARRAY_ITEM(OB_APP_CONFIG_STREAM_PROFILE, index), profile->getImpl(), &error); + Error::handle(&error); + // undistortion + ob_application_config_set_bool(handle_, OB_APP_CONFIG_ARRAY_ITEM(OB_APP_CONFIG_UNDISTORTION_ENABLED, index), sensor->isUndistortionEnabled(), &error); + Error::handle(&error); + } + + std::shared_ptr deviceDecimation() const { + auto cfg = std::make_shared(); + ob_error *error = nullptr; + // enable + auto enable = ob_application_config_get_bool(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_DEVICE_DECIMATION_ENABLED), &error); + Error::handle(&error); + cfg->enable(enable); + if(enable) { + // Preset resolution + OBPresetResolutionConfig config{}; + ob_application_config_get_struct(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_DEVICE_DECIMATION), &config, sizeof(config), &error); + Error::handle(&error); + cfg->setPresetResolutionConfig(config); + } + return cfg; + } + + void setDeviceDecimation(const std::shared_ptr &config) { + if(!config) { + return; + } + ob_error *error = nullptr; + ob_application_config_set_bool(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_DEVICE_DECIMATION_ENABLED), config->isEnabled(), &error); + Error::handle(&error); + auto presetResConfig = config->presetResolutionConfig(); + ob_application_config_set_struct(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_DEVICE_DECIMATION), &presetResConfig, sizeof(presetResConfig), &error); + Error::handle(&error); + } + + std::shared_ptr pointCloud() const { + auto cfg = std::make_shared(); + ob_error *error = nullptr; + // enable + auto enable = ob_application_config_get_bool(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_POINTCLOUD_ENABLED), &error); + Error::handle(&error); + cfg->enable(enable); + // format + auto value = ob_application_config_get_int(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_POINTCLOUD_FORMAT), &error); + Error::handle(&error); + cfg->setFormat(static_cast(value)); + // decimation factor + value = ob_application_config_get_int(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_POINTCLOUD_DECIMATION_FACTOR), &error); + Error::handle(&error); + cfg->setDecimationFactor(value); + // align mode + value = ob_application_config_get_int(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_POINTCLOUD_ALIGN_MODE), &error); + Error::handle(&error); + cfg->setAlignMode(static_cast(value)); + // frame sync + enable = ob_application_config_get_bool(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_POINTCLOUD_FRAME_SYNC), &error); + Error::handle(&error); + cfg->enableFrameSync(enable); + // frame aggregate mode + enable = ob_application_config_get_bool(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_POINTCLOUD_ALL_FRAME_TYPE_REQUIRED), &error); + Error::handle(&error); + cfg->setAllFrameTypeRequired(enable); + // match target resolution + enable = ob_application_config_get_bool(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_POINTCLOUD_MATCH_TARGET_RESOLUTION), &error); + Error::handle(&error); + cfg->enableMatchTargetResolution(enable); + return cfg; + } + + void setPointCloud(const std::shared_ptr &config) { + if(!config) { + return; + } + ob_error *error = nullptr; + ob_application_config_set_bool(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_POINTCLOUD_ENABLED), config->isEnabled(), &error); + Error::handle(&error); + ob_application_config_set_int(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_POINTCLOUD_FORMAT), static_cast(config->format()), &error); + Error::handle(&error); + ob_application_config_set_int(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_POINTCLOUD_DECIMATION_FACTOR), config->decimationFactor(), &error); + Error::handle(&error); + ob_application_config_set_int(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_POINTCLOUD_ALIGN_MODE), static_cast(config->alignMode()), &error); + Error::handle(&error); + ob_application_config_set_bool(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_POINTCLOUD_FRAME_SYNC), config->isFrameSyncEnabled(), &error); + Error::handle(&error); + ob_application_config_set_bool(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_POINTCLOUD_ALL_FRAME_TYPE_REQUIRED), config->isAllFrameTypeRequired(), &error); + Error::handle(&error); + ob_application_config_set_bool(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_POINTCLOUD_MATCH_TARGET_RESOLUTION), config->isMatchTargetResolutionEnabled(), + &error); + Error::handle(&error); + } + + std::shared_ptr hdrMerge() const { + auto cfg = std::make_shared(); + ob_error *error = nullptr; + // enable + auto enable = ob_application_config_get_bool(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_HDR_MERGE_ENABLED), &error); + Error::handle(&error); + cfg->enable(enable); + // IR enable + enable = ob_application_config_get_bool(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_HDR_MERGE_IR_ENABLED), &error); + Error::handle(&error); + cfg->enableIR(enable); + return cfg; + } + + void setHDRMerge(const std::shared_ptr &config) { + if(!config) { + return; + } + ob_error *error = nullptr; + ob_application_config_set_bool(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_HDR_MERGE_ENABLED), config->isEnabled(), &error); + Error::handle(&error); + ob_application_config_set_bool(handle_, OB_APP_CONFIG_ITEM(OB_APP_CONFIG_HDR_MERGE_IR_ENABLED), config->isIREnabled(), &error); + Error::handle(&error); + } + +private: + uint32_t sensorIndex(OBSensorType sensorType) const { + ob_error *error = nullptr; + auto count = ob_application_config_get_count(handle_, OB_APP_CONFIG_SENSORS, &error); + Error::handle(&error); + for(uint32_t i = 0; i < count; ++i) { + auto current = static_cast(ob_application_config_get_int(handle_, OB_APP_CONFIG_ARRAY_ITEM(OB_APP_CONFIG_SENSOR_TYPE, i), &error)); + Error::handle(&error); + if(current == sensorType) { + return i; + } + } + throw std::runtime_error("Application sensor config not found"); + } + + ob_application_config *handle_ = nullptr; +}; + +using ApplicationConfigPtr = std::shared_ptr; + +} // namespace ob diff --git a/orbbec_camera/SDK/x64/include/libobsensor/hpp/Context.hpp b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Context.hpp new file mode 100644 index 00000000..7201ed05 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Context.hpp @@ -0,0 +1,424 @@ +// 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 +#include +#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[in] removedList The list of removed devices. + * @param[in] 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[in] severity The current callback log level. + * @param[in] logMsg The log message. + */ + typedef std::function LogCallback; + + struct DeviceChangedCallbackContext { + Context *ctx; + uint64_t callbackId; + DeviceChangedCallback callback; + }; + +private: + ob_context *impl_ = nullptr; + std::mutex callbackMtx_; + + std::mutex legacyCallbackMtx_; + OBCallbackId legacyCallbackId_ = INVALID_CALLBACK_ID; + + std::unordered_map> devChangedCallbacks_; + // 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 { + // delete contex of C API, which will auto unregister all callbacks + ob_error *error = nullptr; + ob_delete_context(impl_, &error); + Error::handle(&error, false); + } + + /** + * @brief Set the host-side timestamp clock type for the current context. + * + * @attention All ob::Context instances share the same underlying SDK runtime and clock type. + * @attention Switching affects frame system and global timestamps; avoid switching during streaming. + * @attention It is recommended to synchronize device timestamps after switching. + * + * @param[in] type The clock type to use for host-side timestamps. + */ + void setTimestampClockType(OBClockType type) const { + ob_error *error = nullptr; + ob_context_set_timestamp_clock_type(impl_, type, &error); + Error::handle(&error); + } + + /** + * @brief Get the current host-side timestamp clock type for the context. + * + * @return OBClockType The current clock type. + */ + OBClockType getTimestampClockType() const { + ob_error *error = nullptr; + auto type = ob_context_get_timestamp_clock_type(impl_, &error); + Error::handle(&error); + return type; + } + + /** + * @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 "Force" a static IP address configuration in a device identified by its MAC Address. + * + * @param[in] macAddress MAC address of the network device. + * You can obtain it from @ref ob_device_info_get_uid, or specify it manually + * in the format xx:xx:xx:xx:xx:xx, where each xx is a two-digit hexadecimal value. + * @param[in] config The new IP configuration. + * @return bool true if the configuration command was processed successfully, false otherwise. + * + * @note This applies to all GVCP devices + */ + bool forceIp(const char *macAddress, const OBNetIpConfig &config) { + ob_error *error = nullptr; + auto res = ob_force_ip_config(macAddress, config, &error); + Error::handle(&error); + return res; + } + + /** + * @brief Set the GVCP port scheme used for network device discovery and control. + * + * @param[in] scheme Target GVCP port scheme. + * Thrown exception if the specified scheme is invalid or unsupported. + * + * @note This change affects only the current session and is not persisted. + * @note Switching to a different scheme will force disconnection of all currently connected network devices. + */ + void setGvcpPortScheme(OBGvcpPortScheme scheme) { + ob_error *error = nullptr; + ob_set_gvcp_port_scheme(impl_, scheme, &error); + Error::handle(&error); + } + + /** + * @brief Get the current GVCP port scheme. + * + * @return Current GVCP port scheme. + */ + OBGvcpPortScheme getGvcpPortScheme() const { + ob_error *error = nullptr; + auto scheme = ob_get_gvcp_port_scheme(impl_, &error); + Error::handle(&error); + return scheme; + } + + /** + * @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 + * @param[in] accessMode Device access mode. @ref ob_device_access_mode. + * If the device does not support setting the Access Mode, the default OB_DEVICE_DEFAULT_ACCESS is used. + * Applies only on first device creation or after release and re-creation; subsequent calls ignore it. + * + * @return std::shared_ptr The created device object. + */ + std::shared_ptr createNetDevice(const char *address, uint16_t port, OBDeviceAccessMode accessMode = OB_DEVICE_DEFAULT_ACCESS) const { + ob_error *error = nullptr; + auto device = ob_create_net_device_ex(impl_, address, port, accessMode, &error); + Error::handle(&error); + return std::make_shared(device); + } + + /** + * @brief Set the device plug-in callback function. + * + * @deprecated This function is deprecated. Please use registerDeviceChangedCallback() instead. + * + * @attention This function supports multiple callbacks. Each call to this function adds a new callback to an internal list. + * + * @param[in] callback The function triggered when the device is plugged and unplugged. + */ + void setDeviceChangedCallback(DeviceChangedCallback callback) { + std::lock_guard lock(legacyCallbackMtx_); + // remove the last callback first + if(legacyCallbackId_ != INVALID_CALLBACK_ID) { + unregisterDeviceChangedCallback(legacyCallbackId_); + } + // register the new callback + legacyCallbackId_ = registerDeviceChangedCallback(callback); + } + + OBCallbackId registerDeviceChangedCallback(DeviceChangedCallback callback) { + ob_error *error = nullptr; + auto cbCtxHolder = std::unique_ptr(new DeviceChangedCallbackContext({ this, 0, nullptr })); + auto id = ob_register_device_changed_callback(impl_, &Context::deviceChangedCallback, (void *)cbCtxHolder.get(), &error); + Error::handle(&error); + + cbCtxHolder->callbackId = id; + cbCtxHolder->callback = callback; + { + std::unique_lock lock(callbackMtx_); + devChangedCallbacks_[id] = std::move(cbCtxHolder); + } + return id; + } + + void unregisterDeviceChangedCallback(OBCallbackId id) { + ob_error *error = nullptr; + ob_unregister_device_changed_callback(impl_, id, &error); + { + std::unique_lock lock(callbackMtx_); + if(devChangedCallbacks_.count(id)) { + devChangedCallbacks_.erase(id); + } + } + Error::handle(&error); + } + + /** + * @brief Activates device clock synchronization to synchronize the clock of the host and all created devices (if supported). + * + * @param[in] 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 Activates synchronization time to all created devices (if supported). + * + * @param[in] hardwarePPSTime unit:ms. + */ + void syncDeviceHardwarePPSTime(uint64_t hardwarePPSTime) const { + ob_error *error = nullptr; + ob_sync_device_hardware_pps_time(impl_, hardwarePPSTime, &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[in] 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[in] severity The log level output to the file. + * @param[in] 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 the log file name for file output + * + * @param[in] fileName Log file name. Must not be empty. + * + * @note Other settings, such as log level and output directory, remain unchanged. + */ + static void setLoggerFileName(const std::string &fileName) { + ob_error *error = nullptr; + ob_set_logger_file_name(fileName.c_str(), &error); + Error::handle(&error); + } + + /** + * @brief Set log output to the console. + * + * @param[in] 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[in] severity The callback log level. + * @param[in] 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 Logs a message with severity, file, function, and line info. + * + * @param severity Log level, see @ref OBLogSeverity for details + * @param module The module or component the log belongs to + * @param message Message string to log + * @param file Source file name, e.g., __FILE__ + * @param func Function name, e.g., __func__ + * @param line Line number, e.g., __LINE__ + */ + static void logExternalMessage(OBLogSeverity severity, const std::string &module, const std::string &message, const std::string &file, + const std::string &func, int line) { + ob_error *error = nullptr; + ob_log_external_message(severity, module.c_str(), message.c_str(), file.c_str(), func.c_str(), line, &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[in] 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 cbCtx = static_cast(userData); + if(cbCtx && cbCtx->ctx && cbCtx->callbackId != INVALID_CALLBACK_ID) { + DeviceChangedCallback callbackCopy; + { + // preventing the captured variables from being released. + std::unique_lock lock(cbCtx->ctx->callbackMtx_); + if(cbCtx->ctx->devChangedCallbacks_.count(cbCtx->callbackId)) { + callbackCopy = cbCtx->callback; + } + } + auto removed = std::make_shared(removedList); + auto added = std::make_shared(addedList); + callbackCopy(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/orbbec_camera/SDK/x64/include/libobsensor/hpp/Device.hpp b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Device.hpp new file mode 100644 index 00000000..36cf9e41 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Device.hpp @@ -0,0 +1,2006 @@ +// 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 ColorPresetList; +class OBDepthWorkModeList; +class CameraParamList; +class DeviceFrameInterleaveList; +class PresetResolutionConfigList; + +class Device { +public: + /** + * @brief Callback function for device firmware update progress + * + * @param[in] state The device firmware update status. + * @param[in] message Status information. + * @param[in] percent The percentage of the update progress. + */ + typedef std::function DeviceFwUpdateCallback; + + /** + * @brief Callback function for device status updates. + * + * @param[in] state The device status. + * @param[in] 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[in] 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[in] 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[in] propertyId Property id + * @param[in] 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[in] propertyId Property id + * @param[in] 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[in] propertyId Property id + * @param[in] 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[in] 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[in] 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[in] 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[in] 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[in] 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[in] 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[in] propertyId The ID of the property + * @param[in] data The data to set + * @param[in] 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[in] propertyId The ID of the property + * @param[out] data The property data obtained + * @param[out] 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 Check whether the device supports license authorization. + * + * @return true if the device supports license authorization, false otherwise. + */ + bool isLicenseAuthorizationSupported() const { + ob_error *error = nullptr; + auto res = ob_device_is_license_authorization_supported(impl_, &error); + Error::handle(&error); + return res; + } + + /** + * @brief Write signed device license information. + * + * @param[in] licenseInfo SDK license_info JSON string + */ + void writeLicenseInfo(const std::string &licenseInfo) const { + ob_error *error = nullptr; + ob_device_write_license_info(impl_, licenseInfo.c_str(), static_cast(licenseInfo.size()), &error); + Error::handle(&error); + } + + /** + * @brief Clear license information stored on the device. + */ + void clearLicenseInfo() const { + ob_error *error = nullptr; + ob_device_clear_license_info(impl_, &error); + Error::handle(&error); + } + + /** + * @brief Read signed device license information as SDK license_info JSON. + * + * @return std::string SDK license_info JSON string + */ + std::string readLicenseInfo() const { + ob_error *error = nullptr; + char buf[4096] = {}; + ob_device_read_license_info(impl_, buf, sizeof(buf), &error); + Error::handle(&error); + return std::string(buf); + } + + /** + * @brief Set the customer data type of a device property + * + * @param[in] data The data to set + * @param[in] 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[in] data The property data obtained + * @param[in] 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[in] 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[in] propertyId The ID of the property + * @param[in] 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[in] 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 + * + * @attention Only one firmware/preset update may run per device at a time + * + * @param[in] filePath Firmware path + * @param[in] callback Firmware Update progress and status callback + * @param[in] 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 + * + * @attention Only one firmware/preset update may run per device at a time + * + * @param[in] firmwareData Firmware data + * @param[in] firmwareDataSize Firmware data size + * @param[in] callback Firmware Update progress and status callback + * @param[in] 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 + * + * @attention Only one firmware/preset update may run per device at a time + * + * @param[in] filePathList A list(2D array) of preset file paths, each up to OB_PATH_MAX characters. + * @param[in] pathCount The number of the preset file paths. + * @param[in] 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 Update the device optional depth presets from data loaded in memory + * + * @attention Only one firmware/preset update may run per device at a time + * + * @param[in] dataList A list of preset data blocks, each holding the raw bytes of one preset. + * @param[in] callback Preset update progress and status callback + */ + void updateOptionalDepthPresets(const std::vector> &dataList, DeviceFwUpdateCallback callback) { + ob_error *error = nullptr; + std::vector presets; + presets.reserve(dataList.size()); + for(const auto &data: dataList) { + presets.push_back({data.data(), static_cast(data.size())}); + } + fwUpdateCallback_ = callback; + auto count = static_cast(presets.size()); + ob_device_update_optional_depth_presets_from_data(impl_, presets.data(), count, &Device::firmwareUpdateCallback, this, &error); + Error::handle(&error); + } + + /** + * @brief Set the device state changed callbacks + * + * @param[in] 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 Check if the device supports color preset. + * + * @return bool Returns true if the device supports color preset. + */ + bool isColorPresetSupported() const { + ob_error *error = nullptr; + auto result = ob_device_is_color_preset_supported(impl_, &error); + Error::handle(&error); + return result; + } + + /** + * @brief Get the current color preset name. + * + * @return const char* The current color preset name. + */ + const char *getCurrentColorPresetName() const { + ob_error *error = nullptr; + const char *name = ob_device_get_current_color_preset_name(impl_, &error); + Error::handle(&error); + return name; + } + + /** + * @brief Switch the color preset by name. + * + * @param[in] presetName The color preset name. + */ + void switchColorPreset(const char *presetName) const { + ob_error *error = nullptr; + ob_device_switch_color_preset(impl_, presetName, &error); + Error::handle(&error); + } + + /** + * @brief Get the available color preset list. + * + * @return std::shared_ptr The color preset list. + */ + std::shared_ptr getColorPresetList() const { + ob_error *error = nullptr; + auto list = ob_device_get_color_preset_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 synchronization the device time (synchronize hardwarePPS time to device) + * @param[in] hardwarePPSTime unit:ms + * @return Whether the synchronisation is successful + */ + bool syncDeviceHardwarePPSTime(uint64_t hardwarePPSTime) const { + ob_error *error = nullptr; + bool success = ob_device_sync_hardware_pps_time(impl_, hardwarePPSTime, &error); + Error::handle(&error); + return success; + } + + /** + * @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 Enable or disable the device firmware log. + * + * @param[in] enable Whether to enable the firmware log. + */ + void enableFirmwareLog(bool enable) const { + ob_error *error = nullptr; + ob_device_enable_firmware_log(impl_, enable, &error); + Error::handle(&error); + } + + /** + * @brief Check whether the device firmware log is enabled. + * + * @return bool Whether the firmware log is enabled. + */ + bool isFirmwareLogEnabled() const { + ob_error *error = nullptr; + bool enable = ob_device_is_firmware_log_enabled(impl_, &error); + Error::handle(&error); + return enable; + } + + /** + * @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 OBMultiDeviceSyncConfig::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. + */ + inline void timerReset() const { + 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[in] 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[in] 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 @p 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[in] presetName The name of the custome preset. + * @param[in] data The custom preset data. + * @param[in] 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 @p 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[in] presetName The name of the custome preset. + * @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 @p filePath will be added to the available preset list. + * + * @param[in] 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[in] 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 current frame interleave name. + * + * @param[in] device The device object. + * @param[out] error Pointer to an error object that will be set if an error occurs. + * + * @return const char* return the current frame interleave name. + * Returns an empty string ("") if no interleave is loaded. + * Returns nullptr if an error occurs. + */ + OB_EXPORT const char *getCurrentFrameInterleaveName() const { + ob_error *error = nullptr; + auto name = ob_device_get_current_frame_interleave_name(impl_, &error); + Error::handle(&error); + return name; + } + + /** + * @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); + } + + /** + * @brief Get the available preset resolution config list + * + * @return PresetResolutionConfigList return the available preset resolution config list. + */ + std::shared_ptr getAvailablePresetResolutionConfigList() const { + ob_error *error = nullptr; + auto list = ob_device_get_available_preset_resolution_config_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; + } + + /** + * @brief Get the subnet mask of the device + * + * @return const char* the subnet mask of the device, such as "255.255.255.0" + */ + const char *getDeviceSubnetMask() const { + ob_error *error = nullptr; + const char *subnetMask = ob_device_info_get_subnet_mask(impl_, &error); + Error::handle(&error); + return subnetMask; + } + + /** + * @brief Get the gateway address of the device + * + * @return const char* the gateway address of the device, such as "192.168.1.1" + */ + const char *getDeviceGateway() const { + ob_error *error = nullptr; + const char *subnetMask = ob_device_info_get_gateway(impl_, &error); + Error::handle(&error); + return subnetMask; + } + +public: + // The following interfaces are deprecated and are retained here for compatibility purposes. + const char *getDevicegateway() { + return getDeviceGateway(); + } + + 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[in] 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[in] 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[in] 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[in] 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[in] 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[in] 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", + * "GMSL2" + */ + 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[in] 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 subnet mask of the device at the specified index + * + * @attention Only valid for network devices, otherwise it will return "0.0.0.0". + * + * @param[in] index the index of the device + * + * @return const char* the subnet mask of the device + */ + const char *getSubnetMask(uint32_t index) const { + ob_error *error = nullptr; + auto subnetMask = ob_device_list_get_device_subnet_mask(impl_, index, &error); + Error::handle(&error); + return subnetMask; + } + + /** + * @brief get the gateway of the device at the specified index + * + * @attention Only valid for network devices, otherwise it will return "0.0.0.0". + * + * @param[in] index the index of the device + * + * @return const char* the gateway of the device + */ + const char *getGateway(uint32_t index) const { + ob_error *error = nullptr; + auto gateway = ob_device_list_get_device_gateway(impl_, index, &error); + Error::handle(&error); + return gateway; + } + + /** + * @brief Get the MAC address of the host network interface corresponding to the device at the specified index + * + * @attention Only valid for network devices, otherwise it will return "0:0:0:0:0:0". + * + * @param[in] index the index of the device + * + * @return const char* The MAC address of the host network interface associated with 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 IP address of the host network interface corresponding to the device at the specified index + * + * @attention Only valid for network devices, otherwise it will return "0.0.0.0". + * + * @param[in] index The index of the device + * + * @return const char* The IP address of the host network interface associated with the device. + */ + const char *getLocalIP(uint32_t index) const { + ob_error *error = nullptr; + auto ip = ob_device_list_get_device_local_ip(impl_, index, &error); + Error::handle(&error); + return ip; + } + + /** + * @brief Get the subnet length of the host network interface corresponding to the device at the specified index + * + * @attention Only valid for network devices, otherwise it will return 0. + * + * @param[in] index The index of the device + * + * @return uint8_t The subnet length (0~32) of the host network interface associated with the device. + */ + uint8_t getLocalSubnetLength(uint32_t index) const { + ob_error *error = nullptr; + auto subnetMask = ob_device_list_get_device_local_subnet_length(impl_, index, &error); + Error::handle(&error); + return subnetMask; + } + + /** + * @brief Get the gateway of the host network interface corresponding to the device at the specified index + * + * @attention Only valid for network devices, otherwise it will return "0.0.0.0". + * + * @param[in] index The index of the device + * + * @return const char* The gateway of the host network interface associated with the device. + */ + const char *getLocalGateway(uint32_t index) const { + ob_error *error = nullptr; + auto gateway = ob_device_list_get_device_local_gateway(impl_, index, &error); + Error::handle(&error); + return gateway; + } + + /** + * @brief Get the name of the host network interface corresponding to the device at the specified index. + * + * @attention Returns "unknown" for USB devices or non-network devices. + * + * @param[in] index The index of the device. + * + * @return const char* The host network interface name (e.g., "eth0", "en0"). + */ + const char *getLocalNetInterfaceName(uint32_t index) const { + ob_error *error = nullptr; + auto netItfName = ob_device_list_get_device_local_net_if_name(impl_, index, &error); + Error::handle(&error); + return netItfName; + } + + /** + * @brief Get the current IP configuration mode of the device at the specified index. + * + * @attention Only valid for Ethernet devices, otherwise it will return OB_IP_SOURCE_NONE. + * + * @param[in] index The index of the device. + * + * @return OBCurIpConfig The active IP configuration mode (e.g. DHCP, LLA, or Persistent IP). + */ + OBIpSourceType getIpSourceType(uint32_t index) const { + ob_error *error = nullptr; + auto ipSrcType = ob_device_list_get_device_ip_source_type(impl_, index, &error); + Error::handle(&error); + return ipSrcType; + } + + /** + * @brief Get the user-defined name of the device at the specified index. + * + * @attention Only valid for Ethernet devices, otherwise returns "unknown". + * + * @param[in] index The index of the device. + * + * @return const char* The user-defined name string. + */ + const char *getUserName(uint32_t index) const { + ob_error *error = nullptr; + auto userName = ob_device_list_get_device_user_name(impl_, index, &error); + Error::handle(&error); + return userName; + } + + /** + * @brief Query the current device access state without opening the device. + * + * @attention This is a non-invasive GVCP CCP query for supported Ethernet devices. It reports device-side CCP state, not the owner process or host. + * CONTROLLED means monitor access may still be available, while default/control access may still fail. + * This call is synchronous and blocks while waiting for the device's GVCP response over the network; querying an unreachable device blocks until the + * underlying retry logic gives up, so prefer calling it off the UI thread when querying multiple devices. + * The returned state reflects the device access state only at the moment of the query and does not guarantee that a subsequent access (such as creating + * or opening the device) will succeed, as another client may change the state in between. + * + * @param[in] index The index of the device. + * + * @return OBDeviceAccessState The current access state of the device. + */ + OBDeviceAccessState queryDeviceAccessState(uint32_t index) const { + ob_error *error = nullptr; + auto state = ob_device_list_query_device_access_state(impl_, index, &error); + Error::handle(&error); + return state; + } + + /** + * @brief Query the current device access state by serial number without opening the device. + * + * @attention This is a non-invasive GVCP CCP query for supported Ethernet devices. It reports device-side CCP state, not the owner process or host. + * CONTROLLED means monitor access may still be available, while default/control access may still fail. + * This call is synchronous and blocks while waiting for the device's GVCP response over the network; querying an unreachable device blocks until the + * underlying retry logic gives up, so prefer calling it off the UI thread when querying multiple devices. + * The returned state reflects the device access state only at the moment of the query and does not guarantee that a subsequent access (such as creating + * or opening the device) will succeed, as another client may change the state in between. + * If no device in the list matches the given serial number, this throws an ob::Error. + * + * @param[in] serialNumber The serial number of the device. + * + * @return OBDeviceAccessState The current access state of the device. + */ + OBDeviceAccessState queryDeviceAccessStateBySN(const char *serialNumber) const { + ob_error *error = nullptr; + auto state = ob_device_list_query_device_access_state_by_serial_number(impl_, serialNumber, &error); + Error::handle(&error); + return state; + } + + /** + * @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[in] index the index of the device to create + * @param[in] accessMode Device access mode. @ref ob_device_access_mode. + * If the device does not support setting the Access Mode, the default OB_DEVICE_DEFAULT_ACCESS is used. + * Applies only on first device creation or after release and re-creation; subsequent calls ignore it. + * + * @return std::shared_ptr the device object + */ + std::shared_ptr getDevice(uint32_t index, OBDeviceAccessMode accessMode = OB_DEVICE_DEFAULT_ACCESS) const { + ob_error *error = nullptr; + auto device = ob_device_list_get_device_ex(impl_, index, accessMode, &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[in] serialNumber the serial number of the device to create + * @param[in] accessMode Device access mode. @ref ob_device_access_mode. + * If the device does not support setting the Access Mode, the default OB_DEVICE_DEFAULT_ACCESS is used. + * Applies only on first device creation or after release and re-creation; subsequent calls ignore it. + * + * @return std::shared_ptr the device object + */ + std::shared_ptr getDeviceBySN(const char *serialNumber, OBDeviceAccessMode accessMode = OB_DEVICE_DEFAULT_ACCESS) const { + ob_error *error = nullptr; + auto device = ob_device_list_get_device_by_serial_number_ex(impl_, serialNumber, accessMode, &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[in] uid The uid of the device to be created + * @param[in] accessMode Device access mode. @ref ob_device_access_mode. + * If the device does not support setting the Access Mode, the default OB_DEVICE_DEFAULT_ACCESS is used. + * Applies only on first device creation or after release and re-creation; subsequent calls ignore it. + * + * @return std::shared_ptr returns the device object + */ + std::shared_ptr getDeviceByUid(const char *uid, OBDeviceAccessMode accessMode = OB_DEVICE_DEFAULT_ACCESS) const { + ob_error *error = nullptr; + auto device = ob_device_list_get_device_by_uid_ex(impl_, uid, accessMode, &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[in] 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[in] 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[in] 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[in] 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 color presets + */ +class ColorPresetList { +private: + ob_color_preset_list *impl_ = nullptr; + +public: + explicit ColorPresetList(ob_color_preset_list *impl) : impl_(impl) {} + ~ColorPresetList() noexcept { + ob_error *error = nullptr; + ob_delete_color_preset_list(impl_, &error); + Error::handle(&error, false); + } + + uint32_t getCount() const { + ob_error *error = nullptr; + auto count = ob_color_preset_list_get_count(impl_, &error); + Error::handle(&error); + return count; + } + + const char *getName(uint32_t index) const { + ob_error *error = nullptr; + const char *name = ob_color_preset_list_get_name(impl_, index, &error); + Error::handle(&error); + return name; + } +}; + +/** + * @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[in] 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[in] 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[in] 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; + } +}; + +/** + * @brief Class representing a list of preset resolution config list + */ +class PresetResolutionConfigList { +private: + ob_preset_resolution_config_list_t *impl_ = nullptr; + +public: + explicit PresetResolutionConfigList(ob_preset_resolution_config_list_t *impl) : impl_(impl) {} + ~PresetResolutionConfigList() noexcept { + ob_error *error = nullptr; + ob_delete_preset_resolution_config_list(impl_, &error); + Error::handle(&error, false); + } + + /** + * @brief Get the number of device preset resolution ratio in the list + */ + uint32_t getCount() { + ob_error *error = nullptr; + auto count = ob_device_preset_resolution_config_get_count(impl_, &error); + Error::handle(&error); + return count; + } + + /* + * @brief Get the device preset resolution ratio at the specified index + + * @param[in] index the index of the device preset resolution ratio + * + * @return OBPresetResolutionConfig the corresponding device preset resolution ratio + */ + OBPresetResolutionConfig getPresetResolutionRatioConfig(uint32_t index) { + ob_error *error = nullptr; + auto config = ob_device_preset_resolution_config_list_get_item(impl_, index, &error); + Error::handle(&error); + return config; + } +}; + +} // namespace ob diff --git a/orbbec_camera/SDK/x64/include/libobsensor/hpp/Error.hpp b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Error.hpp new file mode 100644 index 00000000..f9799d11 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Error.hpp @@ -0,0 +1,124 @@ +// 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[in] 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[in,out] error The ob_error pointer to be handled. + * @param[in] 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; + } + + /** + * @brief Returns the error status code of the exception. + * + * @return OBStatus The error status code. + */ + OBStatus getStatus() const noexcept { + return impl_->status; + } + +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/orbbec_camera/SDK/x64/include/libobsensor/hpp/Filter.hpp b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Filter.hpp new file mode 100644 index 00000000..591f2f99 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Filter.hpp @@ -0,0 +1,2346 @@ +// 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 +#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[in] 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[in] 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[in] 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[in] configName The name of the config. + * @param[in] 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[in] 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[in] name The name of the filter. + * @param[in] 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[in] 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 override = default; + + /** + * @brief Set the output pointcloud frame format. + * + * @param[in] 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[in] 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[in] state Whether normalization is required. + */ + void setColorDataNormalization(bool state) { + setConfigValue("colorDataNormalization", state); + } + + /** + * @brief Set the point cloud coordinate system. + * + * @param[in] type The coordinate system type. + */ + void setCoordinateSystem(OBCoordinateSystemType type) { + setConfigValue("coordinateSystemType", static_cast(type)); + } + + /** + * @brief Set the point cloud decimation factor. + * Calling this function to decimation factor will output thedownsampled data of the the cloud frame + * + * @param value The decimation factor. + */ + void setDecimationFactor(int value) { + setConfigValue("decimate", value); + } + + /** + * @brief Get the property range of the decimation factor range. + */ + OBIntPropertyRange getDecimationFactorRange() { + OBIntPropertyRange scaleRange{}; + if(configSchemaVec_.size() != 0) { + const auto &item = configSchemaVec_[5]; + scaleRange = getPropertyRange(item, getConfigValue("decimate")); + } + return scaleRange; + } + +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 override = 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[in] 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[in] 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 UnDistortionFilter removes lens distortion from a chosen stream (Color, IR, or Depth). + * + */ +class UnDistortionFilter : public Filter { +public: + explicit UnDistortionFilter(OBStreamType streamType = OB_STREAM_COLOR) { + ob_error *error = nullptr; + auto impl = ob_create_filter("UnDistortionFilter", &error); + Error::handle(&error); + init(impl); + setConfigValue("StreamType", static_cast(streamType)); + } + + virtual ~UnDistortionFilter() noexcept override = default; + + /** + * @brief Set which stream to undistort (default: OB_STREAM_COLOR). + */ + void setStreamType(OBStreamType streamType) { + setConfigValue("StreamType", static_cast(streamType)); + } + + OBStreamType getStreamType() const { + return static_cast(static_cast(getConfigValue("StreamType"))); + } + + /** + * @brief Set the new camera matrix used to project the undistorted image + * (equivalent to OpenCV's `newCameraMatrix` argument in + * `cv::undistort(src, dst, cameraMatrix, distCoeffs, newCameraMatrix)`). + * + * Pass the raw depth camera intrinsic. The filter scales fx/fy/cx/cy from + * the depth resolution to the actual color frame resolution at process time, + * so the caller does NOT need to compute the scale factor. + * + * The new-camera-matrix mode is enabled as long as depthIntrinsic.width > 0. + * Call clearNewCameraMatrix() to return to pure undistortion. + * + * @param depthIntrinsic The depth camera intrinsic at its native resolution. + */ + void setNewCameraMatrix(OBCameraIntrinsic depthIntrinsic) { + setConfigValue("NewCameraFx", static_cast(depthIntrinsic.fx)); + setConfigValue("NewCameraFy", static_cast(depthIntrinsic.fy)); + setConfigValue("NewCameraCx", static_cast(depthIntrinsic.cx)); + setConfigValue("NewCameraCy", static_cast(depthIntrinsic.cy)); + setConfigValue("NewCameraWidth", static_cast(depthIntrinsic.width)); + setConfigValue("NewCameraHeight", static_cast(depthIntrinsic.height)); + } + + /** + * @brief Clear the new camera matrix and return to pure undistortion. + */ + void clearNewCameraMatrix() { + setConfigValue("NewCameraWidth", 0.0); + } +}; + +/** + * @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 override = default; + + /** + * @brief Set the format conversion type. + * + * @param[in] 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 override = 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 override { + if(outputSequenceIdList_) { + delete[] outputSequenceIdList_; + outputSequenceIdList_ = nullptr; + } + } + + /** + * @brief Set the sequenceId filter params. + * + * @param[in] 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 override = default; + + /** + * @brief Set the decimation filter scale value. + * + * @param[in] 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 override = 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 override = 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[in] 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 The Spatial Fast Filter utilizes an enhanced median smoothing algorithm, + * designed to significantly reduce CPU usage and optimize processing efficiency. + */ +class SpatialFastFilter : public Filter { +public: + SpatialFastFilter(const std::string &activationKey = "") { + ob_error *error = nullptr; + auto impl = ob_create_private_filter("SpatialFastFilter", activationKey.c_str(), &error); + Error::handle(&error); + init(impl); + } + + virtual ~SpatialFastFilter() noexcept override = default; + + /** + * @brief Get the spatial fast filter radius range. + * + * @return OBIntPropertyRange the radius value of property range. + */ + OBIntPropertyRange getRadiusRange() { + OBIntPropertyRange 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 fast filter params. + * + * @return OBSpatialFastFilterParams + */ + OBSpatialFastFilterParams getFilterParams() { + OBSpatialFastFilterParams params{}; + params.radius = static_cast(getConfigValue("radius")); + return params; + } + + /** + * @brief Set the spatial fast filter params. + * + * @param[in] params OBSpatialFastFilterParams. + */ + void setFilterParams(OBSpatialFastFilterParams params) { + setConfigValue("radius", params.radius); + } +}; + +/** + * @brief The Spatial Moderate Filter utilizes an optimized average smoothing algorithm, + * to achieve a balance between processing speed and the quality of smoothing achieved. + */ +class SpatialModerateFilter : public Filter { +public: + SpatialModerateFilter(const std::string &activationKey = "") { + ob_error *error = nullptr; + auto impl = ob_create_private_filter("SpatialModerateFilter", activationKey.c_str(), &error); + Error::handle(&error); + init(impl); + } + + virtual ~SpatialModerateFilter() noexcept override = default; + + /** + * @brief Get the spatial moderate filter magnitude range. + * + * @return OBIntPropertyRange 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 moderate filter radius range. + * + * @return OBIntPropertyRange the radius value of property range. + */ + OBIntPropertyRange getRadiusRange() { + OBIntPropertyRange 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 moderate filter disp diff range. + * + * @return OBIntPropertyRange the disp diff value of property range. + */ + OBIntPropertyRange getDispDiffRange() { + OBIntPropertyRange 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 moderate filter params. + * + * @return OBSpatialModerateFilterParams + */ + OBSpatialModerateFilterParams getFilterParams() { + OBSpatialModerateFilterParams params{}; + params.magnitude = static_cast(getConfigValue("magnitude")); + params.radius = static_cast(getConfigValue("radius")); + params.disp_diff = static_cast(getConfigValue("disp_diff")); + return params; + } + + /** + * @brief Set the spatial moderate filter params. + * + * @param[in] params OBSpatialModerateFilterParams. + */ + void setFilterParams(OBSpatialModerateFilterParams params) { + setConfigValue("magnitude", params.magnitude); + setConfigValue("radius", params.radius); + setConfigValue("disp_diff", params.disp_diff); + } +}; + +/** + * @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 override = default; + + /** + * @brief Set the HoleFillingFilter mode. + * + * @param[in] 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 override = 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 override = 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[in] 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[in] value weight value. + */ + void setWeight(float value) { + setConfigValue("weight", static_cast(value)); + } +}; + +/** + * @brief EdgeNoiseRemoval filter + */ +class EdgeNoiseRemovalFilter : public Filter { +public: + EdgeNoiseRemovalFilter(const std::string &activationKey = "") { + ob_error *error = nullptr; + auto impl = ob_create_private_filter("EdgeNoiseRemovalFilter", activationKey.c_str(), &error); + Error::handle(&error); + init(impl); + } + + ~EdgeNoiseRemovalFilter() noexcept override = default; + + /** + * @brief Get the edge noise removal filter margin x th range. + * @return OBUint16PropertyRange The margin x th of property range. + */ + OBUint16PropertyRange getMarginXthRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "margin_x_th") == 0) { + range = getPropertyRange(item, getConfigValue("margin_x_th")); + break; + } + } + return range; + } + + /** + * @brief Get the edge noise removal filter margin y th range. + * @return OBUint16PropertyRange The margin y th of property range. + */ + OBUint16PropertyRange getMarginYthRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "margin_y_th") == 0) { + range = getPropertyRange(item, getConfigValue("margin_y_th")); + break; + } + } + return range; + } + + /** + * @brief Get the edge noise removal filter limit x th range. + * @return OBUint16PropertyRange The limit x th of property range. + */ + OBUint16PropertyRange getLimitXthRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "limit_x_th") == 0) { + range = getPropertyRange(item, getConfigValue("limit_x_th")); + break; + } + } + return range; + } + + /** + * @brief Get the edge noise removal filter limit y th range. + * @return OBUint16PropertyRange The limit y th of property range. + */ + OBUint16PropertyRange getLimitYthRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "limit_y_th") == 0) { + range = getPropertyRange(item, getConfigValue("limit_y_th")); + break; + } + } + return range; + } + + /** + * @brief Get the edge noise removal filter vertical direction enable range. + * @return OBUint16PropertyRange The vertical direction enable of property range. + */ + OBUint16PropertyRange getVerticalDirectionEnableRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "enable_vertical_direction") == 0) { + range = getPropertyRange(item, getConfigValue("enable_vertical_direction")); + break; + } + } + return range; + } + + /** + * @brief Get the edge noise removal filter width range. + * @return OBUint16PropertyRange The width of property range. + */ + OBUint16PropertyRange getWidthRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "width") == 0) { + range = getPropertyRange(item, getConfigValue("width")); + break; + } + } + return range; + } + + /** + * @brief Get the edge noise removal filter height range. + * @return OBUint16PropertyRange The height of property range. + */ + OBUint16PropertyRange getHeightRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "height") == 0) { + range = getPropertyRange(item, getConfigValue("height")); + break; + } + } + return range; + } + + /** + * @brief Set the edge noise removal filter params. + * + * @param[in] filterParams OBEdgeNoiseRemovalFilterParams. + */ + void setFilterParams(OBEdgeNoiseRemovalFilterParams filterParams) { + setConfigValue("margin_x_th", static_cast(filterParams.margin_x_th)); + setConfigValue("margin_y_th", static_cast(filterParams.margin_y_th)); + setConfigValue("limit_x_th", static_cast(filterParams.limit_x_th)); + setConfigValue("limit_y_th", static_cast(filterParams.limit_y_th)); + setConfigValue("enable_vertical_direction", static_cast(filterParams.enable_direction)); + setConfigValue("width", static_cast(filterParams.width)); + setConfigValue("height", static_cast(filterParams.height)); + } + + /** + * @brief Get the edge noise removal filter params. + * + * @return OBEdgeNoiseRemovalFilterParams. + */ + OBEdgeNoiseRemovalFilterParams getFilterParams() { + OBEdgeNoiseRemovalFilterParams param{}; + param.margin_x_th = static_cast(getConfigValue("margin_x_th")); + param.margin_y_th = static_cast(getConfigValue("margin_y_th")); + param.limit_x_th = static_cast(getConfigValue("limit_x_th")); + param.limit_y_th = static_cast(getConfigValue("limit_y_th")); + param.enable_direction = static_cast(getConfigValue("enable_vertical_direction")); + param.width = static_cast(getConfigValue("width")); + param.height = static_cast(getConfigValue("height")); + return param; + } +}; + +/** + * @brief FalsePositive filter + */ +class FalsePositiveFilter : public Filter { +public: + FalsePositiveFilter(const std::string &activationKey = "") { + ob_error *error = nullptr; + auto impl = ob_create_private_filter("FalsePositiveFilter", activationKey.c_str(), &error); + Error::handle(&error); + init(impl); + } + + virtual ~FalsePositiveFilter() noexcept override = default; + + /** + * @brief Get the FalsePositive filter fpEdgeBleedFilterEnable range. + * + * @return OBUint8PropertyRange the fpEdgeBleedFilterEnable value of property range. + */ + OBUint8PropertyRange getfpEdgeBleedFilterEnableRange() { + OBUint8PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fpEdgeBleedFilterEnable") == 0) { + range = getPropertyRange(item, getConfigValue("fpEdgeBleedFilterEnable")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fpebfROIMinXRatio range. + * + * @return OBFloatPropertyRange the fpebfROIMinXRatio value of property range. + */ + OBFloatPropertyRange getfpebfROIMinXRatioRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fpebfROIMinXRatio") == 0) { + range = getPropertyRange(item, getConfigValue("fpebfROIMinXRatio")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fpebfROIMaxXRatio range. + * + * @return OBFloatPropertyRange the fpebfROIMaxXRatio value of property range. + */ + OBFloatPropertyRange getfpebfROIMaxXRatioRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fpebfROIMaxXRatio") == 0) { + range = getPropertyRange(item, getConfigValue("fpebfROIMaxXRatio")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fpebfROIMinYRatio range. + * + * @return OBFloatPropertyRange the fpebfROIMinYRatio value of property range. + */ + OBFloatPropertyRange getfpebfROIMinYRatioRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fpebfROIMinYRatio") == 0) { + range = getPropertyRange(item, getConfigValue("fpebfROIMinYRatio")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fpebfROIMaxYRatio range. + * + * @return OBFloatPropertyRange the fpebfROIMaxYRatio value of property range. + */ + OBFloatPropertyRange getfpebfROIMaxYRatioRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fpebfROIMaxYRatio") == 0) { + range = getPropertyRange(item, getConfigValue("fpebfROIMaxYRatio")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fpebfMinBleedLength range. + * + * @return OBUint16PropertyRange the fpebfMinBleedLength value of property range. + */ + OBUint16PropertyRange getfpebfMinBleedLengthRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fpebfMinBleedLength") == 0) { + range = getPropertyRange(item, getConfigValue("fpebfMinBleedLength")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fpTextureSparsityFilterEnable range. + * + * @return OBUint8PropertyRange the fpTextureSparsityFilterEnable value of property range. + */ + OBUint8PropertyRange getfpTextureSparsityFilterEnableRange() { + OBUint8PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fpTextureSparsityFilterEnable") == 0) { + range = getPropertyRange(item, getConfigValue("fpTextureSparsityFilterEnable")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fptsfROIMinXRatio range. + * + * @return OBFloatPropertyRange the fptsfROIMinXRatio value of property range. + */ + OBFloatPropertyRange getfptsfROIMinXRatioRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fptsfROIMinXRatio") == 0) { + range = getPropertyRange(item, getConfigValue("fptsfROIMinXRatio")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fptsfROIMaxXRatio range. + * + * @return OBFloatPropertyRange the fptsfROIMaxXRatio value of property range. + */ + OBFloatPropertyRange getfptsfROIMaxXRatioRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fptsfROIMaxXRatio") == 0) { + range = getPropertyRange(item, getConfigValue("fptsfROIMaxXRatio")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fptsfROIMinYRatio range. + * + * @return OBFloatPropertyRange the fptsfROIMinYRatio value of property range. + */ + OBFloatPropertyRange getfptsfROIMinYRatioRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fptsfROIMinYRatio") == 0) { + range = getPropertyRange(item, getConfigValue("fptsfROIMinYRatio")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fptsfROIMaxYRatio range. + * + * @return OBFloatPropertyRange the fptsfROIMaxYRatio value of property range. + */ + OBFloatPropertyRange getfptsfROIMaxYRatioRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fptsfROIMaxYRatio") == 0) { + range = getPropertyRange(item, getConfigValue("fptsfROIMaxYRatio")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fptsfMaxNoiseLevel range. + * + * @return OBUint16PropertyRange the fptsfMaxNoiseLevel value of property range. + */ + OBUint16PropertyRange getfptsfMaxNoiseLevelRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fptsfMaxNoiseLevel") == 0) { + range = getPropertyRange(item, getConfigValue("fptsfMaxNoiseLevel")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fptsfMaxSpeckleSize range. + * + * @return OBUint16PropertyRange the fptsfMaxSpeckleSize value of property range. + */ + OBUint16PropertyRange getfptsfMaxSpeckleSizeRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fptsfMaxSpeckleSize") == 0) { + range = getPropertyRange(item, getConfigValue("fptsfMaxSpeckleSize")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fpPatternAmbiguityFilterEnable range. + * + * @return OBUint8PropertyRange the fpPatternAmbiguityFilterEnable value of property range. + */ + OBUint8PropertyRange getfpPatternAmbiguityFilterEnableRange() { + OBUint8PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fpPatternAmbiguityFilterEnable") == 0) { + range = getPropertyRange(item, getConfigValue("fpPatternAmbiguityFilterEnable")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fppafROIMinXRatio range. + * + * @return OBFloatPropertyRange the fppafROIMinXRatio value of property range. + */ + OBFloatPropertyRange getfppafROIMinXRatioRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fppafROIMinXRatio") == 0) { + range = getPropertyRange(item, getConfigValue("fppafROIMinXRatio")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fppafROIMaxXRatio range. + * + * @return OBFloatPropertyRange the fppafROIMaxXRatio value of property range. + */ + OBFloatPropertyRange getfppafROIMaxXRatioRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fppafROIMaxXRatio") == 0) { + range = getPropertyRange(item, getConfigValue("fppafROIMaxXRatio")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fppafROIMinYRatio range. + * + * @return OBFloatPropertyRange the fppafROIMinYRatio value of property range. + */ + OBFloatPropertyRange getfppafROIMinYRatioRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fppafROIMinYRatio") == 0) { + range = getPropertyRange(item, getConfigValue("fppafROIMinYRatio")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fppafROIMaxYRatio range. + * + * @return OBFloatPropertyRange the fppafROIMaxYRatio value of property range. + */ + OBFloatPropertyRange getfppafROIMaxYRatioRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fppafROIMaxYRatio") == 0) { + range = getPropertyRange(item, getConfigValue("fppafROIMaxYRatio")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fppafMaxNoiseLevel range. + * + * @return OBUint16PropertyRange the fppafMaxNoiseLevel value of property range. + */ + OBUint16PropertyRange getfppafMaxNoiseLevelRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fppafMaxNoiseLevel") == 0) { + range = getPropertyRange(item, getConfigValue("fppafMaxNoiseLevel")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fppafMaxSpeckleSize range. + * + * @return OBUint16PropertyRange the fppafMaxSpeckleSize value of property range. + */ + OBUint16PropertyRange getfppafMaxSpeckleSizeRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fppafMaxSpeckleSize") == 0) { + range = getPropertyRange(item, getConfigValue("fppafMaxSpeckleSize")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fppafMaxWidthRatio range. + * + * @return OBFloatPropertyRange the fppafMaxWidthRatio value of property range. + */ + OBFloatPropertyRange getfppafMaxWidthRatioRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fppafMaxWidthRatio") == 0) { + range = getPropertyRange(item, getConfigValue("fppafMaxWidthRatio")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fppafMaxHeightRatio range. + * + * @return OBFloatPropertyRange the fppafMaxHeightRatio value of property range. + */ + OBFloatPropertyRange getfppafMaxHeightRatioRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fppafMaxHeightRatio") == 0) { + range = getPropertyRange(item, getConfigValue("fppafMaxHeightRatio")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fppafTolerance range. + * + * @return OBFloatPropertyRange the fppafTolerance value of property range. + */ + OBFloatPropertyRange getfppafToleranceRange() { + OBFloatPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fppafTolerance") == 0) { + range = getPropertyRange(item, getConfigValue("fppafTolerance")); + break; + } + } + return range; + } + + /** + * @brief Get the FalsePositive filter fppafScore range. + * + * @return OBUint16PropertyRange the fppafScore value of property range. + */ + OBUint16PropertyRange getfppafScoreRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "fppafScore") == 0) { + range = getPropertyRange(item, getConfigValue("fppafScore")); + break; + } + } + return range; + } +}; + +/** + * @brief MgcNoiseRemoval filter + */ +class MgcNoiseRemovalFilter : public Filter { +public: + MgcNoiseRemovalFilter(const std::string &activationKey = "") { + ob_error *error = nullptr; + auto impl = ob_create_private_filter("MgcNoiseRemovalFilter", activationKey.c_str(), &error); + Error::handle(&error); + init(impl); + } + + ~MgcNoiseRemovalFilter() noexcept override = default; + + /** + * @brief Set the mgc noise removal filter params. + * @param[in] filterParams OBMgcNoiseRemovalFilterParams. + */ + void setFilterParams(OBMgcNoiseRemovalFilterParams filterParams) { + setConfigValue("max_width_left", static_cast(filterParams.max_width_left)); + setConfigValue("max_width_right", static_cast(filterParams.max_width_right)); + setConfigValue("max_radius", static_cast(filterParams.max_radius)); + setConfigValue("margin_x_th", static_cast(filterParams.margin_x_th)); + setConfigValue("margin_y_th", static_cast(filterParams.margin_y_th)); + setConfigValue("limit_x_th", static_cast(filterParams.limit_x_th)); + setConfigValue("limit_y_th", static_cast(filterParams.limit_y_th)); + setConfigValue("width", static_cast(filterParams.width)); + setConfigValue("height", static_cast(filterParams.height)); + } + + /** + * @brief Get the mgc noise removal filter params. + * @return OBMgcNoiseRemovalFilterParams. + */ + OBMgcNoiseRemovalFilterParams getFilterParams() { + OBMgcNoiseRemovalFilterParams params{}; + params.max_width_left = static_cast(getConfigValue("max_width_left")); + params.max_width_right = static_cast(getConfigValue("max_width_right")); + params.max_radius = static_cast(getConfigValue("max_radius")); + params.margin_x_th = static_cast(getConfigValue("margin_x_th")); + params.margin_y_th = static_cast(getConfigValue("margin_y_th")); + params.limit_x_th = static_cast(getConfigValue("limit_x_th")); + params.limit_y_th = static_cast(getConfigValue("limit_y_th")); + params.width = static_cast(getConfigValue("width")); + params.height = static_cast(getConfigValue("height")); + return params; + } + + /** + * @brief Get the mgc noise removal filter max_width_left range. + * @return OBUint16PropertyRange The max_width_left of property range. + */ + OBUint16PropertyRange getMaxWidthLeftRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "max_width_left") == 0) { + range = getPropertyRange(item, getConfigValue("max_width_left")); + break; + } + } + return range; + } + + /** + * @brief Get the mgc noise removal filter max_width_right range. + * @return OBUint16PropertyRange The max_width_right of property range. + */ + OBUint16PropertyRange getMaxWidthRightRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "max_width_right") == 0) { + range = getPropertyRange(item, getConfigValue("max_width_right")); + break; + } + } + return range; + } + + /** + * @brief Get the mgc noise removal filter max_radius range. + * @return OBUint16PropertyRange The max_radius of property range. + */ + OBUint16PropertyRange getMaxRadiusRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "max_radius") == 0) { + range = getPropertyRange(item, getConfigValue("max_radius")); + break; + } + } + return range; + } + + /** + * @brief Get the mgc noise removal filter margin_x_th range. + * @return OBUint16PropertyRange The margin_x_th of property range. + */ + OBUint16PropertyRange getMarginXthRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "margin_x_th") == 0) { + range = getPropertyRange(item, getConfigValue("margin_x_th")); + break; + } + } + return range; + } + + /** + * @brief Get the mgc noise removal filter margin_y_th range. + * @return OBUint16PropertyRange The margin_y_th of property range. + */ + OBUint16PropertyRange getMarginYthRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "margin_y_th") == 0) { + range = getPropertyRange(item, getConfigValue("margin_y_th")); + break; + } + } + return range; + } + + /** + * @brief Get the mgc noise removal filter limit_x_th range. + * @return OBUint16PropertyRange The limit_x_th of property range. + */ + OBUint16PropertyRange getLimitXthRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "limit_x_th") == 0) { + range = getPropertyRange(item, getConfigValue("limit_x_th")); + break; + } + } + return range; + } + + /** + * @brief Get the mgc noise removal filter limit_y_th range. + * @return OBUint16PropertyRange The limit_y_th of property range. + */ + OBUint16PropertyRange getLimitYthRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "limit_y_th") == 0) { + range = getPropertyRange(item, getConfigValue("limit_y_th")); + break; + } + } + return range; + } + + /** + * @brief Get the mgc noise removal filter width range. + * @return OBUint16PropertyRange The width of property range. + */ + OBUint16PropertyRange getWidthRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "width") == 0) { + range = getPropertyRange(item, getConfigValue("width")); + break; + } + } + return range; + } + + /** + * @brief Get the mgc noise removal filter height range. + * @return OBUint16PropertyRange The height of property range. + */ + OBUint16PropertyRange getHeightRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "height") == 0) { + range = getPropertyRange(item, getConfigValue("height")); + break; + } + } + return range; + } +}; + +/** + * @brief LutNoiseRemoval filter + */ +class LutNoiseRemovalFilter : public Filter { +public: + LutNoiseRemovalFilter(const std::string &activationKey = "") { + ob_error *error = nullptr; + auto impl = ob_create_private_filter("LutNoiseRemovalFilter", activationKey.c_str(), &error); + Error::handle(&error); + init(impl); + } + + ~LutNoiseRemovalFilter() noexcept override = default; + + /** + * @brief Set the lut noise removal filter params. + * @param[in] filterParams OBLutNoiseRemovalFilterParams. + */ + void setFilterParams(OBLutNoiseRemovalFilterParams filterParams) { + for(int i = 0; i < 16; ++i) { + setConfigValue("max_lut_" + std::to_string(i), static_cast(filterParams.max_lut[i])); + } + setConfigValue("min_diff", static_cast(filterParams.min_diff)); + setConfigValue("width", static_cast(filterParams.width)); + setConfigValue("height", static_cast(filterParams.height)); + } + + /** + * @brief Get the lut noise removal filter params. + * @return OBLutNoiseRemovalFilterParams. + */ + OBLutNoiseRemovalFilterParams getFilterParams() { + OBLutNoiseRemovalFilterParams params{}; + for(int i = 0; i < 16; ++i) { + params.max_lut[i] = static_cast(getConfigValue("max_lut_" + std::to_string(i))); + } + params.min_diff = static_cast(getConfigValue("min_diff")); + params.width = static_cast(getConfigValue("width")); + params.height = static_cast(getConfigValue("height")); + return params; + } + + /** + * @brief Get the lut noise removal filter max_lut range for a given index (0-15). + * @param[in] index LUT entry index in range [0, 15]. + * @return OBUint16PropertyRange The max_lut of property range. + */ + OBUint16PropertyRange getMaxLutRange(int index) { + OBUint16PropertyRange range{}; + if(index < 0 || index >= 16) { + return range; + } + std::string name = "max_lut_" + std::to_string(index); + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, name.c_str()) == 0) { + range = getPropertyRange(item, getConfigValue(name)); + break; + } + } + return range; + } + + /** + * @brief Get the lut noise removal filter min_diff range. + * @return OBUint16PropertyRange The min_diff of property range. + */ + OBUint16PropertyRange getMinDiffRange() { + 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 lut noise removal filter width range. + * @return OBUint16PropertyRange The width of property range. + */ + OBUint16PropertyRange getWidthRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "width") == 0) { + range = getPropertyRange(item, getConfigValue("width")); + break; + } + } + return range; + } + + /** + * @brief Get the lut noise removal filter height range. + * @return OBUint16PropertyRange The height of property range. + */ + OBUint16PropertyRange getHeightRange() { + OBUint16PropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + if(strcmp(item.name, "height") == 0) { + range = getPropertyRange(item, getConfigValue("height")); + break; + } + } + return range; + } +}; + +/** + * @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 override = default; +}; + +/** + * @brief Enhanced depth filter that requires a device for activation. + * + * @note The constructor is a template so that Filter.hpp does not need to include Device.hpp. + * The template is instantiated at the call site where the device type is complete. + */ +class EnhancedDepthFilter : public Filter { +public: + /** + * @brief Construct an EnhancedDepthFilter and activate it for the given device. + * + * @param[in] device The device the filter is bound to. + * @param[in] modelPath Optional path to the inference model file used during activation. When empty, the + * filter falls back to its default model file at extensions/filters/enhanced_depth_filter/model.sm4 + * (located next to the filter library). + */ + template explicit EnhancedDepthFilter(std::shared_ptr device, const std::string &modelPath = "") { + if(!device) { + throw std::invalid_argument("device is null"); + } + ob_error *error = nullptr; + auto impl = ob_create_private_filter("EnhancedDepthFilter", "", &error); + Error::handle(&error); + + // Only pass options when a model path is provided; otherwise hand down nullptr so the filter uses its default. + ob_priv_filter_activate_options options{}; + ob_priv_filter_activate_options *optionsPtr = nullptr; + if(!modelPath.empty()) { + options.struct_size = sizeof(options); + options.model_path = modelPath.c_str(); + optionsPtr = &options; + } + ob_filter_activate_private_ex(impl, device->getImpl(), optionsPtr, &error); + Error::handle(&error); + init(impl); + } + + ~EnhancedDepthFilter() noexcept override = default; + + /** + * @brief Get the resolutions supported by the enhanced depth filter for the constrained (aligned-to) stream. + * + * @return The list of supported {width, height} pairs. This is the single source of truth used by + * @ref isSupportedResolution. + */ + static const std::vector> &getSupportedResolutions() { + static const std::vector> supportedResolutions = { + { 640, 480 }, + { 1280, 720 }, + { 1280, 800 }, + }; + return supportedResolutions; + } + + /** + * @brief Get the frame formats supported by the enhanced depth filter for a given stream type. + * + * @param[in] streamType The stream type. Only color and depth streams are supported. + * + * @return The list of supported formats (color: OB_FORMAT_RGB; depth: OB_FORMAT_Y10, OB_FORMAT_Y11, + * OB_FORMAT_Y12, OB_FORMAT_Y14, OB_FORMAT_Y16, OB_FORMAT_Z16). Empty for unsupported stream types. This is the single + * source of truth used by @ref isSupportedFormat. + */ + static std::vector getSupportedFormats(OBStreamType streamType) { + if(streamType == OB_STREAM_COLOR) { + return { OB_FORMAT_RGB }; + } + if(streamType == OB_STREAM_DEPTH) { + return { OB_FORMAT_Y10, OB_FORMAT_Y11, OB_FORMAT_Y12, OB_FORMAT_Y14, OB_FORMAT_Y16, OB_FORMAT_Z16 }; + } + return {}; + } + + /** + * @brief Check whether a resolution is supported by the enhanced depth filter for a given stream alignment pair. + * + * @param[in] sourceStreamType The source stream type that provides the input frames. + * @param[in] alignToStreamType The target stream type that the source stream is aligned to. + * @param[in] width The frame width to validate. + * @param[in] height The frame height to validate. + * + * @return true if the resolution is supported for the specified alignment combination, otherwise false. + */ + static bool isSupportedResolution(OBStreamType sourceStreamType, OBStreamType alignToStreamType, uint32_t width, uint32_t height) { + if(sourceStreamType != alignToStreamType) { + // If the source and target stream types are different, any resolution is supported. + return true; + } + + for(const auto &res: getSupportedResolutions()) { + if(res.first == width && res.second == height) { + return true; + } + } + return false; + } + + /** + * @brief Check whether a frame format is supported by the enhanced depth filter for a given stream type. + * + * @param[in] streamType The stream type to validate. Only color and depth streams are supported. + * @param[in] format The frame format to validate. + * + * @return true if the format is supported for the given stream type, otherwise false. + */ + static bool isSupportedFormat(OBStreamType streamType, OBFormat format) { + for(const auto &supported: getSupportedFormats(streamType)) { + if(supported == format) { + return true; + } + } + return false; + } + + /** + * @brief Set the working resolution of the enhanced depth filter. + * + * @param[in] width The target frame width. + * @param[in] height The target frame height. + */ + void setResolution(uint32_t width, uint32_t height) { + setConfigValue("width", static_cast(width)); + setConfigValue("height", static_cast(height)); + } + + /** + * @brief Get the current configured frame width. + * + * @return uint32_t The current width. + */ + uint32_t getCurrentWidth() const { + return static_cast(getConfigValue("width")); + } + + /** + * @brief Get the current configured frame height. + * + * @return uint32_t The current height. + */ + uint32_t getCurrentHeight() const { + return static_cast(getConfigValue("height")); + } + + /** + * @brief Set the confidence threshold for depth values. + * + * @param value The confidence threshold. + */ + void setConfidenceThreshold(uint32_t value) { + setConfigValue("confidence_threshold", static_cast(value)); + } + + /** + * @brief Get the property range of the confidence threshold range. + */ + OBIntPropertyRange getConfidenceThresholdRange() { + OBIntPropertyRange range{}; + const auto &schemaVec = getConfigSchemaVec(); + for(const auto &item: schemaVec) { + const char *name = "confidence_threshold"; + if(std::strcmp(item.name, name) == 0) { + range = getPropertyRange(item, getConfigValue(name)); + break; + } + } + return range; + } +}; + +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[in] 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 Returns the mapping of filter type names to their corresponding type_index. + */ +inline const std::unordered_map &getFilterTypeMap() { + static const std::unordered_map filterTypeMap = { + { "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) }, + { "SpatialFastFilter", typeid(SpatialFastFilter) }, + { "SpatialModerateFilter", typeid(SpatialModerateFilter) }, + { "EdgeNoiseRemovalFilter", typeid(EdgeNoiseRemovalFilter) }, + { "FalsePositiveFilter", typeid(FalsePositiveFilter) }, + { "MgcNoiseRemovalFilter", typeid(MgcNoiseRemovalFilter) }, + { "LutNoiseRemovalFilter", typeid(LutNoiseRemovalFilter) }, + { "UnDistortionFilter", typeid(UnDistortionFilter) }, + { "EnhancedDepthFilter", typeid(EnhancedDepthFilter) }, + }; + return filterTypeMap; +} + +/** + * @brief Define the is() template function for the Filter class + * + * @note When adding a new filter class, ensure the filter type map + * (see getFilterTypeMap()) is updated accordingly to maintain correct type matching. + */ +template bool Filter::is() { + std::string name = type(); + + const auto &filterTypeMap = getFilterTypeMap(); + auto it = filterTypeMap.find(name); + if(it != filterTypeMap.end()) { + return std::type_index(typeid(T)) == it->second; + } + return false; +} + +} // namespace ob diff --git a/orbbec_camera/SDK/x64/include/libobsensor/hpp/Frame.hpp b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Frame.hpp new file mode 100644 index 00000000..36bebefa --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Frame.hpp @@ -0,0 +1,1344 @@ +// 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[in] 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 the auth token carried by the frame. + * + * @return uint64_t The auth token value. + */ + uint64_t getToken() const { + ob_error *error = nullptr; + auto token = ob_frame_get_token(impl_, &error); + Error::handle(&error); + + return token; + } + + /** + * @brief Set the auth token carried by the frame. + * + * @param token The auth token value. + */ + void setToken(uint64_t token) { + ob_error *error = nullptr; + auto unConstImpl = const_cast(impl_); + + ob_frame_set_token(unConstImpl, token, &error); + Error::handle(&error); + } + + /** + * @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[in] 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[in] 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_); + } + + /** + * @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] srcFrame Source frame object to copy the information from. + */ + void copyFrameInfo(std::shared_ptr srcFrame) { + ob_error *error = nullptr; + auto unConstImpl = const_cast(impl_); + + ob_frame_copy_info(srcFrame->getImpl(), unConstImpl, &error); + Error::handle(&error); + } + + /** + * @brief Set the system timestamp of the frame in microseconds. + * + * @param systemTimestampUs frame system timestamp to set in microseconds. + */ + void setSystemTimestampUs(uint64_t systemTimestampUs) { + ob_error *error = nullptr; + auto unConstImpl = const_cast(impl_); + + ob_frame_set_system_timestamp_us(unConstImpl, systemTimestampUs, &error); + Error::handle(&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] data The new data to update the frame with. + * @param[in] dataSize The size of the new data. + */ + void updateData(const uint8_t *data, uint32_t dataSize) { + ob_error *error = nullptr; + auto unConstImpl = const_cast(impl_); + + ob_frame_update_data(unConstImpl, data, dataSize, &error); + Error::handle(&error); + } + + /** + * @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] metadata The new metadata to update. + * @param[in] metadataSize The size of the new metadata. + */ + void updateMetadata(const uint8_t *metadata, uint32_t metadataSize) { + ob_error *error = nullptr; + auto unConstImpl = const_cast(impl_); + + ob_frame_update_metadata(unConstImpl, metadata, metadataSize, &error); + Error::handle(&error); + } + + /** + * @brief Set (override) the stream profile of the frame + * + * @param profile The stream profile to set for the frame. + */ + void setStreamProfile(std::shared_ptr profile) { + ob_error *error = nullptr; + auto unConstImpl = const_cast(impl_); + + ob_frame_set_stream_profile(unConstImpl, profile->getImpl(), &error); + Error::handle(&error); + } + +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[in] 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; + } + + /** + * @brief Set video frame pixel format + * + * @param pixelType the pixel format of the frame + */ + void setPixelType(OBPixelType pixelType) { + ob_error *error = nullptr; + auto unConstImpl = const_cast(impl_); + + ob_video_frame_set_pixel_type(unConstImpl, pixelType, &error); + Error::handle(&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] bitSize the effective number of pixels in the pixel, or 0 if it is an unsupported format + */ + void setPixelAvailableBitSize(uint8_t bitSize) { + ob_error *error = nullptr; + auto unConstImpl = const_cast(impl_); + + ob_video_frame_set_pixel_available_bit_size(unConstImpl, bitSize, &error); + Error::handle(&error); + } + +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[in] 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[in] 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 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] valueScale The value scale of the depth frame + */ + void setValueScale(float valueScale) { + ob_error *error = nullptr; + auto unConstImpl = const_cast(impl_); + + ob_depth_frame_set_value_scale(unConstImpl, valueScale, &error); + Error::handle(&error); + } +}; + +/** + * @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[in] impl The pointer to the internal frame object. + */ + explicit IRFrame(const ob_frame *impl) : VideoFrame(impl) {}; + + ~IRFrame() noexcept override = default; +}; + +/** + * @brief Define the ConfidenceFrame class, which inherits from the VideoFrame class + * + */ +class ConfidenceFrame : public VideoFrame { + +public: + /** + * @brief Construct a new ConfidenceFrame 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[in] impl The pointer to the internal frame object. + */ + explicit ConfidenceFrame(const ob_frame *impl) : VideoFrame(impl) {}; + + ~ConfidenceFrame() 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[in] 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 LiDARPointsFrame class, which inherits from the Frame class + * @brief The LiDARPointsFrame class is used to obtain LiDAR point cloud data. + * + * @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_LIDAR_POINT : @ref OBLiDARPoint + * - @ref OB_FORMAT_LIDAR_SPHERE_POINT : @ref OBLiDARSpherePoint + * - @ref OB_FORMAT_LIDAR_SCAN : @ref OBLiDARScanPoint + * - @ref OB_FORMAT_LIDAR_CALIBRATION : LiDAR calibration mode point cloud, raw data + * - The pointcloud data holds a set of points. To find the number of points, divide the dataSize by the structure + * size of the corresponding point type. + */ +class LiDARPointsFrame : public Frame { +public: + /** + * @brief Construct a new LiDARPointsFrame 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[in] impl The pointer to the internal frame object. + */ + explicit LiDARPointsFrame(const ob_frame *impl) : Frame(impl){}; + ~LiDARPointsFrame() noexcept override = default; +}; + +/** + * @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[in] 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[in] 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[in] 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); + } + + /** + * @brief Get the depth frame from the frameset. + * + * @return std::shared_ptr Return the depth frame. + */ + std::shared_ptr getDepthFrame() const { + ob_error *error = nullptr; + auto frame = ob_frameset_get_depth_frame(impl_, &error); + if(!frame) { + return nullptr; + } + Error::handle(&error); + return std::make_shared(frame); + } + + /** + * @brief Get the color frame from the frameset. + * + * @return std::shared_ptr Return the color frame. + */ + std::shared_ptr getColorFrame() const { + ob_error *error = nullptr; + auto frame = ob_frameset_get_color_frame(impl_, &error); + if(!frame) { + return nullptr; + } + Error::handle(&error); + return std::make_shared(frame); + } + + /** + * @brief Get the infrared frame from the frameset. + * + * @return std::shared_ptr Return the infrared frame. + */ + std::shared_ptr getIrFrame() const { + ob_error *error = nullptr; + auto frame = ob_frameset_get_ir_frame(impl_, &error); + if(!frame) { + return nullptr; + } + Error::handle(&error); + return std::make_shared(frame); + } + + /** + * @brief Get the point cloud frame from the frameset. + * + * @return std::shared_ptr Return the point cloud frame. + */ + std::shared_ptr getPointsFrame() const { + ob_error *error = nullptr; + auto frame = ob_frameset_get_points_frame(impl_, &error); + if(!frame) { + return nullptr; + } + Error::handle(&error); + return std::make_shared(frame); + } + +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[in] frameType The type of the frame. + * @param[in] format The format of the frame. + * @param[in] 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[in] frameType The type of the frame. + * @param[in] format The format of the frame. + * @param[in] width The width of the frame. + * @param[in] height The height of the frame. + * @param[in] 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[in] otherFrame The source frame to be copied. + * @param[in] 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[in] 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(); + } + + /** + * @brief Create a new FrameSet object. + * + * This function creates a new FrameSet instance by internally calling the native C API. + * The returned FrameSet is managed by a std::shared_ptr, and its lifetime will be + * automatically managed. When no references remain, the underlying native resources will be released. + * + * @return std::shared_ptr The created FrameSet object. + */ + static std::shared_ptr createFrameSet() { + ob_error *error = nullptr; + auto impl = ob_create_frameset(&error); + Error::handle(&error); + return std::make_shared(impl); + } + +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[in] frame The frame object. + * @param[in] 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: + case OB_FRAME_COLOR_LEFT: + case OB_FRAME_COLOR_RIGHT: + return (typeid(T) == typeid(ColorFrame) || typeid(T) == typeid(VideoFrame)); + case OB_FRAME_CONFIDENCE: + return (typeid(T) == typeid(ConfidenceFrame) || 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_LIDAR_POINTS: + return (typeid(T) == typeid(LiDARPointsFrame)); + 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/orbbec_camera/SDK/x64/include/libobsensor/hpp/Pipeline.hpp b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Pipeline.hpp new file mode 100644 index 00000000..5b3c86a8 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Pipeline.hpp @@ -0,0 +1,528 @@ +// 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[in] 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[in] 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[in] 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[in] streamType The video stream type. + * @param[in] width The video stream width (default is OB_WIDTH_ANY, which selects the default resolution). + * @param[in] height The video stream height (default is OB_HEIGHT_ANY, which selects the default resolution). + * @param[in] fps The video stream frame rate (default is OB_FPS_ANY, which selects the default frame rate). + * @param[in] 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[in] sensorType The sensor type to be enabled. + * @param[in] width The video stream width (default is OB_WIDTH_ANY, which selects the default resolution). + * @param[in] height The video stream height (default is OB_HEIGHT_ANY, which selects the default resolution). + * @param[in] fps The video stream frame rate (default is OB_FPS_ANY, which selects the default frame rate). + * @param[in] 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 a video stream to be used in the pipeline with decimation configuration. + * @brief Will convert sensor type to stream type automatically. + * + * @param[in] sensorType The sensor type to be enabled. + * @param[in] decimationConfig The decimation configuration for this stream. + * @param[in] fps The video stream frame rate (default is OB_FPS_ANY, which selects the default frame rate). + * @param[in] format The video stream format (default is OB_FORMAT_ANY, which selects the default format). + */ + void enableVideoStream(OBSensorType sensorType, OBHardwareDecimationConfig decimationConfig, uint32_t fps = OB_FPS_ANY, + OBFormat format = OB_FORMAT_ANY) const { + auto streamType = ob::TypeHelper::convertSensorTypeToStreamType(sensorType); + ob_error *error = nullptr; + ob_config_enable_video_stream_by_decimation_config(impl_, streamType, decimationConfig, fps, format, &error); + Error::handle(&error); + } + + /** + * @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[in] fullScaleRange The full-scale range of the accelerometer (default is OB_ACCEL_FULL_SCALE_RANGE_ANY, which selects the default range). + * @param[in] 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[in] fullScaleRange The full-scale range of the gyroscope (default is OB_GYRO_FULL_SCALE_RANGE_ANY, which selects the default range). + * @param[in] 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); + } + + /** + * @brief Enable a LiDAR stream to be used in the pipeline. + * + * This function allows users to enable a LiDAR 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[in] scanRate The scan rate of the LiDAR (default is OB_LIDAR_SCAN_ANY, which selects the default scan rate). + * @param[in] format The stream format (default is OB_FORMAT_ANY, which selects the default format). + */ + void enableLiDARStream(OBLiDARScanRate scanRate = OB_LIDAR_SCAN_ANY, OBFormat format = OB_FORMAT_ANY) const { + ob_error *error = nullptr; + ob_config_enable_lidar_stream(impl_, scanRate, format, &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[in] 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[in] 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[in] 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[in] 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[in] 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[in] frame The returned frameset data + */ + typedef std::function frame)> FrameSetCallback; + +private: + ob_pipeline_t *impl_; + FrameSetCallback callback_; + std::function statusCallback_; + +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[in] 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[in] config The configuration of the pipeline + * @param[in] 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)); + } + + static void healthMonitorCallback(ob_pipeline_status status, void *userData) { + auto pipeline = static_cast(userData); + if(pipeline->statusCallback_) { + pipeline->statusCallback_(status); + } + } + + /** + * @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[in] 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[in] 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[in] colorProfile The color stream profile, which is the target stream profile for the depth-to-color alignment. + * @param[in] 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); + } + + /** + * @brief Get the current pipeline status observed during streaming. + * + * @return OBPipelineStatus The accumulated status since the last call or pipeline start. Status is reset after each call. + */ + OBPipelineStatus getStatus() const { + ob_error *error = nullptr; + OBPipelineStatus status = ob_pipeline_get_status(impl_, &error); + Error::handle(&error); + return status; + } + + /** + * @brief Enable pipeline health monitor with periodic status polling. + * + * @param[in] callback The callback function invoked when abnormal status is detected (from internal thread, avoid blocking). + * @param[in] intervalMs Polling interval in milliseconds (recommended: 3000-5000, default: 3000). + */ + void enableHealthMonitor(std::function callback, uint32_t intervalMs = 3000) { + statusCallback_ = callback; + ob_error *error = nullptr; + ob_pipeline_enable_health_monitor(impl_, &Pipeline::healthMonitorCallback, this, intervalMs, &error); + Error::handle(&error); + } + + /** + * @brief Disable pipeline health monitor. + */ + void disableHealthMonitor() const { + ob_error *error = nullptr; + ob_pipeline_disable_health_monitor(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/orbbec_camera/SDK/x64/include/libobsensor/hpp/RecordPlayback.hpp b/orbbec_camera/SDK/x64/include/libobsensor/hpp/RecordPlayback.hpp new file mode 100644 index 00000000..7acfab41 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/hpp/RecordPlayback.hpp @@ -0,0 +1,197 @@ +// 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_ = nullptr; + +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) noexcept { + if(this != &other) { + impl_ = other.impl_; + other.impl_ = nullptr; + } + } + + RecordDevice &operator=(RecordDevice &&other) noexcept { + 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: + /** + * @brief Constructs a PlaybackDevice for playing back recorded device data. + * @param[in] file Path to the playback file. + * @param[in] presetPath Path to a preset JSON file to load after device creation. If empty, no preset is loaded. + */ + explicit PlaybackDevice(const std::string &file, const std::string &presetPath = "") : Device(nullptr) { + ob_error *error = nullptr; + impl_ = ob_create_playback_device(file.c_str(), &error); + Error::handle(&error); + + if(!presetPath.empty()) { + loadPresetFromJsonFile(presetPath.c_str()); + } + } + + virtual ~PlaybackDevice() noexcept override = default; + + PlaybackDevice(PlaybackDevice &&other) noexcept : Device(std::move(other)) {} + + PlaybackDevice &operator=(PlaybackDevice &&other) noexcept { + 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/orbbec_camera/SDK/x64/include/libobsensor/hpp/Sensor.hpp b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Sensor.hpp new file mode 100644 index 00000000..1bda3384 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Sensor.hpp @@ -0,0 +1,239 @@ +// 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[in] 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[in] streamProfile The stream configuration. + * @param[in] 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[in] 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[in] 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[in] 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[in] 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/orbbec_camera/SDK/x64/include/libobsensor/hpp/StreamProfile.hpp b/orbbec_camera/SDK/x64/include/libobsensor/hpp/StreamProfile.hpp new file mode 100644 index 00000000..9b80d4b3 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/hpp/StreamProfile.hpp @@ -0,0 +1,603 @@ +// 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[in] 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[in] 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); + } + + /** + * @brief Get the decimation configuration of the stream. + * Includes original resolution and scale factor. + * + * @return OBHardwareDecimationConfig Return the decimation configuration. + */ + OBHardwareDecimationConfig getDecimationConfig() const { + ob_error *error = nullptr; + auto decimationConfig = ob_video_stream_profile_get_decimation_config(const_cast(impl_), &error); + Error::handle(&error); + return decimationConfig; + } + +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(); + } +}; + +/** + * @brief Class representing a LiDAR stream profile. + */ + +class LiDARStreamProfile : public StreamProfile { +public: + explicit LiDARStreamProfile(const ob_stream_profile_t *impl) : StreamProfile(impl) {} + + ~LiDARStreamProfile() noexcept override = default; + + OBLiDARScanRate getScanRate() const { + ob_error *error = nullptr; + auto rate = ob_lidar_stream_profile_get_scan_rate(impl_, &error); + Error::handle(&error); + return rate; + } +}; + +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_COLOR_LEFT: + case OB_STREAM_COLOR_RIGHT: + case OB_STREAM_DEPTH: + case OB_STREAM_RAW_PHASE: + case OB_STREAM_CONFIDENCE: + return typeid(T) == typeid(VideoStreamProfile); + case OB_STREAM_ACCEL: + return typeid(T) == typeid(AccelStreamProfile); + case OB_STREAM_GYRO: + return typeid(T) == typeid(GyroStreamProfile); + case OB_STREAM_LIDAR: + return typeid(T) == typeid(LiDARStreamProfile); + 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_COLOR_LEFT: + case OB_STREAM_COLOR_RIGHT: + case OB_STREAM_VIDEO: + case OB_STREAM_CONFIDENCE: + return std::make_shared(impl); + case OB_STREAM_ACCEL: + return std::make_shared(impl); + case OB_STREAM_GYRO: + return std::make_shared(impl); + case OB_STREAM_LIDAR: + 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[in] 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[in] width The width of the stream. Pass OB_WIDTH_ANY if no matching condition is required. + * @param[in] height The height of the stream. Pass OB_HEIGHT_ANY if no matching condition is required. + * @param[in] format The type of the stream. Pass OB_FORMAT_ANY if no matching condition is required. + * @param[in] 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 video stream profile according to the decimation configuration. If multiple profiles match, the first one in the list is + * returned. Throws an exception when no matching profile is found. + * + * @param[in] decimationConfig Decimation configuration. The actual resolution is computed fromthe original resolution and scale factor. + * @param[in] format Stream format. Pass OB_FORMAT_ANY if no matching condition is required. + * @param[in] fps Frame rate. Pass OB_FPS_ANY if no matching condition is required. + * + * @return std::shared_ptr Return the matched video stream profile. + */ + std::shared_ptr getVideoStreamProfile(OBHardwareDecimationConfig decimationConfig, 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_by_decimation_config(impl_, decimationConfig, 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[in] fullScaleRange The full scale range. Pass 0 if no matching condition is required. + * @param[in] 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[in] fullScaleRange The full scale range. Pass 0 if no matching condition is required. + * @param[in] 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(); + } + + /** + * @brief Match the corresponding LiDAR 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[in] scanRate The scan rate of LiDAR. Pass OB_LIDAR_SCAN_ANY if no matching condition is required. + * @param[in] format The type of the stream. Pass OB_FORMAT_ANY if no matching condition is required. + */ + std::shared_ptr getLiDARStreamProfile(OBLiDARScanRate scanRate, OBFormat format) const { + ob_error *error = nullptr; + auto profile = ob_stream_profile_list_get_lidar_stream_profile(impl_, scanRate, format, &error); + Error::handle(&error); + auto lsp = StreamProfileFactory::create(profile); + return lsp->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/orbbec_camera/SDK/x64/include/libobsensor/hpp/TypeHelper.hpp b/orbbec_camera/SDK/x64/include/libobsensor/hpp/TypeHelper.hpp new file mode 100644 index 00000000..97a3a086 --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/hpp/TypeHelper.hpp @@ -0,0 +1,234 @@ +// 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 OBIMUSampleRate to its numeric frequency value in Hz. + * + * @param[in] type OBIMUSampleRate type. + * + * @return IMU sample rate value in Hz. + */ + static float convertOBIMUSampleRateTypeToValue(const OBIMUSampleRate &type) { + return ob_imu_rate_type_to_value(type); + } + + /** + * @brief Convert a numeric IMU sample rate value in Hz to OBIMUSampleRate. + * + * @param[in] value IMU sample rate value in Hz. + * + * @return Matching OBIMUSampleRate. + */ + static OBIMUSampleRate convertOBIMUSampleRateValueToType(float value) { + return ob_imu_rate_value_to_type(value); + } + + /** + * @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 OBLiDARScanRate to " string " type and then return. + * + * @param[in] type OBLiDARScanRate type. + * @return OBLiDARScanRate of "string" type. + */ + static std::string convertOBLiDARScanRateTypeToString(const OBLiDARScanRate &type) { + return ob_lidar_scan_rate_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 Convert OBStreamType to OBSensorType and then return. + * + * @param[in] type OBStreamType type. + * + * @return OBSensorType type. + */ + static OBSensorType convertStreamTypeToSensorType(OBStreamType type) { + return ob_stream_type_to_sensor_type(type); + } + + /** + * @brief Convert OBStreamType to OBFrameType and then return. + * + * @param[in] type OBStreamType type. + * + * @return OBFrameType type. + */ + static OBFrameType convertStreamTypeToFrameType(OBStreamType type) { + return ob_stream_type_to_frame_type(type); + } + + /** + * @brief Convert OBFrameType to OBStreamType and then return. + * + * @param[in] type OBFrameType type. + * + * @return OBStreamType type. + */ + static OBStreamType convertFrameTypeToStreamType(OBFrameType type) { + return ob_frame_type_to_stream_type(type); + } + + /** + * @brief Convert OBFrameType to OBSensorType and then return. + * + * @param[in] type OBFrameType type. + * + * @return OBSensorType type. + */ + static OBSensorType convertFrameTypeToSensorType(OBFrameType type) { + return ob_frame_type_to_sensor_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_COLOR_LEFT, + * OB_SENSOR_COLOR_RIGHT, + * OB_SENSOR_DEPTH, + * OB_SENSOR_IR, + * OB_SENSOR_IR_LEFT, + * OB_SENSOR_IR_RIGHT, + * OB_SENSOR_CONFIDENCE, + * + * @param[in] type The sensor type + * + * @return true/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_COLOR_LEFT, + * OB_STREAM_COLOR_RIGHT, + * OB_STREAM_IR, + * OB_STREAM_IR_LEFT, + * OB_STREAM_IR_RIGHT, + * OB_STREAM_CONFIDENCE, + * + * @param[in] 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/orbbec_camera/SDK/x64/include/libobsensor/hpp/Types.hpp b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Types.hpp new file mode 100644 index 00000000..420f1a01 --- /dev/null +++ b/orbbec_camera/SDK/x64/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/orbbec_camera/SDK/x64/include/libobsensor/hpp/Utils.hpp b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Utils.hpp new file mode 100644 index 00000000..c1f8a9ab --- /dev/null +++ b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Utils.hpp @@ -0,0 +1,206 @@ +// 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; + } + + /** + * @brief Save LiDAR point cloud to PLY file. + * + * @param[in] fileName Point cloud save path + * @param[in] frame LiDAR point cloud frame + * @param[in] saveBinary Binary or textual,true: binary, false: textual + * @return bool save LiDAR point cloud result + */ + static bool saveLiDARPointcloudToPly(const char *fileName, std::shared_ptr frame, bool saveBinary) { + ob_error *error = NULL; + auto unConstImpl = const_cast(frame->getImpl()); + bool result = ob_save_lidar_pointcloud_to_ply(fileName, unConstImpl, saveBinary, &error); + Error::handle(&error, false); + return result; + } +}; +} // namespace ob diff --git a/orbbec_camera/SDK/x64/include/libobsensor/hpp/Version.hpp b/orbbec_camera/SDK/x64/include/libobsensor/hpp/Version.hpp new file mode 100644 index 00000000..21b52469 --- /dev/null +++ b/orbbec_camera/SDK/x64/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/orbbec_camera/SDK/lib/x64/OrbbecSDKConfig-release.cmake b/orbbec_camera/SDK/x64/lib/OrbbecSDKConfig-release.cmake similarity index 100% rename from orbbec_camera/SDK/lib/x64/OrbbecSDKConfig-release.cmake rename to orbbec_camera/SDK/x64/lib/OrbbecSDKConfig-release.cmake diff --git a/orbbec_camera/SDK/lib/x64/OrbbecSDKConfig.cmake b/orbbec_camera/SDK/x64/lib/OrbbecSDKConfig.cmake similarity index 100% rename from orbbec_camera/SDK/lib/x64/OrbbecSDKConfig.cmake rename to orbbec_camera/SDK/x64/lib/OrbbecSDKConfig.cmake diff --git a/orbbec_camera/SDK/lib/x64/OrbbecSDKVersion.cmake b/orbbec_camera/SDK/x64/lib/OrbbecSDKVersion.cmake similarity index 100% rename from orbbec_camera/SDK/lib/x64/OrbbecSDKVersion.cmake rename to orbbec_camera/SDK/x64/lib/OrbbecSDKVersion.cmake diff --git a/orbbec_camera/SDK/lib/x64/extensions/depthengine/libdepthengine.so b/orbbec_camera/SDK/x64/lib/extensions/depthengine/libdepthengine.so similarity index 100% rename from orbbec_camera/SDK/lib/x64/extensions/depthengine/libdepthengine.so rename to orbbec_camera/SDK/x64/lib/extensions/depthengine/libdepthengine.so diff --git a/orbbec_camera/SDK/lib/x64/extensions/depthengine/libdepthengine.so.2.0 b/orbbec_camera/SDK/x64/lib/extensions/depthengine/libdepthengine.so.2.0 similarity index 100% rename from orbbec_camera/SDK/lib/x64/extensions/depthengine/libdepthengine.so.2.0 rename to orbbec_camera/SDK/x64/lib/extensions/depthengine/libdepthengine.so.2.0 diff --git a/orbbec_camera/SDK/lib/x64/extensions/filters/libFilterProcessor.so b/orbbec_camera/SDK/x64/lib/extensions/filters/libFilterProcessor.so similarity index 100% rename from orbbec_camera/SDK/lib/x64/extensions/filters/libFilterProcessor.so rename to orbbec_camera/SDK/x64/lib/extensions/filters/libFilterProcessor.so diff --git a/orbbec_camera/SDK/lib/x64/extensions/filters/libob_priv_filter.so b/orbbec_camera/SDK/x64/lib/extensions/filters/libob_priv_filter.so similarity index 100% rename from orbbec_camera/SDK/lib/x64/extensions/filters/libob_priv_filter.so rename to orbbec_camera/SDK/x64/lib/extensions/filters/libob_priv_filter.so diff --git a/orbbec_camera/SDK/lib/x64/extensions/firmwareupdater/libfirmwareupdater.so b/orbbec_camera/SDK/x64/lib/extensions/firmwareupdater/libfirmwareupdater.so similarity index 100% rename from orbbec_camera/SDK/lib/x64/extensions/firmwareupdater/libfirmwareupdater.so rename to orbbec_camera/SDK/x64/lib/extensions/firmwareupdater/libfirmwareupdater.so diff --git a/orbbec_camera/SDK/lib/x64/extensions/frameprocessor/libob_frame_processor.so b/orbbec_camera/SDK/x64/lib/extensions/frameprocessor/libob_frame_processor.so similarity index 100% rename from orbbec_camera/SDK/lib/x64/extensions/frameprocessor/libob_frame_processor.so rename to orbbec_camera/SDK/x64/lib/extensions/frameprocessor/libob_frame_processor.so diff --git a/orbbec_camera/SDK/lib/x64/libOrbbecSDK.so b/orbbec_camera/SDK/x64/lib/libOrbbecSDK.so similarity index 100% rename from orbbec_camera/SDK/lib/x64/libOrbbecSDK.so rename to orbbec_camera/SDK/x64/lib/libOrbbecSDK.so diff --git a/orbbec_camera/SDK/lib/x64/libOrbbecSDK.so.2 b/orbbec_camera/SDK/x64/lib/libOrbbecSDK.so.2 similarity index 100% rename from orbbec_camera/SDK/lib/x64/libOrbbecSDK.so.2 rename to orbbec_camera/SDK/x64/lib/libOrbbecSDK.so.2 diff --git a/orbbec_camera/SDK/lib/x64/libOrbbecSDK.so.2.9.3 b/orbbec_camera/SDK/x64/lib/libOrbbecSDK.so.2.9.3 similarity index 100% rename from orbbec_camera/SDK/lib/x64/libOrbbecSDK.so.2.9.3 rename to orbbec_camera/SDK/x64/lib/libOrbbecSDK.so.2.9.3