From 1469a0a121bba546624cc0b07015d7e46875170d Mon Sep 17 00:00:00 2001 From: ob-yalian Date: Wed, 22 Jul 2026 14:45:13 +0800 Subject: [PATCH 01/48] fix: improve LDP configuration error handling in setupDevices --- orbbec_camera/src/ob_camera_node.cpp | 39 ++++++++++++++++------------ 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index d54bfec8..615941db 100644 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -1104,24 +1104,31 @@ void OBCameraNode::setupDevices() { << disparity_to_depth_mode_ << "', keeping default settings"); } } - if (should_apply_launch_config("enable_ldp") && - device_->isPropertySupported(OB_PROP_LDP_BOOL, OB_PERMISSION_READ_WRITE)) { - if (device_->isPropertySupported(OB_PROP_LASER_CONTROL_INT, OB_PERMISSION_READ_WRITE)) { - auto laser_enable = device_->getIntProperty(OB_PROP_LASER_CONTROL_INT); - TRY_TO_SET_PROPERTY(setBoolProperty, OB_PROP_LDP_BOOL, enable_ldp_); - TRY_TO_SET_PROPERTY(setIntProperty, OB_PROP_LASER_CONTROL_INT, laser_enable); - } else if (device_->isPropertySupported(OB_PROP_LASER_BOOL, OB_PERMISSION_READ_WRITE)) { - if (!enable_ldp_) { - auto laser_enable = device_->getIntProperty(OB_PROP_LASER_BOOL); - TRY_TO_SET_PROPERTY(setBoolProperty, OB_PROP_LDP_BOOL, enable_ldp_); - std::this_thread::sleep_for(std::chrono::milliseconds(3)); - TRY_TO_SET_PROPERTY(setIntProperty, OB_PROP_LASER_BOOL, laser_enable); - } else { - TRY_TO_SET_PROPERTY(setBoolProperty, OB_PROP_LDP_BOOL, enable_ldp_); + try { + if (should_apply_launch_config("enable_ldp") && + device_->isPropertySupported(OB_PROP_LDP_BOOL, OB_PERMISSION_READ_WRITE)) { + if (device_->isPropertySupported(OB_PROP_LASER_CONTROL_INT, OB_PERMISSION_READ_WRITE)) { + auto laser_enable = device_->getIntProperty(OB_PROP_LASER_CONTROL_INT); + device_->setBoolProperty(OB_PROP_LDP_BOOL, enable_ldp_); + device_->setIntProperty(OB_PROP_LASER_CONTROL_INT, laser_enable); + } else if (device_->isPropertySupported(OB_PROP_LASER_BOOL, OB_PERMISSION_READ_WRITE)) { + if (!enable_ldp_) { + auto laser_enable = device_->getIntProperty(OB_PROP_LASER_BOOL); + device_->setBoolProperty(OB_PROP_LDP_BOOL, enable_ldp_); + std::this_thread::sleep_for(std::chrono::milliseconds(3)); + device_->setIntProperty(OB_PROP_LASER_BOOL, laser_enable); + } else { + device_->setBoolProperty(OB_PROP_LDP_BOOL, enable_ldp_); + } } + RCLCPP_INFO_STREAM( + logger_, "Current LDP: " << (device_->getBoolProperty(OB_PROP_LDP_BOOL) ? "ON" : "OFF")); } - RCLCPP_INFO_STREAM( - logger_, "Current LDP: " << (device_->getBoolProperty(OB_PROP_LDP_BOOL) ? "ON" : "OFF")); + } catch (const ob::Error &e) { + RCLCPP_WARN_STREAM(logger_, + "Skipping LDP configuration: " << orbbec_camera::formatObErrorWithStatus(e)); + } catch (const std::exception &e) { + RCLCPP_WARN_STREAM(logger_, "Skipping LDP configuration: " << e.what()); } if (ldp_power_level_ != -1 && device_->isPropertySupported(OB_PROP_LASER_POWER_LEVEL_CONTROL_INT, OB_PERMISSION_WRITE)) { From a157ad20ee538bd18e8672c19c34584528504c57 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Tue, 26 May 2026 11:14:39 +0200 Subject: [PATCH 02/48] colcon workflow --- .github/workflows/colcon.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/colcon.yml diff --git a/.github/workflows/colcon.yml b/.github/workflows/colcon.yml new file mode 100644 index 00000000..ad1f1d18 --- /dev/null +++ b/.github/workflows/colcon.yml @@ -0,0 +1,28 @@ +name: colcon + +on: [push, pull_request] + +jobs: + # build on Ubuntu docker images + build: + name: "${{ matrix.image }} (${{ matrix.ros }})" + + runs-on: ubuntu-latest + + strategy: + matrix: + include: + - {image: "ubuntu:22.04", ros: humble} + - {image: "ubuntu:24.04", ros: jazzy} + + container: + image: ${{ matrix.image }} + + steps: + - uses: actions/checkout@v6 + + - uses: ros-tooling/setup-ros@v0.7 + + - uses: ros-tooling/action-ros-ci@v0.4 + with: + target-ros2-distro: ${{ matrix.ros }} From 842ab626712f62caf5c791f45384eed9aae627ce Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Tue, 26 May 2026 11:35:08 +0200 Subject: [PATCH 03/48] update CMake requirements to 3.22 --- orbbec_camera/CMakeLists.txt | 2 +- orbbec_camera_msgs/CMakeLists.txt | 2 +- orbbec_description/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/orbbec_camera/CMakeLists.txt b/orbbec_camera/CMakeLists.txt index 9bde88d9..e702fe84 100644 --- a/orbbec_camera/CMakeLists.txt +++ b/orbbec_camera/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.22) project(orbbec_camera) set(CMAKE_CXX_STANDARD 17) diff --git a/orbbec_camera_msgs/CMakeLists.txt b/orbbec_camera_msgs/CMakeLists.txt index 347f4ed7..fd229bb6 100644 --- a/orbbec_camera_msgs/CMakeLists.txt +++ b/orbbec_camera_msgs/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.22) project(orbbec_camera_msgs) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") diff --git a/orbbec_description/CMakeLists.txt b/orbbec_description/CMakeLists.txt index 7fd8a452..8310ce57 100644 --- a/orbbec_description/CMakeLists.txt +++ b/orbbec_description/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.22) project(orbbec_description) find_package(ament_cmake REQUIRED) From 7b34a8d9523cc93641a9939a5c9574c0301c6e10 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Tue, 26 May 2026 13:29:15 +0200 Subject: [PATCH 04/48] add 'lyrical' to CI --- .github/workflows/colcon.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/colcon.yml b/.github/workflows/colcon.yml index ad1f1d18..c8afe194 100644 --- a/.github/workflows/colcon.yml +++ b/.github/workflows/colcon.yml @@ -14,6 +14,7 @@ jobs: include: - {image: "ubuntu:22.04", ros: humble} - {image: "ubuntu:24.04", ros: jazzy} + - {image: "ubuntu:26.04", ros: lyrical} container: image: ${{ matrix.image }} From c5f744869b1d60377949658d63c72d13537acd80 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Fri, 24 Jul 2026 10:15:37 +0200 Subject: [PATCH 05/48] update deprecated header --- .../multi_camera_time_sync/image_sync_example_node.cpp | 6 +++--- orbbec_camera/include/orbbec_camera/d2c_viewer.h | 8 ++++---- orbbec_camera/include/orbbec_camera/ob_camera_node.h | 10 +++++----- orbbec_camera/include/orbbec_camera/ob_lidar_node.h | 10 +++++----- orbbec_camera/include/orbbec_camera/utils.h | 2 +- orbbec_camera/tools/multi_save_rgbir.cpp | 6 +++--- orbbec_camera/tools/ob_benchmark.cpp | 6 +++--- orbbec_camera/tools/start_benchmark.cpp | 6 +++--- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp b/orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp index b919592d..cc27f357 100644 --- a/orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp +++ b/orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #include #include diff --git a/orbbec_camera/include/orbbec_camera/d2c_viewer.h b/orbbec_camera/include/orbbec_camera/d2c_viewer.h index 8912e113..1bb366a2 100644 --- a/orbbec_camera/include/orbbec_camera/d2c_viewer.h +++ b/orbbec_camera/include/orbbec_camera/d2c_viewer.h @@ -14,10 +14,10 @@ * limitations under the License. *******************************************************************************/ #pragma once -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/orbbec_camera/include/orbbec_camera/ob_camera_node.h b/orbbec_camera/include/orbbec_camera/ob_camera_node.h index 366b65d9..68a3c319 100644 --- a/orbbec_camera/include/orbbec_camera/ob_camera_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_camera_node.h @@ -31,11 +31,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/orbbec_camera/include/orbbec_camera/ob_lidar_node.h b/orbbec_camera/include/orbbec_camera/ob_lidar_node.h index 06da6341..93205155 100644 --- a/orbbec_camera/include/orbbec_camera/ob_lidar_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_lidar_node.h @@ -31,11 +31,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/orbbec_camera/include/orbbec_camera/utils.h b/orbbec_camera/include/orbbec_camera/utils.h index 51af52e7..b1b6da8d 100644 --- a/orbbec_camera/include/orbbec_camera/utils.h +++ b/orbbec_camera/include/orbbec_camera/utils.h @@ -17,7 +17,7 @@ #pragma once #include #include -#include +#include #include #include "libobsensor/ObSensor.hpp" diff --git a/orbbec_camera/tools/multi_save_rgbir.cpp b/orbbec_camera/tools/multi_save_rgbir.cpp index 5efa13be..6496787a 100644 --- a/orbbec_camera/tools/multi_save_rgbir.cpp +++ b/orbbec_camera/tools/multi_save_rgbir.cpp @@ -5,9 +5,9 @@ #include #include "orbbec_camera/ob_camera_node.h" #include "orbbec_camera_msgs/msg/metadata.hpp" -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/orbbec_camera/tools/ob_benchmark.cpp b/orbbec_camera/tools/ob_benchmark.cpp index afc514d0..52022503 100644 --- a/orbbec_camera/tools/ob_benchmark.cpp +++ b/orbbec_camera/tools/ob_benchmark.cpp @@ -3,9 +3,9 @@ #include #include #include "orbbec_camera_msgs/msg/metadata.hpp" -#include -#include -#include +#include +#include +#include #include namespace orbbec_camera { diff --git a/orbbec_camera/tools/start_benchmark.cpp b/orbbec_camera/tools/start_benchmark.cpp index 7295c205..9b474080 100644 --- a/orbbec_camera/tools/start_benchmark.cpp +++ b/orbbec_camera/tools/start_benchmark.cpp @@ -3,9 +3,9 @@ #include #include #include "orbbec_camera_msgs/msg/metadata.hpp" -#include -#include -#include +#include +#include +#include #include namespace orbbec_camera { From e01836930480db44110a0daee8540ffcbca04a14 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Wed, 27 May 2026 13:32:34 +0200 Subject: [PATCH 06/48] ignore 'deprecated-declarations' --- orbbec_camera/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/orbbec_camera/CMakeLists.txt b/orbbec_camera/CMakeLists.txt index e702fe84..e1bf8b7d 100644 --- a/orbbec_camera/CMakeLists.txt +++ b/orbbec_camera/CMakeLists.txt @@ -13,6 +13,7 @@ option(INSTALL_UDEV_RULES "Install udev rule for Orbbec cameras" ON) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Werror -Wno-pedantic -Wno-array-bounds) + add_compile_options(-Wno-error=deprecated-declarations) endif() # find dependencies From 75636938cc1b2fc3c0f31c744c8c978d881f95d0 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Fri, 24 Jul 2026 10:18:42 +0200 Subject: [PATCH 07/48] use newer 'message_filters::Subscriber' constructor API --- orbbec_camera/CMakeLists.txt | 4 ++++ .../image_sync_example_node.cpp | 8 +++++++- orbbec_camera/src/d2c_viewer.cpp | 16 ++++++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) mode change 100644 => 100755 orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp diff --git a/orbbec_camera/CMakeLists.txt b/orbbec_camera/CMakeLists.txt index e1bf8b7d..f497f989 100644 --- a/orbbec_camera/CMakeLists.txt +++ b/orbbec_camera/CMakeLists.txt @@ -53,6 +53,10 @@ endforeach() find_package(PkgConfig REQUIRED) find_package(OpenSSL REQUIRED) +if(message_filters_VERSION VERSION_GREATER_EQUAL 5.0) + add_compile_definitions(message_filters_QoS) +endif() + if(USE_RK_HW_DECODER) pkg_search_module(RK_MPP REQUIRED rockchip_mpp) if(NOT RK_MPP_FOUND) diff --git a/orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp b/orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp old mode 100644 new mode 100755 index cc27f357..aa8e838c --- a/orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp +++ b/orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp @@ -79,13 +79,19 @@ class ImageSyncNode : public rclcpp::Node { rclcpp::QoS qos{rclcpp::KeepLast(queue_size_)}; qos.reliable(); +#ifdef message_filters_QoS + const rclcpp::QoS qos_prof = qos; +#else + const rmw_qos_profile_t qos_prof = qos.get_rmw_qos_profile(); +#endif + if (sync_topics_.size() == 1) { single_sub_ = this->create_subscription( sync_topics_.front(), qos, [this](const ImageConstPtr msg) { this->handle_synced_images({msg}); }); } else { for (size_t i = 0; i < sync_topics_.size(); ++i) { - subscribers_[i].subscribe(this, sync_topics_[i], qos.get_rmw_qos_profile()); + subscribers_[i].subscribe(this, sync_topics_[i], qos_prof); } create_synchronizer(); } diff --git a/orbbec_camera/src/d2c_viewer.cpp b/orbbec_camera/src/d2c_viewer.cpp index d8a52802..0637f3f5 100644 --- a/orbbec_camera/src/d2c_viewer.cpp +++ b/orbbec_camera/src/d2c_viewer.cpp @@ -30,9 +30,21 @@ D2CViewer::D2CViewer(rclcpp::Node* const node, rmw_qos_profile_t rgb_qos, rmw_qos_profile_t depth_qos, bool use_intra_process) : node_(node), logger_(rclcpp::get_logger("d2c_viewer")), is_active_(true) { rgb_sub_ = std::make_shared>( - node_, "color/image_raw", rgb_qos); + node_, "color/image_raw", +#ifdef message_filters_QoS + rclcpp::QoS{rclcpp::QoSInitialization::from_rmw(rgb_qos), rgb_qos} +#else + rgb_qos +#endif + ); depth_sub_ = std::make_shared>( - node_, "depth/image_raw", depth_qos); + node_, "depth/image_raw", +#ifdef message_filters_QoS + rclcpp::QoS{rclcpp::QoSInitialization::from_rmw(depth_qos), depth_qos} +#else + depth_qos +#endif + ); sync_ = std::make_shared>(MySyncPolicy(10), *rgb_sub_, *depth_sub_); sync_->setMaxIntervalDuration(rclcpp::Duration::from_seconds(1.0)); // 1s From 4fa2c29fb20ac5af4165ad6d51a864b33bcfaf70 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Wed, 27 May 2026 13:08:33 +0200 Subject: [PATCH 08/48] update 'create_publisher' API --- orbbec_camera/CMakeLists.txt | 8 ++++++++ orbbec_camera/src/image_publisher.cpp | 14 +++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/orbbec_camera/CMakeLists.txt b/orbbec_camera/CMakeLists.txt index f497f989..79ef7880 100644 --- a/orbbec_camera/CMakeLists.txt +++ b/orbbec_camera/CMakeLists.txt @@ -57,6 +57,14 @@ if(message_filters_VERSION VERSION_GREATER_EQUAL 5.0) add_compile_definitions(message_filters_QoS) endif() +if(image_transport_VERSION VERSION_GREATER_EQUAL 6.4) + add_compile_definitions(image_transport_NODE_INTERFACE) +endif() + +if(image_transport_VERSION VERSION_GREATER_EQUAL 6.4) + add_compile_definitions(image_transport_QoS) +endif() + if(USE_RK_HW_DECODER) pkg_search_module(RK_MPP REQUIRED rockchip_mpp) if(NOT RK_MPP_FOUND) diff --git a/orbbec_camera/src/image_publisher.cpp b/orbbec_camera/src/image_publisher.cpp index a68d1513..7283cb8d 100644 --- a/orbbec_camera/src/image_publisher.cpp +++ b/orbbec_camera/src/image_publisher.cpp @@ -36,7 +36,19 @@ image_transport_publisher::image_transport_publisher(rclcpp::Node& node, const std::string& topic_name, const rmw_qos_profile_t& qos) { image_publisher_impl = std::make_shared( - image_transport::create_publisher(&node, topic_name, qos)); + image_transport::create_publisher( +#ifdef image_transport_NODE_INTERFACE + image_transport::RequiredInterfaces{node}, +#else + &node, +#endif + topic_name, +#ifdef image_transport_QoS + rclcpp::QoS{rclcpp::QoSInitialization::from_rmw(qos), qos} +#else + qos +#endif + )); } void image_transport_publisher::publish(sensor_msgs::msg::Image::UniquePtr image_ptr) { image_publisher_impl->publish(*image_ptr); From 9837dfb024dbb74a86c59265d8060594c0624d17 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Wed, 27 May 2026 16:34:38 +0200 Subject: [PATCH 09/48] remove unused header --- orbbec_camera/include/orbbec_camera/ob_camera_node.h | 1 - orbbec_camera/include/orbbec_camera/ob_lidar_node.h | 2 -- 2 files changed, 3 deletions(-) diff --git a/orbbec_camera/include/orbbec_camera/ob_camera_node.h b/orbbec_camera/include/orbbec_camera/ob_camera_node.h index 68a3c319..a665be23 100644 --- a/orbbec_camera/include/orbbec_camera/ob_camera_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_camera_node.h @@ -52,7 +52,6 @@ #include "libobsensor/ObSensor.hpp" #include "orbbec_camera_msgs/msg/device_info.hpp" -#include "orbbec_camera_msgs/msg/depth_filter_param.hpp" #include "orbbec_camera_msgs/msg/depth_filter_state.hpp" #include "orbbec_camera_msgs/msg/depth_filters_status.hpp" #include "orbbec_camera_msgs/srv/get_device_config.hpp" diff --git a/orbbec_camera/include/orbbec_camera/ob_lidar_node.h b/orbbec_camera/include/orbbec_camera/ob_lidar_node.h index 93205155..80115989 100644 --- a/orbbec_camera/include/orbbec_camera/ob_lidar_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_lidar_node.h @@ -48,10 +48,8 @@ #include #include "libobsensor/ObSensor.hpp" -#include "orbbec_camera_msgs/msg/device_info.hpp" #include "orbbec_camera_msgs/srv/get_device_info.hpp" #include "orbbec_camera_msgs/msg/extrinsics.hpp" -#include "orbbec_camera_msgs/msg/metadata.hpp" #include "orbbec_camera_msgs/msg/imu_info.hpp" #include "orbbec_camera_msgs/srv/get_int32.hpp" #include "orbbec_camera_msgs/srv/get_string.hpp" From 217f4abee4d8564727af0724472dfced559c6702 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Thu, 28 May 2026 11:29:47 +0200 Subject: [PATCH 10/48] require 'orbbec_camera_msgs' at version 2.8.6 or later --- orbbec_camera/package.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orbbec_camera/package.xml b/orbbec_camera/package.xml index b38780e1..b0899b76 100644 --- a/orbbec_camera/package.xml +++ b/orbbec_camera/package.xml @@ -17,7 +17,7 @@ rclcpp_components cv_bridge camera_info_manager - orbbec_camera_msgs + orbbec_camera_msgs builtin_interfaces rclcpp sensor_msgs From 293cd7bbb0c32a8087578ed3ed272ceaab1bb79e Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Wed, 10 Jun 2026 14:24:22 +0200 Subject: [PATCH 11/48] enable 'relro', 'now', and 'defs' to ensure that all symbols are resolved --- orbbec_camera/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/orbbec_camera/CMakeLists.txt b/orbbec_camera/CMakeLists.txt index 79ef7880..907c8a5c 100644 --- a/orbbec_camera/CMakeLists.txt +++ b/orbbec_camera/CMakeLists.txt @@ -14,6 +14,7 @@ option(INSTALL_UDEV_RULES "Install udev rule for Orbbec cameras" ON) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Werror -Wno-pedantic -Wno-array-bounds) add_compile_options(-Wno-error=deprecated-declarations) + add_link_options("-Wl,-z,relro,-z,now,-z,defs") endif() # find dependencies From 8d34a65f8201bb6a6ecca4c3f7995687e4792c73 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Tue, 26 May 2026 13:04:39 +0200 Subject: [PATCH 12/48] replace 'ament_target_dependencies' macro --- orbbec_camera/CMakeLists.txt | 110 ++++++++++++++++++++++++----------- 1 file changed, 76 insertions(+), 34 deletions(-) diff --git a/orbbec_camera/CMakeLists.txt b/orbbec_camera/CMakeLists.txt index 907c8a5c..15fc98b6 100644 --- a/orbbec_camera/CMakeLists.txt +++ b/orbbec_camera/CMakeLists.txt @@ -114,26 +114,8 @@ set(COMMON_INCLUDE_DIRS $ ${ORBBEC_INCLUDE_DIR} ${OpenCV_INCLUDED_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/tools ) -set(COMMON_LIBRARIES - ${ORBBEC_SDK_LIBRARIES} - ${OpenCV_LIBS} - Eigen3::Eigen - -lOrbbecSDK - -L${ORBBEC_LIBS_DIR} - Threads::Threads - -lrt - -ldw - yaml-cpp - OpenSSL::Crypto +set(EXTRA_TARGETS ) -if(USE_RK_HW_DECODER) - list(APPEND COMMON_LIBRARIES ${RK_MPP_LIBRARIES} ${RGA_LIBRARIES}) - -endif() - -if(USE_NV_HW_DECODER) - list(APPEND COMMON_LIBRARIES ${NV_LIBRARIES}) -endif() set(SOURCE_FILES src/d2c_viewer.cpp @@ -154,15 +136,16 @@ if(USE_RK_HW_DECODER) add_definitions(-DUSE_RK_HW_DECODER) list(APPEND SOURCE_FILES src/rk_mpp_decoder.cpp) list(APPEND COMMON_INCLUDE_DIRS ${RK_MPP_INCLUDE_DIRS} ${RGA_INCLUDE_DIRS}) - list(APPEND COMMON_LIBRARIES ${RGA_LIBRARIES} ${RK_MPP_LIBRARIES}) + list(APPEND EXTRA_TARGETS ${RGA_LIBRARIES} ${RK_MPP_LIBRARIES}) if(NOT RGA_FOUND) - list(APPEND COMMON_LIBRARIES -lyuv) + list(APPEND EXTRA_TARGETS yuv) endif() endif() if(USE_NV_HW_DECODER) list(APPEND SOURCE_FILES src/jetson_nv_decoder.cpp) list(APPEND COMMON_INCLUDE_DIRS ${JETSON_MULTI_MEDIA_API_INCLUDE_DIR} ${LIBJPEG8B_INCLUDE_DIR}) + list(APPEND EXTRA_TARGETS ${NV_LIBRARIES}) # append jetson_multimedia_api source files list( APPEND @@ -185,16 +168,42 @@ endif() macro(add_orbbec_executable TARGET SOURCE) add_executable(${TARGET} ${SOURCE}) target_include_directories(${TARGET} PUBLIC ${COMMON_INCLUDE_DIRS}) - target_link_libraries(${TARGET} ${COMMON_LIBRARIES} ${PROJECT_NAME}) - ament_target_dependencies(${TARGET} ${dependencies}) + target_link_directories(${TARGET} PRIVATE + ${ORBBEC_LIBS_DIR} + ) + target_link_libraries(${TARGET} + ${OpenCV_LIBS} + ${PROJECT_NAME} + OrbbecSDK + yaml-cpp + ) endmacro() # Define library and nodes add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES}) -ament_target_dependencies(${PROJECT_NAME} ${dependencies}) -target_include_directories(${PROJECT_NAME} PUBLIC ${COMMON_INCLUDE_DIRS}) -target_link_libraries(${PROJECT_NAME} ${COMMON_LIBRARIES}) +target_include_directories(${PROJECT_NAME} PUBLIC ${COMMON_INCLUDE_DIRS} ${image_publisher_INCLUDE_DIRS}) +target_link_directories(${PROJECT_NAME} PRIVATE ${ORBBEC_LIBS_DIR}) +target_link_libraries(${PROJECT_NAME} + ${OpenCV_LIBS} + ${orbbec_camera_msgs_TARGETS} + ${sensor_msgs_TARGETS} + ${std_srvs_TARGETS} + ament_index_cpp::ament_index_cpp + camera_info_manager::camera_info_manager + cv_bridge::cv_bridge + diagnostic_updater::diagnostic_updater + Eigen3::Eigen + image_transport::image_transport + message_filters::message_filters + OpenSSL::Crypto + OrbbecSDK + rclcpp::rclcpp + rclcpp_components::component + tf2::tf2 + tf2_ros::tf2_ros + ${EXTRA_TARGETS} +) rclcpp_components_register_node( ${PROJECT_NAME} PLUGIN "orbbec_camera::OBCameraNodeDriver" EXECUTABLE orbbec_camera_node @@ -221,24 +230,57 @@ install( add_library(frame_latency SHARED tools/frame_latency.cpp) target_include_directories(frame_latency PUBLIC ${COMMON_INCLUDE_DIRS}) -target_link_libraries(frame_latency ${COMMON_LIBRARIES}) -ament_target_dependencies(frame_latency ${dependencies}) +target_link_libraries(frame_latency + ${orbbec_camera_msgs_TARGETS} + ${sensor_msgs_TARGETS} + ${tf2_msgs_TARGETS} + diagnostic_updater::diagnostic_updater + rclcpp::rclcpp + rclcpp_components::component +) rclcpp_components_register_node(frame_latency PLUGIN "orbbec_camera::FrameLatencyNode" EXECUTABLE frame_latency_node) add_library(start_benchmark SHARED tools/start_benchmark.cpp) -target_include_directories(start_benchmark PUBLIC ${COMMON_INCLUDE_DIRS}) -target_link_libraries(start_benchmark ${COMMON_LIBRARIES}) -ament_target_dependencies(start_benchmark ${dependencies}) +target_include_directories(start_benchmark PUBLIC ${COMMON_INCLUDE_DIRS} ${image_publisher_INCLUDE_DIRS}) +target_link_libraries(start_benchmark + ${OpenCV_LIBS} + ${orbbec_camera_msgs_TARGETS} + ${sensor_msgs_TARGETS} + ${std_srvs_TARGETS} + camera_info_manager::camera_info_manager + diagnostic_updater::diagnostic_updater + Eigen3::Eigen + image_transport::image_transport + rclcpp::rclcpp + rclcpp_components::component + tf2_ros::tf2_ros +) rclcpp_components_register_node( start_benchmark PLUGIN "orbbec_camera::tools::StartBenchmark" EXECUTABLE start_benchmark_node ) add_library(multi_save_rgbir SHARED tools/multi_save_rgbir.cpp src/utils.cpp) -target_include_directories(multi_save_rgbir PUBLIC ${COMMON_INCLUDE_DIRS}) -target_link_libraries(multi_save_rgbir ${COMMON_LIBRARIES}) -ament_target_dependencies(multi_save_rgbir ${dependencies}) +target_include_directories(multi_save_rgbir PUBLIC ${COMMON_INCLUDE_DIRS} ${image_publisher_INCLUDE_DIRS}) +target_link_directories(multi_save_rgbir PRIVATE ${ORBBEC_LIBS_DIR}) +target_link_libraries(multi_save_rgbir + ${OpenCV_LIBS} + ${orbbec_camera_msgs_TARGETS} + ${sensor_msgs_TARGETS} + ${std_srvs_TARGETS} + camera_info_manager::camera_info_manager + cv_bridge::cv_bridge + diagnostic_updater::diagnostic_updater + Eigen3::Eigen + image_transport::image_transport + OpenSSL::Crypto + OrbbecSDK + rclcpp::rclcpp + rclcpp_components::component + tf2::tf2 + tf2_ros::tf2_ros +) rclcpp_components_register_node( multi_save_rgbir PLUGIN "orbbec_camera::tools::MultiCameraSubscriber" EXECUTABLE multi_save_rgbir_node From b34de79e0d71dac36f6ad6e82fe98938e2f1a034 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Mon, 29 Jun 2026 09:54:43 +0200 Subject: [PATCH 13/48] add 'message_filters' to list of dependencies --- orbbec_camera/CMakeLists.txt | 1 + orbbec_camera/package.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/orbbec_camera/CMakeLists.txt b/orbbec_camera/CMakeLists.txt index 15fc98b6..3386c741 100644 --- a/orbbec_camera/CMakeLists.txt +++ b/orbbec_camera/CMakeLists.txt @@ -28,6 +28,7 @@ set(dependencies camera_info_manager image_transport image_publisher + message_filters OpenCV orbbec_camera_msgs rclcpp diff --git a/orbbec_camera/package.xml b/orbbec_camera/package.xml index b0899b76..8cf3d733 100644 --- a/orbbec_camera/package.xml +++ b/orbbec_camera/package.xml @@ -14,6 +14,7 @@ backward_ros image_transport image_publisher + message_filters rclcpp_components cv_bridge camera_info_manager From 55ded4ec2e81705d7ae10969286baf859ea81097 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Tue, 7 Jul 2026 08:34:22 +0200 Subject: [PATCH 14/48] remove references to 'foxy' from documentation --- .github/ISSUE_TEMPLATE/issue_template.md | 4 ++-- README.MD | 5 +---- README_CN.MD | 5 +---- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/issue_template.md b/.github/ISSUE_TEMPLATE/issue_template.md index 028465ee..c67fc88f 100644 --- a/.github/ISSUE_TEMPLATE/issue_template.md +++ b/.github/ISSUE_TEMPLATE/issue_template.md @@ -12,8 +12,8 @@ assignees: '' - CPU model (e.g., `13th Gen Intel® Core™ i7-13700 × 24`, `NVIDIA Jetson Orin`) - Memory size (e.g., `16GB`, `32GB`) - GPU model if available (e.g., `NVIDIA RTX 3060`, `Integrated GPU`) -- **Ubuntu Version**: Please provide the ubuntu version you are using (e.g., `ubuntu20.04`, `ubuntu22.04`, etc.) -- **ROS Version**: Please provide the version of ROS you are using (e.g., `ROS Noetic`, `ROS 2 Foxy`, etc.) +- **Ubuntu Version**: Please provide the ubuntu version you are using (e.g., `ubuntu22.04`, `ubuntu24.04`, etc.) +- **ROS Version**: Please provide the version of ROS you are using (e.g., `ROS 2 Humble`, etc.) - **Camera Model**: Please provide the model of camera you are using (e.g., `Femto Bolt`, `Gemini 335`, etc.) - **Firmware Version**: Please provide the firmware version you are using. - **Branch**: Please provide the branch you are using (e.g., `main`, `v2-main`) diff --git a/README.MD b/README.MD index 986b68e2..246d1109 100644 --- a/README.MD +++ b/README.MD @@ -12,9 +12,6 @@ - - ROS Foxy - ROS Humble @@ -41,7 +38,7 @@ ## Introduction The **OrbbecSDK ROS2 Wrapper** provides seamless integration of Orbbec cameras with the ROS 2 ecosystem. - It supports ROS2 **Foxy**, **Humble**, and **Jazzy** distributions. + It supports ROS2 **Humble**, **Jazzy**, and **Lyrical** distributions. - Default branch: **v2-main** - For legacy **OpenNI** devices: use the **main** branch diff --git a/README_CN.MD b/README_CN.MD index 3bfd3190..c2d661d9 100644 --- a/README_CN.MD +++ b/README_CN.MD @@ -12,9 +12,6 @@ - - ROS Foxy - ROS Humble @@ -40,7 +37,7 @@ ## 简介 -OrbbecSDK ROS2 Wrapper 提供 Orbbec 相机与 ROS 2 环境的无缝集成,支持 **ROS2 Foxy、Humble 和 Jazzy** 发行版。 +OrbbecSDK ROS2 Wrapper 提供 Orbbec 相机与 ROS 2 环境的无缝集成,支持 **ROS2 Humble 和 Jazzy** 发行版。 - 默认推荐使用 **v2-main** 分支。 - 对于旧的 **OpenNI** 设备(v2-main 不支持),请使用 **main** 分支。 From b7f967a24b456b68854301ddaffc3ce07d2b7a75 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Fri, 24 Jul 2026 10:19:39 +0200 Subject: [PATCH 15/48] move 'magic_enum.hpp' to source files where required --- orbbec_camera/include/orbbec_camera/ob_camera_node.h | 1 - orbbec_camera/include/orbbec_camera/ob_lidar_node.h | 1 - orbbec_camera/include/orbbec_camera/utils.h | 1 - orbbec_camera/src/ob_camera_node.cpp | 1 + orbbec_camera/src/ob_lidar_node.cpp | 1 + orbbec_camera/src/rk_mpp_decoder.cpp | 1 - 6 files changed, 2 insertions(+), 4 deletions(-) diff --git a/orbbec_camera/include/orbbec_camera/ob_camera_node.h b/orbbec_camera/include/orbbec_camera/ob_camera_node.h index a665be23..5562c6f6 100644 --- a/orbbec_camera/include/orbbec_camera/ob_camera_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_camera_node.h @@ -72,7 +72,6 @@ #include "orbbec_camera/constants.h" #include "orbbec_camera/dynamic_params.h" #include "orbbec_camera/d2c_viewer.h" -#include "magic_enum/magic_enum.hpp" #include "orbbec_camera/image_publisher.h" #include "orbbec_camera/fps_counter.hpp" #include "orbbec_camera/fps_delay_status.hpp" diff --git a/orbbec_camera/include/orbbec_camera/ob_lidar_node.h b/orbbec_camera/include/orbbec_camera/ob_lidar_node.h index 80115989..9f870638 100644 --- a/orbbec_camera/include/orbbec_camera/ob_lidar_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_lidar_node.h @@ -61,7 +61,6 @@ #include "orbbec_camera/constants.h" #include "orbbec_camera/dynamic_params.h" #include "orbbec_camera/d2c_viewer.h" -#include "magic_enum/magic_enum.hpp" #include "orbbec_camera/image_publisher.h" #include #include diff --git a/orbbec_camera/include/orbbec_camera/utils.h b/orbbec_camera/include/orbbec_camera/utils.h index b1b6da8d..84f94f41 100644 --- a/orbbec_camera/include/orbbec_camera/utils.h +++ b/orbbec_camera/include/orbbec_camera/utils.h @@ -24,7 +24,6 @@ #include "sensor_msgs/distortion_models.hpp" #include "sensor_msgs/msg/camera_info.hpp" #include "orbbec_camera_msgs/msg/extrinsics.hpp" -#include "magic_enum/magic_enum.hpp" #include #include #include diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index d54bfec8..4fc5726f 100644 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "orbbec_camera/utils.h" #include diff --git a/orbbec_camera/src/ob_lidar_node.cpp b/orbbec_camera/src/ob_lidar_node.cpp index 1fbb8257..0f3d2baa 100644 --- a/orbbec_camera/src/ob_lidar_node.cpp +++ b/orbbec_camera/src/ob_lidar_node.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "orbbec_camera/utils.h" #include diff --git a/orbbec_camera/src/rk_mpp_decoder.cpp b/orbbec_camera/src/rk_mpp_decoder.cpp index 353e149d..42bd2e86 100644 --- a/orbbec_camera/src/rk_mpp_decoder.cpp +++ b/orbbec_camera/src/rk_mpp_decoder.cpp @@ -16,7 +16,6 @@ #include "orbbec_camera/rk_mpp_decoder.h" #include -#include namespace orbbec_camera { From b7a1392bac9d9f5d02e8998cd663f91c1b5d4744 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Tue, 7 Jul 2026 11:35:58 +0200 Subject: [PATCH 16/48] only install the 'orbbec_camera' headers --- orbbec_camera/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orbbec_camera/CMakeLists.txt b/orbbec_camera/CMakeLists.txt index 3386c741..de2119b6 100644 --- a/orbbec_camera/CMakeLists.txt +++ b/orbbec_camera/CMakeLists.txt @@ -292,7 +292,7 @@ install(TARGETS ${PROJECT_NAME} frame_latency start_benchmark multi_save_rgbir A LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) -install(DIRECTORY include/ DESTINATION include) +install(DIRECTORY include/orbbec_camera DESTINATION include/orbbec_camera) install(DIRECTORY launch DESTINATION share/${PROJECT_NAME}/) install(DIRECTORY config DESTINATION share/${PROJECT_NAME}/) install(DIRECTORY examples DESTINATION share/${PROJECT_NAME}/) From 5c8051fb94163af5edf7571149a3cec312dec488 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Fri, 24 Jul 2026 10:40:26 +0200 Subject: [PATCH 17/48] remove unused 'this' capture --- orbbec_camera/src/ob_camera_node.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) mode change 100644 => 100755 orbbec_camera/src/ob_camera_node.cpp diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp old mode 100644 new mode 100755 index 4fc5726f..0f9ca2a4 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -452,8 +452,7 @@ void OBCameraNode::publishDepthFiltersStatus() { depth_filters_snapshot = depth_filter_list_; } - auto find_depth_filter = [&depth_filters_snapshot, - this](const std::string &filter_name) -> std::shared_ptr { + auto find_depth_filter = [&depth_filters_snapshot](const std::string &filter_name) -> std::shared_ptr { const auto normalized_name = normalizeDepthFilterName(filter_name); auto it = std::find_if(depth_filters_snapshot.begin(), depth_filters_snapshot.end(), [&normalized_name](const auto &filter) { From 10a40ce3145195944219f9c4624158000ebc1826 Mon Sep 17 00:00:00 2001 From: slz Date: Tue, 28 Jul 2026 21:06:41 +0800 Subject: [PATCH 18/48] feat: support multiple ROS 2 distributions --- .github/rosdep/orbbec-camera-msgs.yaml | 5 + .github/workflows/colcon.yml | 50 +++- .github/workflows/debian-packages.yml | 222 ++++++++++++++++++ README.MD | 13 +- README_CN.MD | 12 +- orbbec_camera/.make_deb.sh | 7 +- orbbec_camera/CMakeLists.txt | 125 +++++++--- .../camera_example_node.cpp | 6 +- .../image_sync_example_node.cpp | 15 +- .../include/orbbec_camera/d2c_viewer.h | 14 +- .../include/orbbec_camera/ob_camera_node.h | 25 +- .../include/orbbec_camera/ob_lidar_node.h | 25 +- orbbec_camera/include/orbbec_camera/utils.h | 8 +- orbbec_camera/package.xml | 19 +- orbbec_camera/src/d2c_viewer.cpp | 4 +- orbbec_camera/src/image_publisher.cpp | 12 +- orbbec_camera/src/ob_camera_node.cpp | 33 ++- orbbec_camera/src/ob_camera_node_driver.cpp | 37 ++- orbbec_camera/src/ob_lidar_node.cpp | 4 +- orbbec_camera/tools/multi_save_rgbir.cpp | 5 +- orbbec_camera/tools/ob_benchmark.cpp | 3 - orbbec_camera/tools/start_benchmark.cpp | 3 - orbbec_camera_msgs/CMakeLists.txt | 2 +- orbbec_description/CMakeLists.txt | 2 +- orbbec_description/package.xml | 7 + 25 files changed, 554 insertions(+), 104 deletions(-) create mode 100644 .github/rosdep/orbbec-camera-msgs.yaml create mode 100644 .github/workflows/debian-packages.yml diff --git a/.github/rosdep/orbbec-camera-msgs.yaml b/.github/rosdep/orbbec-camera-msgs.yaml new file mode 100644 index 00000000..97aa85ab --- /dev/null +++ b/.github/rosdep/orbbec-camera-msgs.yaml @@ -0,0 +1,5 @@ +orbbec_camera_msgs: + ubuntu: + jammy: [ros-humble-orbbec-camera-msgs] + noble: [ros-jazzy-orbbec-camera-msgs] + resolute: [ros-lyrical-orbbec-camera-msgs] diff --git a/.github/workflows/colcon.yml b/.github/workflows/colcon.yml index c8afe194..1beb8a77 100644 --- a/.github/workflows/colcon.yml +++ b/.github/workflows/colcon.yml @@ -1,20 +1,30 @@ -name: colcon +name: CI -on: [push, pull_request] +on: + push: + pull_request: + workflow_dispatch: + +permissions: read-all jobs: - # build on Ubuntu docker images build: - name: "${{ matrix.image }} (${{ matrix.ros }})" + name: "ROS2 ${{ matrix.ros }} (${{ matrix.os }})" - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.ros == 'rolling' }} + env: + ROS_DISTRO: ${{ matrix.ros }} strategy: + fail-fast: false matrix: include: - - {image: "ubuntu:22.04", ros: humble} - - {image: "ubuntu:24.04", ros: jazzy} - - {image: "ubuntu:26.04", ros: lyrical} + - {image: "ros:foxy-ros-core-focal", os: ubuntu-22.04, ros: foxy} + - {image: "ros:humble-ros-core-jammy", os: ubuntu-22.04, ros: humble} + - {image: "ros:jazzy-ros-core-noble", os: ubuntu-24.04, ros: jazzy} + - {image: "ros:lyrical-ros-core-resolute", os: ubuntu-26.04, ros: lyrical} + - {image: "ros:rolling-ros-core-resolute", os: ubuntu-26.04, ros: rolling} container: image: ${{ matrix.image }} @@ -22,8 +32,24 @@ jobs: steps: - uses: actions/checkout@v6 - - uses: ros-tooling/setup-ros@v0.7 + - name: Install build tools + shell: bash + run: | + set -euo pipefail + apt-get update + apt-get install --no-install-recommends --yes \ + build-essential \ + cmake \ + git \ + python3-colcon-common-extensions \ + python3-rosdep + rosdep init || true + rosdep update --rosdistro "${ROS_DISTRO}" --include-eol-distros - - uses: ros-tooling/action-ros-ci@v0.4 - with: - target-ros2-distro: ${{ matrix.ros }} + - name: Install dependencies and build + shell: bash + run: | + set -eo pipefail + source "/opt/ros/${ROS_DISTRO}/setup.bash" + rosdep install --from-paths . --ignore-src --rosdistro "${ROS_DISTRO}" -y + colcon build --symlink-install --event-handlers console_direct+ diff --git a/.github/workflows/debian-packages.yml b/.github/workflows/debian-packages.yml new file mode 100644 index 00000000..8acaa6e3 --- /dev/null +++ b/.github/workflows/debian-packages.yml @@ -0,0 +1,222 @@ +name: Build Debian packages + +on: + workflow_dispatch: + inputs: + ros_distro: + description: ROS 2 distribution to package + required: true + default: all + type: choice + options: + - all + - humble + - jazzy + - lyrical + architecture: + description: CPU architecture to package + required: true + default: all + type: choice + options: + - all + - amd64 + - arm64 + +permissions: + contents: read + +jobs: + prepare: + name: Prepare build matrix + runs-on: ubuntu-24.04 + outputs: + matrix: ${{ steps.matrix.outputs.matrix }} + + steps: + - name: Generate selected build matrix + id: matrix + shell: bash + env: + SELECTED_ROS_DISTRO: ${{ inputs.ros_distro }} + SELECTED_ARCHITECTURE: ${{ inputs.architecture }} + run: | + set -euo pipefail + + architectures=(amd64 arm64) + if [[ "${SELECTED_ARCHITECTURE}" != "all" ]]; then + architectures=("${SELECTED_ARCHITECTURE}") + fi + + entries=() + while IFS='|' read -r ros_distro ubuntu_codename ubuntu_version; do + if [[ "${SELECTED_ROS_DISTRO}" != "all" && + "${SELECTED_ROS_DISTRO}" != "${ros_distro}" ]]; then + continue + fi + + for architecture in "${architectures[@]}"; do + runner="ubuntu-${ubuntu_version}" + if [[ "${architecture}" == "arm64" ]]; then + runner="${runner}-arm" + fi + + printf -v entry \ + '{"ros":"%s","arch":"%s","runner":"%s","image":"ros:%s-ros-core-%s"}' \ + "${ros_distro}" \ + "${architecture}" \ + "${runner}" \ + "${ros_distro}" \ + "${ubuntu_codename}" + entries+=("${entry}") + done + done <<'EOF' + humble|jammy|22.04 + jazzy|noble|24.04 + lyrical|resolute|26.04 + EOF + + matrix=$(IFS=,; printf '{"include":[%s]}' "${entries[*]}") + echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}" + + build: + name: ROS 2 ${{ matrix.ros }} (${{ matrix.arch }}) + needs: prepare + runs-on: ${{ matrix.runner }} + container: + image: ${{ matrix.image }} + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }} + env: + DEBIAN_FRONTEND: noninteractive + ROS_DISTRO: ${{ matrix.ros }} + + steps: + - uses: actions/checkout@v6 + + - name: Install packaging tools and dependencies + shell: bash + run: | + set -euo pipefail + apt-get update + apt-get install --no-install-recommends --yes \ + build-essential \ + cmake \ + debhelper \ + fakeroot \ + git \ + python3-bloom \ + python3-rosdep + + rosdep init || true + + local_rosdep_dir="${RUNNER_TEMP}/orbbec-rosdep" + mkdir -p "${local_rosdep_dir}" + printf 'yaml file://%s/.github/rosdep/orbbec-camera-msgs.yaml\n' \ + "${GITHUB_WORKSPACE}" \ + > "${local_rosdep_dir}/10-orbbec-camera-msgs.list" + export ROSDEP_SOURCE_PATH="${local_rosdep_dir}:/etc/ros/rosdep/sources.list.d" + echo "ROSDEP_SOURCE_PATH=${ROSDEP_SOURCE_PATH}" >> "${GITHUB_ENV}" + + rosdep update --rosdistro "${ROS_DISTRO}" + + set +u + source "/opt/ros/${ROS_DISTRO}/setup.bash" + set -u + rosdep install \ + --from-paths orbbec_camera_msgs orbbec_camera \ + --ignore-src \ + --rosdistro "${ROS_DISTRO}" \ + -y + + - name: Build and install message package + shell: bash + run: | + set -euo pipefail + set +u + source "/opt/ros/${ROS_DISTRO}/setup.bash" + set -u + + ( + cd orbbec_camera_msgs + bash .make_deb.sh + ) + + mapfile -t message_packages < <( + find . -maxdepth 1 -type f \ + -name "ros-${ROS_DISTRO}-orbbec-camera-msgs_*.deb" \ + -print + ) + if [[ "${#message_packages[@]}" -ne 1 ]]; then + echo "Expected one orbbec_camera_msgs Debian package, found ${#message_packages[@]}" >&2 + exit 1 + fi + + apt-get install --yes "${message_packages[0]}" + + - name: Build camera package + shell: bash + run: | + set -euo pipefail + set +u + source "/opt/ros/${ROS_DISTRO}/setup.bash" + set -u + + ( + cd orbbec_camera + bash .make_deb.sh + ) + + - name: Validate and install generated packages + shell: bash + env: + EXPECTED_ARCHITECTURE: ${{ matrix.arch }} + run: | + set -euo pipefail + + mapfile -t camera_packages < <( + find . -maxdepth 1 -type f \ + -name "ros-${ROS_DISTRO}-orbbec-camera_*.deb" \ + -print + ) + if [[ "${#camera_packages[@]}" -ne 1 ]]; then + echo "Expected one orbbec_camera Debian package, found ${#camera_packages[@]}" >&2 + exit 1 + fi + + actual_architecture=$(dpkg --print-architecture) + if [[ "${actual_architecture}" != "${EXPECTED_ARCHITECTURE}" ]]; then + echo "Runner architecture ${actual_architecture} does not match ${EXPECTED_ARCHITECTURE}" >&2 + exit 1 + fi + + for package in ./*.deb ./*.ddeb; do + [[ -e "${package}" ]] || continue + package_architecture=$(dpkg-deb --field "${package}" Architecture) + if [[ "${package_architecture}" != "${EXPECTED_ARCHITECTURE}" && + "${package_architecture}" != "all" ]]; then + echo "Package ${package} has unexpected architecture ${package_architecture}" >&2 + exit 1 + fi + done + + apt-get install --yes "${camera_packages[0]}" + + - name: Collect packages + shell: bash + run: | + set -euo pipefail + mkdir -p artifacts + find . -maxdepth 1 -type f \ + \( -name '*.deb' -o -name '*.ddeb' \) \ + -exec cp --target-directory artifacts {} + + + - name: Upload Debian packages + uses: actions/upload-artifact@v7 + with: + name: orbbec-ros2-debs-${{ matrix.ros }}-${{ matrix.arch }} + path: artifacts/ + if-no-files-found: error + retention-days: 14 + compression-level: 0 diff --git a/README.MD b/README.MD index 246d1109..2e9c865e 100644 --- a/README.MD +++ b/README.MD @@ -12,15 +12,25 @@ + + ROS Foxy + ROS Humble ROS Jazzy + + ROS Lyrical + + + ROS Rolling (experimental) + Ubuntu 20.04 Ubuntu 22.04 Ubuntu 24.04 + Ubuntu 26.04
@@ -37,8 +47,7 @@ ## Introduction -The **OrbbecSDK ROS2 Wrapper** provides seamless integration of Orbbec cameras with the ROS 2 ecosystem. - It supports ROS2 **Humble**, **Jazzy**, and **Lyrical** distributions. +The **OrbbecSDK ROS2 Wrapper** provides seamless integration of Orbbec cameras with the ROS 2 ecosystem and supports the **ROS2 Foxy**, **Humble**, **Jazzy**, and **Lyrical** distributions, with experimental support for **Rolling**. - Default branch: **v2-main** - For legacy **OpenNI** devices: use the **main** branch diff --git a/README_CN.MD b/README_CN.MD index c2d661d9..04827a1f 100644 --- a/README_CN.MD +++ b/README_CN.MD @@ -12,15 +12,25 @@ + + ROS Foxy + ROS Humble ROS Jazzy + + ROS Lyrical + + + ROS Rolling (experimental) + Ubuntu 20.04 Ubuntu 22.04 Ubuntu 24.04 + Ubuntu 26.04
@@ -37,7 +47,7 @@ ## 简介 -OrbbecSDK ROS2 Wrapper 提供 Orbbec 相机与 ROS 2 环境的无缝集成,支持 **ROS2 Humble 和 Jazzy** 发行版。 +OrbbecSDK ROS2 Wrapper 提供 Orbbec 相机与 ROS 2 环境的无缝集成,支持 **ROS2 Foxy、Humble、Jazzy 和 Lyrical** 发行版,并提供对 **Rolling** 的实验性支持。 - 默认推荐使用 **v2-main** 分支。 - 对于旧的 **OpenNI** 设备(v2-main 不支持),请使用 **main** 分支。 diff --git a/orbbec_camera/.make_deb.sh b/orbbec_camera/.make_deb.sh index 1261a2b7..d84db41a 100644 --- a/orbbec_camera/.make_deb.sh +++ b/orbbec_camera/.make_deb.sh @@ -11,11 +11,14 @@ sed -i '/^override_dh_shlibdeps:/,/^$/d' debian/rules cat >> debian/rules << 'EOF' +ORBBEC_PACKAGE := ros-$(ROS_DISTRO)-orbbec-camera +ORBBEC_LIB_DIR := $(CURDIR)/debian/$(ORBBEC_PACKAGE)/opt/ros/$(ROS_DISTRO)/lib + override_dh_shlibdeps: - dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info + dh_shlibdeps -Xlibengine_infer_encry.so -l$(ORBBEC_LIB_DIR) -- --ignore-missing-info EOF PARALLEL=$(nproc) if [ "$PARALLEL" -gt 3 ]; then PARALLEL=3; fi export DEB_BUILD_OPTIONS="parallel=$PARALLEL" -fakeroot debian/rules binary \ No newline at end of file +fakeroot debian/rules binary diff --git a/orbbec_camera/CMakeLists.txt b/orbbec_camera/CMakeLists.txt index de2119b6..555112fe 100644 --- a/orbbec_camera/CMakeLists.txt +++ b/orbbec_camera/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.10) project(orbbec_camera) set(CMAKE_CXX_STANDARD 17) @@ -26,13 +26,16 @@ set(dependencies cv_bridge backward_ros camera_info_manager + geometry_msgs image_transport image_publisher message_filters OpenCV orbbec_camera_msgs + rcl_interfaces rclcpp rclcpp_components + rmw sensor_msgs std_msgs std_srvs @@ -55,18 +58,49 @@ endforeach() find_package(PkgConfig REQUIRED) find_package(OpenSSL REQUIRED) -if(message_filters_VERSION VERSION_GREATER_EQUAL 5.0) - add_compile_definitions(message_filters_QoS) +set(ORBBEC_MESSAGE_FILTERS_USES_RCLCPP_QOS OFF) +if(DEFINED message_filters_VERSION AND message_filters_VERSION VERSION_GREATER_EQUAL 5.0) + set(ORBBEC_MESSAGE_FILTERS_USES_RCLCPP_QOS ON) endif() -if(image_transport_VERSION VERSION_GREATER_EQUAL 6.4) - add_compile_definitions(image_transport_NODE_INTERFACE) +set(ORBBEC_IMAGE_TRANSPORT_USES_REQUIRED_INTERFACES OFF) +if(DEFINED image_transport_VERSION AND image_transport_VERSION VERSION_GREATER_EQUAL 6.4) + set(ORBBEC_IMAGE_TRANSPORT_USES_REQUIRED_INTERFACES ON) endif() -if(image_transport_VERSION VERSION_GREATER_EQUAL 6.4) - add_compile_definitions(image_transport_QoS) +set(ORBBEC_CAMERA_INFO_MANAGER_USES_NODE_INTERFACES OFF) +if(DEFINED camera_info_manager_VERSION AND + camera_info_manager_VERSION VERSION_GREATER_EQUAL 4.1.0) + set(ORBBEC_CAMERA_INFO_MANAGER_USES_NODE_INTERFACES ON) endif() +set(ORBBEC_CAMERA_INFO_MANAGER_USES_RCLCPP_QOS OFF) +if(DEFINED camera_info_manager_VERSION AND + camera_info_manager_VERSION VERSION_GREATER_EQUAL 7.0.0) + set(ORBBEC_CAMERA_INFO_MANAGER_USES_RCLCPP_QOS ON) +endif() + +function(orbbec_target_dependencies target) + if(COMMAND ament_target_dependencies) + ament_target_dependencies(${target} ${ARGN}) + return() + endif() + + set(dependency_targets) + foreach(dependency IN LISTS ARGN) + if(dependency STREQUAL "rclcpp_components") + list(APPEND dependency_targets rclcpp_components::component) + elseif(dependency STREQUAL "sensor_msgs") + list(APPEND dependency_targets sensor_msgs::sensor_msgs_library) + elseif(TARGET "${dependency}::${dependency}") + list(APPEND dependency_targets "${dependency}::${dependency}") + else() + message(FATAL_ERROR "No CMake target exported by ${dependency}") + endif() + endforeach() + target_link_libraries(${target} ${dependency_targets}) +endfunction() + if(USE_RK_HW_DECODER) pkg_search_module(RK_MPP REQUIRED rockchip_mpp) if(NOT RK_MPP_FOUND) @@ -112,7 +146,7 @@ endif() set(COMMON_INCLUDE_DIRS $ $ - $ ${ORBBEC_INCLUDE_DIR} ${OpenCV_INCLUDED_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/tools + $ ${ORBBEC_INCLUDE_DIR} ${OpenCV_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/tools ) set(EXTRA_TARGETS @@ -182,29 +216,51 @@ endmacro() # Define library and nodes add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES}) +if(ORBBEC_MESSAGE_FILTERS_USES_RCLCPP_QOS) + target_compile_definitions(${PROJECT_NAME} PRIVATE ORBBEC_MESSAGE_FILTERS_USES_RCLCPP_QOS) +endif() +if(ORBBEC_IMAGE_TRANSPORT_USES_REQUIRED_INTERFACES) + target_compile_definitions(${PROJECT_NAME} PRIVATE ORBBEC_IMAGE_TRANSPORT_USES_REQUIRED_INTERFACES) +endif() +if(ORBBEC_CAMERA_INFO_MANAGER_USES_NODE_INTERFACES) + target_compile_definitions(${PROJECT_NAME} + PRIVATE ORBBEC_CAMERA_INFO_MANAGER_USES_NODE_INTERFACES) +endif() +if(ORBBEC_CAMERA_INFO_MANAGER_USES_RCLCPP_QOS) + target_compile_definitions(${PROJECT_NAME} + PRIVATE ORBBEC_CAMERA_INFO_MANAGER_USES_RCLCPP_QOS) +endif() target_include_directories(${PROJECT_NAME} PUBLIC ${COMMON_INCLUDE_DIRS} ${image_publisher_INCLUDE_DIRS}) target_link_directories(${PROJECT_NAME} PRIVATE ${ORBBEC_LIBS_DIR}) target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} ${orbbec_camera_msgs_TARGETS} - ${sensor_msgs_TARGETS} ${std_srvs_TARGETS} ament_index_cpp::ament_index_cpp - camera_info_manager::camera_info_manager - cv_bridge::cv_bridge - diagnostic_updater::diagnostic_updater Eigen3::Eigen - image_transport::image_transport - message_filters::message_filters OpenSSL::Crypto OrbbecSDK + Threads::Threads + ${BACKWARD_LIBRARIES} rclcpp::rclcpp - rclcpp_components::component + rt tf2::tf2 tf2_ros::tf2_ros ${EXTRA_TARGETS} ) +orbbec_target_dependencies(${PROJECT_NAME} + camera_info_manager + cv_bridge + diagnostic_updater + geometry_msgs + image_transport + message_filters + rcl_interfaces + rclcpp_components + rmw + sensor_msgs +) rclcpp_components_register_node( ${PROJECT_NAME} PLUGIN "orbbec_camera::OBCameraNodeDriver" EXECUTABLE orbbec_camera_node @@ -221,6 +277,10 @@ add_orbbec_executable(ob_benchmark_node tools/ob_benchmark.cpp) add_orbbec_executable(435le_example_node examples/Gemini_435Le_example_node/camera_example_node.cpp) add_orbbec_executable(service_benchmark_node scripts/service_benchmark_node.cpp) add_orbbec_executable(image_sync_example_node examples/multi_camera_time_sync/image_sync_example_node.cpp) +orbbec_target_dependencies(topic_statistics_node statistics_msgs) +if(ORBBEC_MESSAGE_FILTERS_USES_RCLCPP_QOS) + target_compile_definitions(image_sync_example_node PRIVATE ORBBEC_MESSAGE_FILTERS_USES_RCLCPP_QOS) +endif() install( PROGRAMS @@ -233,11 +293,14 @@ add_library(frame_latency SHARED tools/frame_latency.cpp) target_include_directories(frame_latency PUBLIC ${COMMON_INCLUDE_DIRS}) target_link_libraries(frame_latency ${orbbec_camera_msgs_TARGETS} - ${sensor_msgs_TARGETS} ${tf2_msgs_TARGETS} - diagnostic_updater::diagnostic_updater rclcpp::rclcpp - rclcpp_components::component +) +orbbec_target_dependencies(frame_latency + diagnostic_updater + geometry_msgs + rclcpp_components + sensor_msgs ) rclcpp_components_register_node(frame_latency PLUGIN "orbbec_camera::FrameLatencyNode" EXECUTABLE frame_latency_node) @@ -247,16 +310,18 @@ target_include_directories(start_benchmark PUBLIC ${COMMON_INCLUDE_DIRS} ${image target_link_libraries(start_benchmark ${OpenCV_LIBS} ${orbbec_camera_msgs_TARGETS} - ${sensor_msgs_TARGETS} ${std_srvs_TARGETS} - camera_info_manager::camera_info_manager - diagnostic_updater::diagnostic_updater Eigen3::Eigen - image_transport::image_transport rclcpp::rclcpp - rclcpp_components::component tf2_ros::tf2_ros ) +orbbec_target_dependencies(start_benchmark + camera_info_manager + diagnostic_updater + image_transport + rclcpp_components + sensor_msgs +) rclcpp_components_register_node( start_benchmark PLUGIN "orbbec_camera::tools::StartBenchmark" EXECUTABLE start_benchmark_node @@ -268,20 +333,22 @@ target_link_directories(multi_save_rgbir PRIVATE ${ORBBEC_LIBS_DIR}) target_link_libraries(multi_save_rgbir ${OpenCV_LIBS} ${orbbec_camera_msgs_TARGETS} - ${sensor_msgs_TARGETS} ${std_srvs_TARGETS} - camera_info_manager::camera_info_manager - cv_bridge::cv_bridge - diagnostic_updater::diagnostic_updater Eigen3::Eigen - image_transport::image_transport OpenSSL::Crypto OrbbecSDK rclcpp::rclcpp - rclcpp_components::component tf2::tf2 tf2_ros::tf2_ros ) +orbbec_target_dependencies(multi_save_rgbir + camera_info_manager + cv_bridge + diagnostic_updater + image_transport + rclcpp_components + sensor_msgs +) rclcpp_components_register_node( multi_save_rgbir PLUGIN "orbbec_camera::tools::MultiCameraSubscriber" EXECUTABLE multi_save_rgbir_node diff --git a/orbbec_camera/examples/Gemini_435Le_example_node/camera_example_node.cpp b/orbbec_camera/examples/Gemini_435Le_example_node/camera_example_node.cpp index 0a99ad6d..0986ae40 100644 --- a/orbbec_camera/examples/Gemini_435Le_example_node/camera_example_node.cpp +++ b/orbbec_camera/examples/Gemini_435Le_example_node/camera_example_node.cpp @@ -139,9 +139,9 @@ class CameraExampleNode : public rclcpp::Node { "/camera/device_status", 10, std::bind(&CameraExampleNode::deviceStatusCallback, this, std::placeholders::_1)); - while (rclcpp::ok()) { - rclcpp::spin_some(shared_from_this()); - } + rclcpp::executors::SingleThreadedExecutor executor; + executor.add_node(shared_from_this()); + executor.spin(); } // Feature 7: Set Color AE ROI diff --git a/orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp b/orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp index aa8e838c..48791ba7 100755 --- a/orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp +++ b/orbbec_camera/examples/multi_camera_time_sync/image_sync_example_node.cpp @@ -1,8 +1,17 @@ +#include +#include + +#if __has_include() #include #include #include -#include -#include +#elif __has_include() +#include +#include +#include +#else +#error "No compatible message_filters headers found" +#endif #if __has_include() #include @@ -79,7 +88,7 @@ class ImageSyncNode : public rclcpp::Node { rclcpp::QoS qos{rclcpp::KeepLast(queue_size_)}; qos.reliable(); -#ifdef message_filters_QoS +#ifdef ORBBEC_MESSAGE_FILTERS_USES_RCLCPP_QOS const rclcpp::QoS qos_prof = qos; #else const rmw_qos_profile_t qos_prof = qos.get_rmw_qos_profile(); diff --git a/orbbec_camera/include/orbbec_camera/d2c_viewer.h b/orbbec_camera/include/orbbec_camera/d2c_viewer.h index 1bb366a2..1c9f31d6 100644 --- a/orbbec_camera/include/orbbec_camera/d2c_viewer.h +++ b/orbbec_camera/include/orbbec_camera/d2c_viewer.h @@ -14,12 +14,20 @@ * limitations under the License. *******************************************************************************/ #pragma once +#include +#include + +#if __has_include() #include #include #include -#include -#include -#include +#elif __has_include() +#include +#include +#include +#else +#error "No compatible message_filters headers found" +#endif #include "utils.h" diff --git a/orbbec_camera/include/orbbec_camera/ob_camera_node.h b/orbbec_camera/include/orbbec_camera/ob_camera_node.h index 5562c6f6..f21ad31c 100644 --- a/orbbec_camera/include/orbbec_camera/ob_camera_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_camera_node.h @@ -31,11 +31,6 @@ #include #include #include -#include -#include -#include -#include -#include #include #include #include @@ -81,6 +76,26 @@ #include #include +#if __has_include() +#include +#include +#elif __has_include() +#include +#include +#else +#error "No compatible tf2 LinearMath headers found" +#endif + +#if __has_include() +#include +#include +#elif __has_include() +#include +#include +#else +#error "No compatible tf2_ros broadcaster headers found" +#endif + #if __has_include() #include #elif __has_include() diff --git a/orbbec_camera/include/orbbec_camera/ob_lidar_node.h b/orbbec_camera/include/orbbec_camera/ob_lidar_node.h index 9f870638..a843ae79 100644 --- a/orbbec_camera/include/orbbec_camera/ob_lidar_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_lidar_node.h @@ -31,11 +31,6 @@ #include #include #include -#include -#include -#include -#include -#include #include #include #include @@ -66,6 +61,26 @@ #include #include +#if __has_include() +#include +#include +#elif __has_include() +#include +#include +#else +#error "No compatible tf2 LinearMath headers found" +#endif + +#if __has_include() +#include +#include +#elif __has_include() +#include +#include +#else +#error "No compatible tf2_ros broadcaster headers found" +#endif + #if __has_include() #include #elif __has_include() diff --git a/orbbec_camera/include/orbbec_camera/utils.h b/orbbec_camera/include/orbbec_camera/utils.h index 84f94f41..1f6e6c89 100644 --- a/orbbec_camera/include/orbbec_camera/utils.h +++ b/orbbec_camera/include/orbbec_camera/utils.h @@ -17,13 +17,19 @@ #pragma once #include #include -#include #include #include "libobsensor/ObSensor.hpp" #include "sensor_msgs/distortion_models.hpp" #include "sensor_msgs/msg/camera_info.hpp" #include "orbbec_camera_msgs/msg/extrinsics.hpp" +#if __has_include() +#include +#elif __has_include() +#include +#else +#error "No compatible tf2 Quaternion header found" +#endif #include #include #include diff --git a/orbbec_camera/package.xml b/orbbec_camera/package.xml index 8cf3d733..790cf788 100644 --- a/orbbec_camera/package.xml +++ b/orbbec_camera/package.xml @@ -8,6 +8,8 @@ Apache-2.0 ament_cmake + pkg-config + ament_lint_auto ament_lint_common ament_index_cpp @@ -18,7 +20,7 @@ rclcpp_components cv_bridge camera_info_manager - orbbec_camera_msgs + orbbec_camera_msgs builtin_interfaces rclcpp sensor_msgs @@ -37,6 +39,21 @@ libssl-dev opengl + eigen + geometry_msgs + libopencv-dev + rcl_interfaces + rmw + yaml-cpp + + ament_index_python + launch + launch_ros + python3-psutil + python3-tabulate + python3-yaml + rclpy + ament_cmake diff --git a/orbbec_camera/src/d2c_viewer.cpp b/orbbec_camera/src/d2c_viewer.cpp index 0637f3f5..b6a4f166 100644 --- a/orbbec_camera/src/d2c_viewer.cpp +++ b/orbbec_camera/src/d2c_viewer.cpp @@ -31,7 +31,7 @@ D2CViewer::D2CViewer(rclcpp::Node* const node, rmw_qos_profile_t rgb_qos, : node_(node), logger_(rclcpp::get_logger("d2c_viewer")), is_active_(true) { rgb_sub_ = std::make_shared>( node_, "color/image_raw", -#ifdef message_filters_QoS +#ifdef ORBBEC_MESSAGE_FILTERS_USES_RCLCPP_QOS rclcpp::QoS{rclcpp::QoSInitialization::from_rmw(rgb_qos), rgb_qos} #else rgb_qos @@ -39,7 +39,7 @@ D2CViewer::D2CViewer(rclcpp::Node* const node, rmw_qos_profile_t rgb_qos, ); depth_sub_ = std::make_shared>( node_, "depth/image_raw", -#ifdef message_filters_QoS +#ifdef ORBBEC_MESSAGE_FILTERS_USES_RCLCPP_QOS rclcpp::QoS{rclcpp::QoSInitialization::from_rmw(depth_qos), depth_qos} #else depth_qos diff --git a/orbbec_camera/src/image_publisher.cpp b/orbbec_camera/src/image_publisher.cpp index 7283cb8d..0998fedb 100644 --- a/orbbec_camera/src/image_publisher.cpp +++ b/orbbec_camera/src/image_publisher.cpp @@ -35,20 +35,20 @@ size_t image_rcl_publisher::get_subscription_count() const { image_transport_publisher::image_transport_publisher(rclcpp::Node& node, const std::string& topic_name, const rmw_qos_profile_t& qos) { - image_publisher_impl = std::make_shared( - image_transport::create_publisher( -#ifdef image_transport_NODE_INTERFACE + image_publisher_impl = + std::make_shared(image_transport::create_publisher( +#ifdef ORBBEC_IMAGE_TRANSPORT_USES_REQUIRED_INTERFACES image_transport::RequiredInterfaces{node}, #else &node, #endif topic_name, -#ifdef image_transport_QoS +#ifdef ORBBEC_IMAGE_TRANSPORT_USES_REQUIRED_INTERFACES rclcpp::QoS{rclcpp::QoSInitialization::from_rmw(qos), qos} #else qos #endif - )); + )); } void image_transport_publisher::publish(sensor_msgs::msg::Image::UniquePtr image_ptr) { image_publisher_impl->publish(*image_ptr); @@ -57,4 +57,4 @@ void image_transport_publisher::publish(sensor_msgs::msg::Image::UniquePtr image size_t image_transport_publisher::get_subscription_count() const { return image_publisher_impl->getNumSubscribers(); } -} // namespace orbbec_camera \ No newline at end of file +} // namespace orbbec_camera diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index 0f9ca2a4..2db3c2a4 100755 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -5311,15 +5311,32 @@ void OBCameraNode::publishConfidenceFrame(const std::shared_ptr &conf } void OBCameraNode::setupCameraInfo() { - std::string color_camera_name = camera_name_ + "_color"; + const auto create_camera_info_manager = [this](const std::string &camera_name, + const std::string &camera_info_url) { +#ifdef ORBBEC_CAMERA_INFO_MANAGER_USES_NODE_INTERFACES +#ifdef ORBBEC_CAMERA_INFO_MANAGER_USES_RCLCPP_QOS + return std::make_unique( + node_->get_node_base_interface(), node_->get_node_services_interface(), + node_->get_node_logging_interface(), camera_name, camera_info_url, + rclcpp::SystemDefaultsQoS()); +#else + return std::make_unique( + node_->get_node_base_interface(), node_->get_node_services_interface(), + node_->get_node_logging_interface(), camera_name, camera_info_url, rmw_qos_profile_default); +#endif +#else + return std::make_unique(node_, camera_name, + camera_info_url); +#endif + }; + + const std::string color_camera_name = camera_name_ + "_color"; if (!color_info_url_.empty()) { - color_info_manager_ = std::make_unique( - node_, color_camera_name, color_info_url_); + color_info_manager_ = create_camera_info_manager(color_camera_name, color_info_url_); } - std::string ir_camera_name = camera_name_ + "_ir"; + const std::string ir_camera_name = camera_name_ + "_ir"; if (!ir_info_url_.empty()) { - ir_info_manager_ = std::make_unique( - node_, ir_camera_name, ir_info_url_); + ir_info_manager_ = create_camera_info_manager(ir_camera_name, ir_info_url_); } } @@ -7287,8 +7304,8 @@ void OBCameraNode::publishStaticTransforms() { if (!publish_tf_) { return; } - static_tf_broadcaster_ = std::make_shared(node_); - dynamic_tf_broadcaster_ = std::make_shared(node_); + static_tf_broadcaster_ = std::make_shared(*node_); + dynamic_tf_broadcaster_ = std::make_shared(*node_); calcAndPublishStaticTransform(); if (tf_publish_rate_ > 0) { tf_thread_ = std::make_shared([this]() { publishDynamicTransforms(); }); diff --git a/orbbec_camera/src/ob_camera_node_driver.cpp b/orbbec_camera/src/ob_camera_node_driver.cpp index 98c6ef07..5634a3f3 100644 --- a/orbbec_camera/src/ob_camera_node_driver.cpp +++ b/orbbec_camera/src/ob_camera_node_driver.cpp @@ -19,8 +19,13 @@ #include #include #include -#include #include +#if __has_include() +#include +#define ORBBEC_AMENT_INDEX_USES_FILESYSTEM_PATHS +#else +#include +#endif #include #include #include @@ -39,6 +44,24 @@ std::string g_time_domain = "global"; // Assuming this is declared elsew namespace { constexpr auto kStreamStartDelayAfterReconnect = std::chrono::seconds(5); +std::filesystem::path getPackageSharePath(const std::string &package_name) { +#ifdef ORBBEC_AMENT_INDEX_USES_FILESYSTEM_PATHS + return ament_index_cpp::get_package_share_path(package_name); +#else + return ament_index_cpp::get_package_share_directory(package_name); +#endif +} + +std::filesystem::path getPackagePrefixPath(const std::string &package_name) { +#ifdef ORBBEC_AMENT_INDEX_USES_FILESYSTEM_PATHS + std::filesystem::path package_prefix; + ament_index_cpp::get_package_prefix(package_name, package_prefix); + return package_prefix; +#else + return ament_index_cpp::get_package_prefix(package_name); +#endif +} + std::string getLogDirectoryForCamera(const std::string &camera_name) { const char *log_dir_override = std::getenv("ORBBEC_LOG_DIR"); if (log_dir_override && log_dir_override[0] != '\0') { @@ -153,10 +176,10 @@ int rosLogSeverityFromString(const std::string_view &log_level) { OBCameraNodeDriver::OBCameraNodeDriver(const rclcpp::NodeOptions &node_options) : Node("orbbec_camera_node", "/", node_options), node_options_(node_options), - config_path_(ament_index_cpp::get_package_share_directory("orbbec_camera") + - "/config/OrbbecSDKConfig_v2.0.xml"), + config_path_( + (getPackageSharePath("orbbec_camera") / "config" / "OrbbecSDKConfig_v2.0.xml").string()), logger_(this->get_logger()), - extension_path_(ament_index_cpp::get_package_prefix("orbbec_camera") + "/lib/extensions") { + extension_path_((getPackagePrefixPath("orbbec_camera") / "lib" / "extensions").string()) { node_name_ = "orbbec_camera_node"; init(); } @@ -165,10 +188,10 @@ OBCameraNodeDriver::OBCameraNodeDriver(const std::string &node_name, const std:: const rclcpp::NodeOptions &node_options) : Node(node_name, ns, node_options), node_options_(node_options), - config_path_(ament_index_cpp::get_package_share_directory("orbbec_camera") + - "/config/OrbbecSDKConfig_v2.0.xml"), + config_path_( + (getPackageSharePath("orbbec_camera") / "config" / "OrbbecSDKConfig_v2.0.xml").string()), logger_(this->get_logger()), - extension_path_(ament_index_cpp::get_package_prefix("orbbec_camera") + "/lib/extensions") { + extension_path_((getPackagePrefixPath("orbbec_camera") / "lib" / "extensions").string()) { node_name_ = node_name; init(); } diff --git a/orbbec_camera/src/ob_lidar_node.cpp b/orbbec_camera/src/ob_lidar_node.cpp index 0f3d2baa..b21bc13e 100644 --- a/orbbec_camera/src/ob_lidar_node.cpp +++ b/orbbec_camera/src/ob_lidar_node.cpp @@ -1165,8 +1165,8 @@ void OBLidarNode::publishStaticTransforms() { if (!publish_tf_) { return; } - static_tf_broadcaster_ = std::make_shared(node_); - dynamic_tf_broadcaster_ = std::make_shared(node_); + static_tf_broadcaster_ = std::make_shared(*node_); + dynamic_tf_broadcaster_ = std::make_shared(*node_); calcAndPublishStaticTransform(); if (tf_publish_rate_ > 0) { tf_thread_ = std::make_shared([this]() { publishDynamicTransforms(); }); diff --git a/orbbec_camera/tools/multi_save_rgbir.cpp b/orbbec_camera/tools/multi_save_rgbir.cpp index 6496787a..69bbc290 100644 --- a/orbbec_camera/tools/multi_save_rgbir.cpp +++ b/orbbec_camera/tools/multi_save_rgbir.cpp @@ -5,9 +5,6 @@ #include #include "orbbec_camera/ob_camera_node.h" #include "orbbec_camera_msgs/msg/metadata.hpp" -#include -#include -#include #include #include #include @@ -410,4 +407,4 @@ class MultiCameraSubscriber : public rclcpp::Node { }; } // namespace tools } // namespace orbbec_camera -RCLCPP_COMPONENTS_REGISTER_NODE(orbbec_camera::tools::MultiCameraSubscriber) \ No newline at end of file +RCLCPP_COMPONENTS_REGISTER_NODE(orbbec_camera::tools::MultiCameraSubscriber) diff --git a/orbbec_camera/tools/ob_benchmark.cpp b/orbbec_camera/tools/ob_benchmark.cpp index 52022503..76a85081 100644 --- a/orbbec_camera/tools/ob_benchmark.cpp +++ b/orbbec_camera/tools/ob_benchmark.cpp @@ -3,9 +3,6 @@ #include #include #include "orbbec_camera_msgs/msg/metadata.hpp" -#include -#include -#include #include namespace orbbec_camera { diff --git a/orbbec_camera/tools/start_benchmark.cpp b/orbbec_camera/tools/start_benchmark.cpp index 9b474080..5987a554 100644 --- a/orbbec_camera/tools/start_benchmark.cpp +++ b/orbbec_camera/tools/start_benchmark.cpp @@ -3,9 +3,6 @@ #include #include #include "orbbec_camera_msgs/msg/metadata.hpp" -#include -#include -#include #include namespace orbbec_camera { diff --git a/orbbec_camera_msgs/CMakeLists.txt b/orbbec_camera_msgs/CMakeLists.txt index fd229bb6..b71437b9 100644 --- a/orbbec_camera_msgs/CMakeLists.txt +++ b/orbbec_camera_msgs/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.10) project(orbbec_camera_msgs) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") diff --git a/orbbec_description/CMakeLists.txt b/orbbec_description/CMakeLists.txt index 8310ce57..5cbf3d19 100644 --- a/orbbec_description/CMakeLists.txt +++ b/orbbec_description/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.10) project(orbbec_description) find_package(ament_cmake REQUIRED) diff --git a/orbbec_description/package.xml b/orbbec_description/package.xml index f79a7f55..10234781 100644 --- a/orbbec_description/package.xml +++ b/orbbec_description/package.xml @@ -9,6 +9,13 @@ ament_cmake + ament_index_python + launch + launch_ros + robot_state_publisher + rviz2 + xacro + ament_lint_auto ament_lint_common From 05acd7174cbc47687d11ac1e4658dd4eed80ff76 Mon Sep 17 00:00:00 2001 From: slz Date: Wed, 29 Jul 2026 16:01:00 +0800 Subject: [PATCH 19/48] fix: pass robot description as a parameter --- orbbec_description/launch/launch_utils.py | 15 +++------------ orbbec_description/launch/view_model.launch.py | 5 +++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/orbbec_description/launch/launch_utils.py b/orbbec_description/launch/launch_utils.py index 10e43fb0..fd365587 100644 --- a/orbbec_description/launch/launch_utils.py +++ b/orbbec_description/launch/launch_utils.py @@ -12,22 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os import xacro -import tempfile + def to_urdf(xacro_path, parameters=None): - """Convert the given xacro file to URDF file. + """Convert the given xacro file to a URDF string. * xacro_path -- the path to the xacro file * parameters -- to be used when xacro file is parsed. """ - with tempfile.NamedTemporaryFile(prefix="%s_" % os.path.basename(xacro_path), delete=False) as xacro_file: - urdf_path = xacro_file.name - - # open and process file doc = xacro.process_file(xacro_path, mappings=parameters) - # open the output file - with open(urdf_path, 'w') as urdf_file: - urdf_file.write(doc.toprettyxml(indent=' ')) - - return urdf_path + return doc.toprettyxml(indent=' ') diff --git a/orbbec_description/launch/view_model.launch.py b/orbbec_description/launch/view_model.launch.py index 8f163cd9..f5a73fd4 100644 --- a/orbbec_description/launch/view_model.launch.py +++ b/orbbec_description/launch/view_model.launch.py @@ -35,7 +35,8 @@ def generate_launch_description(): rviz_config_dir = os.path.join(get_package_share_directory('orbbec_description'), 'rviz', 'urdf.rviz') xacro_path = os.path.join(get_package_share_directory('orbbec_description'), 'urdf', params['model']) - urdf = to_urdf(xacro_path, {'use_nominal_extrinsics': 'true', 'add_plug': 'true'}) + robot_description = to_urdf( + xacro_path, {'use_nominal_extrinsics': 'true', 'add_plug': 'true'}) rviz_node = Node( package='rviz2', executable='rviz2', @@ -50,6 +51,6 @@ def generate_launch_description(): executable='robot_state_publisher', namespace='', output='screen', - arguments=[urdf] + parameters=[{'robot_description': robot_description}] ) return launch.LaunchDescription([rviz_node, model_node]) From 130f6a6704ad1bcf944490193a557759095afe80 Mon Sep 17 00:00:00 2001 From: slz Date: Wed, 29 Jul 2026 16:51:57 +0800 Subject: [PATCH 20/48] fix: correct public header install path --- orbbec_camera/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orbbec_camera/CMakeLists.txt b/orbbec_camera/CMakeLists.txt index 555112fe..334401c2 100644 --- a/orbbec_camera/CMakeLists.txt +++ b/orbbec_camera/CMakeLists.txt @@ -359,7 +359,7 @@ install(TARGETS ${PROJECT_NAME} frame_latency start_benchmark multi_save_rgbir A LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) -install(DIRECTORY include/orbbec_camera DESTINATION include/orbbec_camera) +install(DIRECTORY include/orbbec_camera DESTINATION include) install(DIRECTORY launch DESTINATION share/${PROJECT_NAME}/) install(DIRECTORY config DESTINATION share/${PROJECT_NAME}/) install(DIRECTORY examples DESTINATION share/${PROJECT_NAME}/) From 19e2ce69100112dcc143232f4f78af06d9f755ce Mon Sep 17 00:00:00 2001 From: slz Date: Wed, 29 Jul 2026 17:06:52 +0800 Subject: [PATCH 21/48] fix: require CMake 3.13 for link commands The package uses add_link_options() and target_link_directories(), which were both introduced in CMake 3.13. --- orbbec_camera/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orbbec_camera/CMakeLists.txt b/orbbec_camera/CMakeLists.txt index 334401c2..d3e514fc 100644 --- a/orbbec_camera/CMakeLists.txt +++ b/orbbec_camera/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.13) project(orbbec_camera) set(CMAKE_CXX_STANDARD 17) From e967d85067e2261f6f55e043f40a6574d74793d2 Mon Sep 17 00:00:00 2001 From: slz Date: Mon, 3 Aug 2026 09:55:48 +0800 Subject: [PATCH 22/48] docs: update README files to clarify ROS 2 installation instructions and parameter names --- README.MD | 21 ++++++++++++------- README_CN.MD | 21 ++++++++++++------- .../Gemini_435Le_example_node/README.MD | 10 ++++----- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/README.MD b/README.MD index 986b68e2..d49298c6 100644 --- a/README.MD +++ b/README.MD @@ -226,9 +226,17 @@ If you need to migrate existing projects from the main (v1.x) branch to the v2-m **Environment configuration** -Install ROS 2 according to the official guide: +Install one of the supported ROS 2 distributions according to its official guide: -* [ROS 2 installation (Ubuntu)](https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html) +* [Foxy](https://docs.ros.org/en/foxy/) +* [Humble](https://docs.ros.org/en/humble/) +* [Jazzy](https://docs.ros.org/en/jazzy/) + +Source the ROS 2 environment before running the commands below: + +```bash +source /opt/ros/humble/setup.bash # Replace humble with foxy or jazzy as needed +``` Install dependencies: @@ -256,10 +264,10 @@ sudo apt update apt list | grep orbbec ``` -Install OrbbecSDK ROS2 package: +If binary packages are available for your ROS 2 distribution, install the OrbbecSDK ROS2 packages with: ```bash -sudo apt install ros-humble-orbbec-camera ros-humble-orbbec-description +sudo apt install ros-${ROS_DISTRO}-orbbec-camera ros-${ROS_DISTRO}-orbbec-description ``` After installation, you can use it directly without compilation. @@ -304,12 +312,11 @@ sudo udevadm control --reload-rules && sudo udevadm trigger ```bash cd ~/ros2_ws/src/OrbbecSDK_ROS2/orbbec_camera/scripts sudo bash install_udev_rules.sh -sudo udevadm control --reload-rules && sudo udevadm trigger ``` This step is **mandatory** for Linux users. -`Notes:` If this script is not executed, open the device will fail due to permission issues. You need to run the sample with sudo (administrator privileges). +> **Note:** Without the udev rules, the device may fail to open because of insufficient permissions. Install the rules and reconnect the camera instead of running ROS 2 nodes with `sudo`. ## Getting start @@ -356,7 +363,7 @@ For more usage details, please refer to the official [OrbbecSDK ROS2 documentati ## Supported Devices -Currently, the following devices are supported by the OrbbecSDK ROS2 Wrapper v2-main branch. More devices support will be added in the near future. If you can not find your device in the table below, try the [main](https://github.com/orbbec/OrbbecSDK_ROS2) branch. +Currently, the following devices are supported by the OrbbecSDK ROS2 Wrapper v2-main branch. More devices support will be added in the near future. If you can not find your device in the table below, try the [main](https://github.com/orbbec/OrbbecSDK_ROS2/tree/main) branch. For optimal performance, we strongly recommend updating to the latest firmware version. This ensures that you benefit from the most recent enhancements and bug fixes. diff --git a/README_CN.MD b/README_CN.MD index 3bfd3190..954747cf 100644 --- a/README_CN.MD +++ b/README_CN.MD @@ -225,9 +225,17 @@ OrbbecSDK ROS2 Wrapper 提供 Orbbec 相机与 ROS 2 环境的无缝集成,支 **环境配置** -根据官方指南安装 ROS 2: +根据相应的官方指南安装一个受支持的 ROS 2 发行版: -* [ROS 2 安装指南(Ubuntu)](https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html) +* [Foxy](https://docs.ros.org/en/foxy/) +* [Humble](https://docs.ros.org/en/humble/) +* [Jazzy](https://docs.ros.org/en/jazzy/) + +执行后续命令前,请先加载 ROS 2 环境: + +```bash +source /opt/ros/humble/setup.bash # 根据需要将 humble 替换为 foxy 或 jazzy +``` 安装依赖项: @@ -255,10 +263,10 @@ sudo apt update apt list | grep orbbec ``` -安装 OrbbecSDK ROS2 包: +如果当前 ROS 2 发行版提供二进制包,可使用以下命令安装 OrbbecSDK ROS2: ```bash -sudo apt install ros-humble-orbbec-camera ros-humble-orbbec-description +sudo apt install ros-${ROS_DISTRO}-orbbec-camera ros-${ROS_DISTRO}-orbbec-description ``` 安装完成后,直接使用即可,无需编译。 @@ -302,12 +310,11 @@ sudo udevadm control --reload-rules && sudo udevadm trigger ```bash cd ~/ros2_ws/src/OrbbecSDK_ROS2/orbbec_camera/scripts sudo bash install_udev_rules.sh -sudo udevadm control --reload-rules && sudo udevadm trigger ``` 此步骤对于 Linux 用户是**必需的**。 -`注意:` 如果不执行此脚本,由于权限问题,打开设备将会失败。您需要使用 sudo(管理员权限)运行示例程序。 +> **注意:** 如果未安装 udev 规则,可能因权限不足而无法打开设备。请正确安装规则并重新插拔相机,不建议使用 `sudo` 运行 ROS 2 节点。 ## 快速开始 @@ -354,7 +361,7 @@ ros2 service call /camera/get_sdk_version orbbec_camera_msgs/srv/GetString '{}' ## 支持的设备 -目前 v2-main 分支支持以下设备。更多设备支持将陆续增加。如果没有找到您的设备,请尝试 [main](https://github.com/orbbec/OrbbecSDK_ROS2) 分支。 +目前 v2-main 分支支持以下设备。更多设备支持将陆续增加。如果没有找到您的设备,请尝试 [main](https://github.com/orbbec/OrbbecSDK_ROS2/tree/main) 分支。 为获得最佳性能,强烈建议更新至最新固件版本,以确保您能获得最新的改进和 bug 修复。 diff --git a/orbbec_camera/examples/Gemini_435Le_example_node/README.MD b/orbbec_camera/examples/Gemini_435Le_example_node/README.MD index 2482ca7e..b08c9c8f 100644 --- a/orbbec_camera/examples/Gemini_435Le_example_node/README.MD +++ b/orbbec_camera/examples/Gemini_435Le_example_node/README.MD @@ -91,7 +91,7 @@ The master switch for camera streams allows enabling or disabling all streams du - **Get streams status** ```bash - ros2 service call /camera/get_streams_enable std_srvs/srv/GetBool '{}' + ros2 service call /camera/get_streams_enable orbbec_camera_msgs/srv/GetBool '{}' ``` ### 2.3 Device Info @@ -148,11 +148,11 @@ A new parameter **time_sync_period** is introduced to configure the time synchro --- -### 3.3 Added `camera_info_url` and `ir_info_url` +### 3.3 Added `color_info_url` and `ir_info_url` Support specifying calibration file paths through parameters to load external camera intrinsic and extrinsic configurations: -* **camera\_info\_url**: Path to the color camera calibration file +* **color\_info\_url**: Path to the color camera calibration file * **ir\_info\_url**: Path to the IR camera calibration file > Note: This method does not write the file information to the device. @@ -162,8 +162,8 @@ Support specifying calibration file paths through parameters to load external ca Specify the path in the launch file or when launching: ```launch -DeclareLaunchArgument('ir_info_url', default_value='file:///home/user/calibration/color.yaml'), -DeclareLaunchArgument('color_info_url', default_value='file:///home/user/calibration/ir.yaml'), +DeclareLaunchArgument('ir_info_url', default_value='file:///home/user/calibration/ir.yaml'), +DeclareLaunchArgument('color_info_url', default_value='file:///home/user/calibration/color.yaml'), ``` #### Calibration File Example (YAML Format) From 66541c6d329dd263ed1ae40fc6b07cc36f8e102d Mon Sep 17 00:00:00 2001 From: slz Date: Wed, 5 Aug 2026 15:12:16 +0800 Subject: [PATCH 23/48] fix: normalize line endings to LF (#118) --- .cmake-format.py | 206 ++-- .gitattributes | 15 + .../multicamera_sync/Python/Config.ini | 16 +- .../multicamera_sync/Python/README.md | 12 +- .../multicamera_sync/Python/SyncFramesMain.py | 180 +-- .../script/config_frameMatch-Astra2_new.py | 784 ++++++------- .../config_frameMatch-systemTimestamp.py | 806 ++++++------- .../Python/script/config_frameMatch.py | 850 +++++++------- .../script/config_frameMatch_Gemini2VL.py | 820 ++++++------- .../Python/script/config_frameMatch_g330.py | 852 +++++++------- orbbec_camera_msgs/msg/DeviceInfo.msg | 14 +- orbbec_camera_msgs/srv/GetCameraInfo.srv | 4 +- orbbec_camera_msgs/srv/GetDeviceInfo.srv | 6 +- orbbec_description/urdf/astra_2.urdf.xacro | 832 ++++++------- orbbec_description/urdf/gemini_2.urdf.xacro | 938 +++++++-------- orbbec_description/urdf/gemini_2_L.urdf.xacro | 1044 ++++++++--------- .../urdf/gemini_335_L_336_L.urdf.xacro | 1044 ++++++++--------- 17 files changed, 4219 insertions(+), 4204 deletions(-) diff --git a/.cmake-format.py b/.cmake-format.py index 14e300d5..8b8f33c5 100644 --- a/.cmake-format.py +++ b/.cmake-format.py @@ -1,104 +1,104 @@ -# ----------------------------- -# Options affecting formatting. -# ----------------------------- -with section("format"): - - # Disable formatting entirely, making cmake-format a no-op - disable = False - - # How wide to allow formatted cmake files - line_width = 120 - - # How many spaces to tab for indent - tab_size = 4 - - # If true, lines are indented using tab characters (utf-8 0x09) instead of - # space characters (utf-8 0x20). In cases where the layout would - # require a fractional tab character, the behavior of the fractional - # indentation is governed by - use_tabchars = False - - # If is True, then the value of this variable indicates how - # fractional indentions are handled during whitespace replacement. If set to - # 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set - # to `round-up` fractional indentation is replaced with a single tab character - # (utf-8 0x09) effectively shifting the column to the next tabstop - fractional_tab_policy = 'use-space' - - # If an argument group contains more than this many sub-groups (parg or kwarg - # groups) then force it to a vertical layout. - max_subgroups_hwrap = 4 - - # If a positional argument group contains more than this many arguments, then - # force it to a vertical layout. - max_pargs_hwrap = 6 - - # If a cmdline positional group consumes more than this many lines without - # nesting, then invalidate the layout (and nest) - max_rows_cmdline = 2 - - # If true, separate flow control names from their parentheses with a space - separate_ctrl_name_with_space = False - - # If true, separate function names from parentheses with a space - separate_fn_name_with_space = False - - # If a statement is wrapped to more than one line, than dangle the closing - # parenthesis on its own line. - dangle_parens = True - - # If the trailing parenthesis must be 'dangled' on its on line, then align it - # to this reference: `prefix`: the start of the statement, `prefix-indent`: - # the start of the statement, plus one indentation level, `child`: align to - # the column of the arguments - dangle_align = 'prefix' - - # If the statement spelling length (including space and parenthesis) is - # smaller than this amount, then force reject nested layouts. - min_prefix_chars = 4 - - # If the statement spelling length (including space and parenthesis) is larger - # than the tab width by more than this amount, then force reject un-nested - # layouts. - max_prefix_chars = 10 - - # If a candidate layout is wrapped horizontally but it exceeds this many - # lines, then reject the layout. - max_lines_hwrap = 2 - - # What style line endings to use in the output. - line_ending = 'unix' - - # Format command names consistently as 'lower' or 'upper' case - command_case = 'canonical' - - # Format keywords consistently as 'lower' or 'upper' case - keyword_case = 'unchanged' - - # A list of command names which should always be wrapped - always_wrap = [] - - # If true, the argument lists which are known to be sortable will be sorted - # lexicographicall - enable_sort = True - - # If true, the parsers may infer whether or not an argument list is sortable - # (without annotation). - autosort = False - - # By default, if cmake-format cannot successfully fit everything into the - # desired linewidth it will apply the last, most agressive attempt that it - # made. If this flag is True, however, cmake-format will print error, exit - # with non-zero status code, and write-out nothing - require_valid_layout = False - - # A dictionary mapping layout nodes to a list of wrap decisions. See the - # documentation for more information. - layout_passes = {} - -# ----------------------------- -# Options affecting comment formatting (indirectly). -# ----------------------------- -with section("markup"): - # Disabling markup avoids merging consecutive comment lines +# ----------------------------- +# Options affecting formatting. +# ----------------------------- +with section("format"): + + # Disable formatting entirely, making cmake-format a no-op + disable = False + + # How wide to allow formatted cmake files + line_width = 120 + + # How many spaces to tab for indent + tab_size = 4 + + # If true, lines are indented using tab characters (utf-8 0x09) instead of + # space characters (utf-8 0x20). In cases where the layout would + # require a fractional tab character, the behavior of the fractional + # indentation is governed by + use_tabchars = False + + # If is True, then the value of this variable indicates how + # fractional indentions are handled during whitespace replacement. If set to + # 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set + # to `round-up` fractional indentation is replaced with a single tab character + # (utf-8 0x09) effectively shifting the column to the next tabstop + fractional_tab_policy = 'use-space' + + # If an argument group contains more than this many sub-groups (parg or kwarg + # groups) then force it to a vertical layout. + max_subgroups_hwrap = 4 + + # If a positional argument group contains more than this many arguments, then + # force it to a vertical layout. + max_pargs_hwrap = 6 + + # If a cmdline positional group consumes more than this many lines without + # nesting, then invalidate the layout (and nest) + max_rows_cmdline = 2 + + # If true, separate flow control names from their parentheses with a space + separate_ctrl_name_with_space = False + + # If true, separate function names from parentheses with a space + separate_fn_name_with_space = False + + # If a statement is wrapped to more than one line, than dangle the closing + # parenthesis on its own line. + dangle_parens = True + + # If the trailing parenthesis must be 'dangled' on its on line, then align it + # to this reference: `prefix`: the start of the statement, `prefix-indent`: + # the start of the statement, plus one indentation level, `child`: align to + # the column of the arguments + dangle_align = 'prefix' + + # If the statement spelling length (including space and parenthesis) is + # smaller than this amount, then force reject nested layouts. + min_prefix_chars = 4 + + # If the statement spelling length (including space and parenthesis) is larger + # than the tab width by more than this amount, then force reject un-nested + # layouts. + max_prefix_chars = 10 + + # If a candidate layout is wrapped horizontally but it exceeds this many + # lines, then reject the layout. + max_lines_hwrap = 2 + + # What style line endings to use in the output. + line_ending = 'unix' + + # Format command names consistently as 'lower' or 'upper' case + command_case = 'canonical' + + # Format keywords consistently as 'lower' or 'upper' case + keyword_case = 'unchanged' + + # A list of command names which should always be wrapped + always_wrap = [] + + # If true, the argument lists which are known to be sortable will be sorted + # lexicographicall + enable_sort = True + + # If true, the parsers may infer whether or not an argument list is sortable + # (without annotation). + autosort = False + + # By default, if cmake-format cannot successfully fit everything into the + # desired linewidth it will apply the last, most agressive attempt that it + # made. If this flag is True, however, cmake-format will print error, exit + # with non-zero status code, and write-out nothing + require_valid_layout = False + + # A dictionary mapping layout nodes to a list of wrap decisions. See the + # documentation for more information. + layout_passes = {} + +# ----------------------------- +# Options affecting comment formatting (indirectly). +# ----------------------------- +with section("markup"): + # Disabling markup avoids merging consecutive comment lines enable_markup = False \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index e69de29b..923a704f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -0,0 +1,15 @@ +# Normalize text files to LF in both the repository and working tree. +* text=auto eol=lf + +# Treat generated assets and bundled binaries as binary files. +*.stl binary +*.STL binary +*.so binary +*.so.* binary +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.pdf binary +*.zip binary +*.gz binary diff --git a/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/Config.ini b/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/Config.ini index fcfc7475..ff67167e 100644 --- a/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/Config.ini +++ b/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/Config.ini @@ -1,8 +1,8 @@ -[Parameter] -# Unit: FPS. Please fill in according to the actual dataset frame rate, -# otherwise the matching will be inaccurate. -frameRate=30 -# Unit: ms. When the timestamp range difference of a matched frame group -# is greater than or equal to tspRangeThreshold, the file name will be marked. -tspRangeThreshold=4 - +[Parameter] +# Unit: FPS. Please fill in according to the actual dataset frame rate, +# otherwise the matching will be inaccurate. +frameRate=30 +# Unit: ms. When the timestamp range difference of a matched frame group +# is greater than or equal to tspRangeThreshold, the file name will be marked. +tspRangeThreshold=4 + diff --git a/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/README.md b/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/README.md index e0805178..b405b24b 100644 --- a/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/README.md +++ b/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/README.md @@ -1,7 +1,7 @@ -## config_frameMatch.py - -**Definition of the three folders:** - -- **matchFrames**: Data constrained within a half-frame. -- **notMatchFrames**: Data not constrained within a half-frame, unmatched. +## config_frameMatch.py + +**Definition of the three folders:** + +- **matchFrames**: Data constrained within a half-frame. +- **notMatchFrames**: Data not constrained within a half-frame, unmatched. - **abnormal**: Data within the group that exceeds the `tspRangeThreshold` setting. \ No newline at end of file diff --git a/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/SyncFramesMain.py b/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/SyncFramesMain.py index e85cb04a..e7e8caa9 100644 --- a/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/SyncFramesMain.py +++ b/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/SyncFramesMain.py @@ -1,90 +1,90 @@ -import os -import subprocess -import json -import platform - -def list_subdirectories(path): - for f in os.listdir(path): - if os.path.isdir(os.path.join(path, f)): - yield f - -def read_pid_from_device_json(frames_dir): - file_path = frames_dir + "/DevicesInfo.txt" - if not os.path.exists(file_path): - print(file_path + " not exists. Please check it") - return "" - - with open(file_path, 'r') as f: - data = json.load(f) - - if not 'devicePid' in data: - print("Not found 'devicePid' in " + file_path) - return "" - - return data['devicePid'] - -def execute_sync_width_pid(frames_dir, pid): - sync_script_file="" - if pid.lower() == "0x0675": - sync_script_file="script/config_frameMatch_Gemini2VL.py" - elif pid.lower() == "0x0670" or pid.lower() == "0x0701": - sync_script_file="script/config_frameMatch-systemTimestamp.py" - elif pid.lower() == "0x0660": - sync_script_file="script/config_frameMatch-Astra2_new.py" - elif pid.lower() == "0x0800" or pid.lower() == "0x0804" or pid.lower() == "0x0803" or pid.lower() == "0x0807" or pid.lower() == "0x0801" or pid.lower() == "0x0805" or pid.lower() == "0x080b" or pid.lower() == "0x080e" or pid.lower() == "0x080f" or pid.lower() == "0x0A13": - sync_script_file="script/config_frameMatch_g330.py" - else: - sync_script_file="script/config_frameMatch.py" - - if len(sync_script_file) > 0: - print(f"execute synchronize frames. script_file={sync_script_file}, frames_dir={frames_dir}") - if platform.system() == "Windows": - output = subprocess.check_output(["python", sync_script_file, os.path.abspath(f"{frames_dir}"), os.getcwd()]) - print(output.decode("gbk")) - else: - output = subprocess.check_output(["python3", sync_script_file, os.path.abspath(f"{frames_dir}"), os.getcwd()]) - print(output.decode("utf-8")) - else: - print("Invalid pid=" + pid + ", not match sync frame script") - -def sync_frames(frames_dir): - pid = read_pid_from_device_json(frames_dir) - if len(pid) <= 0: - print("Get pid failed.") - return - - execute_sync_width_pid(frames_dir, pid) - -def main(): - frames_output_path = os.path.abspath("../output") - - subdirectories = list(list_subdirectories(frames_output_path)) - - if not subdirectories: - print("No subdirectories found in the specified directory.") - - for i, subdir in enumerate(subdirectories): - print(f"{i + 1}. {subdir}") - - choice = input("Please select a subdirectory by number (or 'q' to quit): ") - - if choice.lower() == 'q': - return - - is_index_valid = False - try: - index = int(choice) - 1 - if 0 <= index < len(subdirectories): - is_index_valid = True - else: - print(f"Invalid choice. index={index}. Please enter a number between 1 and the total number of subdirectories.") - except ValueError: - print("Invalid choice(ValueException). Please enter a number between 1 and the total number of subdirectories") - if is_index_valid: - selected_subdir = subdirectories[index] - print(f"You selected the subdirectory: {selected_subdir}") - sync_frames(f"{frames_output_path }/{selected_subdir}") - - -if __name__ == "__main__": - main() +import os +import subprocess +import json +import platform + +def list_subdirectories(path): + for f in os.listdir(path): + if os.path.isdir(os.path.join(path, f)): + yield f + +def read_pid_from_device_json(frames_dir): + file_path = frames_dir + "/DevicesInfo.txt" + if not os.path.exists(file_path): + print(file_path + " not exists. Please check it") + return "" + + with open(file_path, 'r') as f: + data = json.load(f) + + if not 'devicePid' in data: + print("Not found 'devicePid' in " + file_path) + return "" + + return data['devicePid'] + +def execute_sync_width_pid(frames_dir, pid): + sync_script_file="" + if pid.lower() == "0x0675": + sync_script_file="script/config_frameMatch_Gemini2VL.py" + elif pid.lower() == "0x0670" or pid.lower() == "0x0701": + sync_script_file="script/config_frameMatch-systemTimestamp.py" + elif pid.lower() == "0x0660": + sync_script_file="script/config_frameMatch-Astra2_new.py" + elif pid.lower() == "0x0800" or pid.lower() == "0x0804" or pid.lower() == "0x0803" or pid.lower() == "0x0807" or pid.lower() == "0x0801" or pid.lower() == "0x0805" or pid.lower() == "0x080b" or pid.lower() == "0x080e" or pid.lower() == "0x080f" or pid.lower() == "0x0A13": + sync_script_file="script/config_frameMatch_g330.py" + else: + sync_script_file="script/config_frameMatch.py" + + if len(sync_script_file) > 0: + print(f"execute synchronize frames. script_file={sync_script_file}, frames_dir={frames_dir}") + if platform.system() == "Windows": + output = subprocess.check_output(["python", sync_script_file, os.path.abspath(f"{frames_dir}"), os.getcwd()]) + print(output.decode("gbk")) + else: + output = subprocess.check_output(["python3", sync_script_file, os.path.abspath(f"{frames_dir}"), os.getcwd()]) + print(output.decode("utf-8")) + else: + print("Invalid pid=" + pid + ", not match sync frame script") + +def sync_frames(frames_dir): + pid = read_pid_from_device_json(frames_dir) + if len(pid) <= 0: + print("Get pid failed.") + return + + execute_sync_width_pid(frames_dir, pid) + +def main(): + frames_output_path = os.path.abspath("../output") + + subdirectories = list(list_subdirectories(frames_output_path)) + + if not subdirectories: + print("No subdirectories found in the specified directory.") + + for i, subdir in enumerate(subdirectories): + print(f"{i + 1}. {subdir}") + + choice = input("Please select a subdirectory by number (or 'q' to quit): ") + + if choice.lower() == 'q': + return + + is_index_valid = False + try: + index = int(choice) - 1 + if 0 <= index < len(subdirectories): + is_index_valid = True + else: + print(f"Invalid choice. index={index}. Please enter a number between 1 and the total number of subdirectories.") + except ValueError: + print("Invalid choice(ValueException). Please enter a number between 1 and the total number of subdirectories") + if is_index_valid: + selected_subdir = subdirectories[index] + print(f"You selected the subdirectory: {selected_subdir}") + sync_frames(f"{frames_output_path }/{selected_subdir}") + + +if __name__ == "__main__": + main() diff --git a/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch-Astra2_new.py b/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch-Astra2_new.py index b6551274..8d83851d 100644 --- a/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch-Astra2_new.py +++ b/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch-Astra2_new.py @@ -1,392 +1,392 @@ -import os.path -import argparse -import sys -import json -import shutil -import configparser - -from pathlib import Path -from datetime import datetime - -## Config.ini configuration -# Unit: FPS. Please fill in according to the actual dataset frame rate, -# otherwise it will cause inaccurate matching. -frameRate = -1 -# Unit: ms. When the timestamp range difference of a matched frame group -# is greater than or equal to tspRangeThreshold, the file name will be marked. -tspRangeThreshold = -1 - -## Parsed automatically by Python script, DO NOT modify -primaryId = '-1' # Host ID -mainPythonWorkPath = "" # Working directory of SyncFramesMain.py -sourceFramesPath = "" # DO NOT modify, fixed value, path to TotalMode directory -sourceRootPath = "" # Root directory containing TotalMode -resultPath = "" # Path to save sync analysis results -streamProfileDict = dict() # Store Python results - - -class PictureInfo(object): - class Struct(object): - def __init__(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt): - self.deviceId = deviceId - self.sensorType = sensorType - self.syncTimeStamp = syncTimeStamp - self.picturePath = picturePath - self.deviceIdFull = deviceIdFull - self.fileExt = fileExt - - def make_struct(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt): - return self.Struct(deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt) - - -class StreamProfileInfo: - def __init__(self, sensorType, width, height, format, fps): - self.sensorType = sensorType - self.width = width - self.height = height - self.format = format - self.fps = fps - - -def initPrimaryId(): - global primaryId - - deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" - if not os.path.exists(deviceInfoPath): - print(f"Initialize primaryId failed. {deviceInfoPath} not exists") - return False - - with open(deviceInfoPath, 'r') as f: - data = json.load(f) - - if not 'devices' in data: - print(f"Initialize primaryId failed. {deviceInfoPath} not contain item 'devices'") - return False - - for item in data['devices']: - if 'isPrimaryDevice' in item and 'index' in item and item['isPrimaryDevice']: - primaryId = str(item['index']) - return True - - return False - - -def initSyncConfigParams(): - global frameRate, tspRangeThreshold - - configPath = f"{mainPythonWorkPath}/Config.ini" - if not os.path.exists(configPath): - print(f"Initliaze synchronized config parameter failed. {configPath} not exists.") - return False - - # Create ConfigParser object - config = configparser.ConfigParser() - - # Read ini file - config.read(configPath, 'utf-8') - - if not config.has_option('Parameter', 'frameRate'): - print(f"Initliaze synchronized config parameter failed. Not define 'frameRate' in ${configPath}") - return False - - if not config.has_option('Parameter', 'tspRangeThreshold'): - print(f"Initliaze synchronized config parameter failed. Not define 'tspRangeThreshold' in ${configPath}") - return False - - frameRate = config.getfloat('Parameter', 'frameRate') - if frameRate <= 0 or frameRate >= 1000: - print(f"Initliaze synchronized config parameter failed. Invalid frameRate={frameRate}") - return False - - tspRangeThreshold = config.getfloat('Parameter', 'tspRangeThreshold') - if tspRangeThreshold <= 0: - print(f"Initliaze synchronized config parameter failed. Invalid tspRangeThreshold={tspRangeThreshold}") - return False - - return True - - -def getDeviceCount(): - deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" - if not os.path.exists(deviceInfoPath): - print(f"Get device count failed. {deviceInfoPath} not exists") - return 0 - - with open(deviceInfoPath, 'r') as f: - data = json.load(f) - - if not 'devices' in data: - print(f"Get device count failed. {deviceInfoPath} not contain item 'devices'") - return 0 - - return len(data['devices']) - - -def initProfileInfoDict(): - global streamProfileDict - - streamProfileDict = dict() - profilePath = f"{sourceRootPath}/StreamProfileInfo.txt" - if not os.path.exists(profilePath): - print(f"Initialize profile information dictionary failed. {profilePath} not exists") - return False - - with open(profilePath, 'r') as f: - data = json.load(f) - - if not 'streamProfiles' in data: - print(f"Initialize profile information dictionary failed. {profilePath} not contain item 'streamProfiles'") - return False - - for item in data['streamProfiles']: - if 'sensorType' in item and 'width' in item and 'height' in item and 'format' in item and 'fps' in item: - profileInfo = StreamProfileInfo(item['sensorType'], item['width'], item['height'], item['format'], item['fps']) - streamProfileDict.setdefault(item['sensorType'], profileInfo) - else: - print(f"Initialize profile information dictionary. Error invalid StreamProfile, {item}") - - return len(streamProfileDict.items()) > 0 - - -def initResultDir(): - global resultPath - timeText = datetime.now().strftime("%Y-%m-%d_%H%M%S") - resultPath = f"{sourceRootPath}/results-{timeText}" - if not os.path.exists(resultPath): - os.makedirs(resultPath) - - -def isFrameFile(fileName): - fileExt = os.path.splitext(fileName) - if len(fileExt) < 2: - return False - - frameExts = {".jpeg", ".jpg", ".png", ".raw", "bmp"} - return fileExt[1] in frameExts - - -def initPictureInfoDictionary(rootFilePath, pictureInfoDict): - frameFileCount = 0 - for dirpath, dirnames, filenames in os.walk(rootFilePath): - # print(f"dirpath={dirpath}, dirpath.basename=" + os.path.basename(dirpath)) - for fileName in filenames: - filePath = os.path.join(dirpath, fileName) - if not isFrameFile(fileName): - continue - - frameFileCount += 1 - fileNameNoExt = os.path.splitext(fileName)[0] - pictureNameList = fileNameNoExt.split('_') - deviceId = pictureNameList[2][5:] - sensorType = pictureNameList[0].replace('#', '_') - syncTimeStamp = int(pictureNameList[3][1:]) - - # Create struct - pictureInfo = PictureInfo() - info = pictureInfo.make_struct(deviceId, sensorType, syncTimeStamp, filePath, os.path.basename(dirpath), os.path.splitext(fileName)[1]) - - # Format dictionary: one key corresponds to one array - pictureInfoDict.setdefault(deviceId, []).append(info) - - if 0 == frameFileCount: - print("initialize pictureInfoDict failed. Not found frame file") - - -def matchFrame(pictureInfoDict): - global primaryId, frameRate - global streamProfileDict - - # Get comparison image array, take the Color array of the first device for comparison - compareList = [] - for key in pictureInfoDict: - listTmp = list(pictureInfoDict[key]) - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == 'color': - compareList.append(info) - - sorted_dict = dict(sorted(pictureInfoDict.items(), key=lambda x: x[1], reverse=False)) - pictureInfoDict = sorted_dict - - # Dynamically analyze based on stream opening status to reduce loop iterations - hasColorProfile = 'OB_SENSOR_COLOR' in streamProfileDict - hasDepthProfile = 'OB_SENSOR_DEPTH' in streamProfileDict - hasIRProfile = 'OB_SENSOR_IR' in streamProfileDict - - # Match adjacent frames - resultDict = {} - consumedList = [] - dictIndex = 0 - frameTspGap = int(1000.0/frameRate+0.5) - for comparePic in compareList: - resultDict.setdefault(dictIndex, []).append(comparePic) - for key in pictureInfoDict: - listTmp = list(pictureInfoDict[key]) - # Compare Color - if hasColorProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'color' and info.syncTimeStamp >= comparePic.syncTimeStamp and info.syncTimeStamp - comparePic.syncTimeStamp <= frameTspGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Compare Depth - if hasDepthProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'depth' and info.syncTimeStamp >= comparePic.syncTimeStamp and info.syncTimeStamp - comparePic.syncTimeStamp <= frameTspGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Compare IR - if hasIRProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'ir' and info.syncTimeStamp >= comparePic.syncTimeStamp and info.syncTimeStamp - comparePic.syncTimeStamp <= frameTspGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Calculate deviation - for info in resultDict[dictIndex]: - info.tspDiff = info.syncTimeStamp - comparePic.syncTimeStamp - - dictIndex += 1 - - return resultDict - - -def safe_make_dir(path): - if not os.path.exists(path): - os.makedirs(path) - - -def handleSyncFrames(): - global resultPath - global sourceFramesPath - global streamProfileDict - - fp = open(f"{resultPath}/frameMatchLog.txt", "w") - - if not initProfileInfoDict(): - print("Initialize stream profile dictionary failed. exit") - return - print(f"Stream profiles: {streamProfileDict}") - streamProfileCount = len(streamProfileDict.items()) - - pictureInfoDict = {} - - initPictureInfoDictionary(Path(sourceFramesPath), pictureInfoDict) - if len(pictureInfoDict) <= 0: - print("init pictureInfoDict failed. pictureInfoDict.len = 0") - return - - # # Dump pictureInfoDict - # for key in pictureInfoDict: - # print("===================key:%s" % key) - # listTmp = list(pictureInfoDict[key]) - # for info in listTmp: - # print("=====================value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % (info.deviceId,info.sensorType,info.syncTimeStamp,info.picturePath)) - - deviceCount = getDeviceCount() - print("=================device count:%d" % deviceCount) - - resultDict = {} - resultDict = matchFrame(pictureInfoDict) - - for key in resultDict: - fp.write("===================result key:%s\n" % key) - print("===================result key:%s" % key) - listTmp = list(resultDict[key]) - for info in listTmp: - fp.write("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s\n" % ( - info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) - print("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % ( - info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) - - matchPath = f"{resultPath}/matchFrames/" - safe_make_dir(matchPath) - notMatchPath = f"{resultPath}/notMatchFrames/" - abnormalPath = f"{resultPath}/abnormal/" - - for key in resultDict: - listTmp = list(resultDict[key]) - if (len(listTmp) == (deviceCount * streamProfileCount)): - haveAbnormalData = False - for info in listTmp: - if info.tspDiff >= tspRangeThreshold: - path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + info.fileExt - shutil.copy(info.picturePath, path) - haveAbnormalData = True - else: - path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt - shutil.copy(info.picturePath, path) - - if haveAbnormalData: - safe_make_dir(abnormalPath) - for info in listTmp: - if info.tspDiff >= tspRangeThreshold: - path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + info.fileExt - shutil.copy(info.picturePath, path) - else: - path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt - shutil.copy(info.picturePath, path) - else: - safe_make_dir(notMatchPath) - for info in listTmp: - newFilePath = notMatchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt - shutil.copy(info.picturePath, newFilePath) - - -def main(): - if not initPrimaryId(): - print("Initialize primaryId failed. exit.") - return - - if not initSyncConfigParams(): - print("Initialized Sync config parameter failed. exit.") - return - - initResultDir() - - print(f"PrimaryId={primaryId}, frameRate={frameRate}, tspRangeThreshold={tspRangeThreshold}") - handleSyncFrames() - - return - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description="Synchronize frames support for 'Orbbec Astra2'") - parser.add_argument('frames_dir', type=str, help="Frames directory") - parser.add_argument('main_script_root_dir', type=str, help="SyncFramesMain.py working directory") - args = parser.parse_args() - - sourceRootPath = args.frames_dir - sourceFramesPath = f"{args.frames_dir}/TotalModeFrames" - mainPythonWorkPath = args.main_script_root_dir - print(f"Start of Astra2 synchronize frame. sourceRootPath={sourceRootPath}") - - main() - - print("Finish of Astra2 synchronize frame.") +import os.path +import argparse +import sys +import json +import shutil +import configparser + +from pathlib import Path +from datetime import datetime + +## Config.ini configuration +# Unit: FPS. Please fill in according to the actual dataset frame rate, +# otherwise it will cause inaccurate matching. +frameRate = -1 +# Unit: ms. When the timestamp range difference of a matched frame group +# is greater than or equal to tspRangeThreshold, the file name will be marked. +tspRangeThreshold = -1 + +## Parsed automatically by Python script, DO NOT modify +primaryId = '-1' # Host ID +mainPythonWorkPath = "" # Working directory of SyncFramesMain.py +sourceFramesPath = "" # DO NOT modify, fixed value, path to TotalMode directory +sourceRootPath = "" # Root directory containing TotalMode +resultPath = "" # Path to save sync analysis results +streamProfileDict = dict() # Store Python results + + +class PictureInfo(object): + class Struct(object): + def __init__(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt): + self.deviceId = deviceId + self.sensorType = sensorType + self.syncTimeStamp = syncTimeStamp + self.picturePath = picturePath + self.deviceIdFull = deviceIdFull + self.fileExt = fileExt + + def make_struct(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt): + return self.Struct(deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt) + + +class StreamProfileInfo: + def __init__(self, sensorType, width, height, format, fps): + self.sensorType = sensorType + self.width = width + self.height = height + self.format = format + self.fps = fps + + +def initPrimaryId(): + global primaryId + + deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" + if not os.path.exists(deviceInfoPath): + print(f"Initialize primaryId failed. {deviceInfoPath} not exists") + return False + + with open(deviceInfoPath, 'r') as f: + data = json.load(f) + + if not 'devices' in data: + print(f"Initialize primaryId failed. {deviceInfoPath} not contain item 'devices'") + return False + + for item in data['devices']: + if 'isPrimaryDevice' in item and 'index' in item and item['isPrimaryDevice']: + primaryId = str(item['index']) + return True + + return False + + +def initSyncConfigParams(): + global frameRate, tspRangeThreshold + + configPath = f"{mainPythonWorkPath}/Config.ini" + if not os.path.exists(configPath): + print(f"Initliaze synchronized config parameter failed. {configPath} not exists.") + return False + + # Create ConfigParser object + config = configparser.ConfigParser() + + # Read ini file + config.read(configPath, 'utf-8') + + if not config.has_option('Parameter', 'frameRate'): + print(f"Initliaze synchronized config parameter failed. Not define 'frameRate' in ${configPath}") + return False + + if not config.has_option('Parameter', 'tspRangeThreshold'): + print(f"Initliaze synchronized config parameter failed. Not define 'tspRangeThreshold' in ${configPath}") + return False + + frameRate = config.getfloat('Parameter', 'frameRate') + if frameRate <= 0 or frameRate >= 1000: + print(f"Initliaze synchronized config parameter failed. Invalid frameRate={frameRate}") + return False + + tspRangeThreshold = config.getfloat('Parameter', 'tspRangeThreshold') + if tspRangeThreshold <= 0: + print(f"Initliaze synchronized config parameter failed. Invalid tspRangeThreshold={tspRangeThreshold}") + return False + + return True + + +def getDeviceCount(): + deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" + if not os.path.exists(deviceInfoPath): + print(f"Get device count failed. {deviceInfoPath} not exists") + return 0 + + with open(deviceInfoPath, 'r') as f: + data = json.load(f) + + if not 'devices' in data: + print(f"Get device count failed. {deviceInfoPath} not contain item 'devices'") + return 0 + + return len(data['devices']) + + +def initProfileInfoDict(): + global streamProfileDict + + streamProfileDict = dict() + profilePath = f"{sourceRootPath}/StreamProfileInfo.txt" + if not os.path.exists(profilePath): + print(f"Initialize profile information dictionary failed. {profilePath} not exists") + return False + + with open(profilePath, 'r') as f: + data = json.load(f) + + if not 'streamProfiles' in data: + print(f"Initialize profile information dictionary failed. {profilePath} not contain item 'streamProfiles'") + return False + + for item in data['streamProfiles']: + if 'sensorType' in item and 'width' in item and 'height' in item and 'format' in item and 'fps' in item: + profileInfo = StreamProfileInfo(item['sensorType'], item['width'], item['height'], item['format'], item['fps']) + streamProfileDict.setdefault(item['sensorType'], profileInfo) + else: + print(f"Initialize profile information dictionary. Error invalid StreamProfile, {item}") + + return len(streamProfileDict.items()) > 0 + + +def initResultDir(): + global resultPath + timeText = datetime.now().strftime("%Y-%m-%d_%H%M%S") + resultPath = f"{sourceRootPath}/results-{timeText}" + if not os.path.exists(resultPath): + os.makedirs(resultPath) + + +def isFrameFile(fileName): + fileExt = os.path.splitext(fileName) + if len(fileExt) < 2: + return False + + frameExts = {".jpeg", ".jpg", ".png", ".raw", "bmp"} + return fileExt[1] in frameExts + + +def initPictureInfoDictionary(rootFilePath, pictureInfoDict): + frameFileCount = 0 + for dirpath, dirnames, filenames in os.walk(rootFilePath): + # print(f"dirpath={dirpath}, dirpath.basename=" + os.path.basename(dirpath)) + for fileName in filenames: + filePath = os.path.join(dirpath, fileName) + if not isFrameFile(fileName): + continue + + frameFileCount += 1 + fileNameNoExt = os.path.splitext(fileName)[0] + pictureNameList = fileNameNoExt.split('_') + deviceId = pictureNameList[2][5:] + sensorType = pictureNameList[0].replace('#', '_') + syncTimeStamp = int(pictureNameList[3][1:]) + + # Create struct + pictureInfo = PictureInfo() + info = pictureInfo.make_struct(deviceId, sensorType, syncTimeStamp, filePath, os.path.basename(dirpath), os.path.splitext(fileName)[1]) + + # Format dictionary: one key corresponds to one array + pictureInfoDict.setdefault(deviceId, []).append(info) + + if 0 == frameFileCount: + print("initialize pictureInfoDict failed. Not found frame file") + + +def matchFrame(pictureInfoDict): + global primaryId, frameRate + global streamProfileDict + + # Get comparison image array, take the Color array of the first device for comparison + compareList = [] + for key in pictureInfoDict: + listTmp = list(pictureInfoDict[key]) + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == 'color': + compareList.append(info) + + sorted_dict = dict(sorted(pictureInfoDict.items(), key=lambda x: x[1], reverse=False)) + pictureInfoDict = sorted_dict + + # Dynamically analyze based on stream opening status to reduce loop iterations + hasColorProfile = 'OB_SENSOR_COLOR' in streamProfileDict + hasDepthProfile = 'OB_SENSOR_DEPTH' in streamProfileDict + hasIRProfile = 'OB_SENSOR_IR' in streamProfileDict + + # Match adjacent frames + resultDict = {} + consumedList = [] + dictIndex = 0 + frameTspGap = int(1000.0/frameRate+0.5) + for comparePic in compareList: + resultDict.setdefault(dictIndex, []).append(comparePic) + for key in pictureInfoDict: + listTmp = list(pictureInfoDict[key]) + # Compare Color + if hasColorProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'color' and info.syncTimeStamp >= comparePic.syncTimeStamp and info.syncTimeStamp - comparePic.syncTimeStamp <= frameTspGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Compare Depth + if hasDepthProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'depth' and info.syncTimeStamp >= comparePic.syncTimeStamp and info.syncTimeStamp - comparePic.syncTimeStamp <= frameTspGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Compare IR + if hasIRProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'ir' and info.syncTimeStamp >= comparePic.syncTimeStamp and info.syncTimeStamp - comparePic.syncTimeStamp <= frameTspGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Calculate deviation + for info in resultDict[dictIndex]: + info.tspDiff = info.syncTimeStamp - comparePic.syncTimeStamp + + dictIndex += 1 + + return resultDict + + +def safe_make_dir(path): + if not os.path.exists(path): + os.makedirs(path) + + +def handleSyncFrames(): + global resultPath + global sourceFramesPath + global streamProfileDict + + fp = open(f"{resultPath}/frameMatchLog.txt", "w") + + if not initProfileInfoDict(): + print("Initialize stream profile dictionary failed. exit") + return + print(f"Stream profiles: {streamProfileDict}") + streamProfileCount = len(streamProfileDict.items()) + + pictureInfoDict = {} + + initPictureInfoDictionary(Path(sourceFramesPath), pictureInfoDict) + if len(pictureInfoDict) <= 0: + print("init pictureInfoDict failed. pictureInfoDict.len = 0") + return + + # # Dump pictureInfoDict + # for key in pictureInfoDict: + # print("===================key:%s" % key) + # listTmp = list(pictureInfoDict[key]) + # for info in listTmp: + # print("=====================value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % (info.deviceId,info.sensorType,info.syncTimeStamp,info.picturePath)) + + deviceCount = getDeviceCount() + print("=================device count:%d" % deviceCount) + + resultDict = {} + resultDict = matchFrame(pictureInfoDict) + + for key in resultDict: + fp.write("===================result key:%s\n" % key) + print("===================result key:%s" % key) + listTmp = list(resultDict[key]) + for info in listTmp: + fp.write("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s\n" % ( + info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) + print("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % ( + info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) + + matchPath = f"{resultPath}/matchFrames/" + safe_make_dir(matchPath) + notMatchPath = f"{resultPath}/notMatchFrames/" + abnormalPath = f"{resultPath}/abnormal/" + + for key in resultDict: + listTmp = list(resultDict[key]) + if (len(listTmp) == (deviceCount * streamProfileCount)): + haveAbnormalData = False + for info in listTmp: + if info.tspDiff >= tspRangeThreshold: + path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + info.fileExt + shutil.copy(info.picturePath, path) + haveAbnormalData = True + else: + path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt + shutil.copy(info.picturePath, path) + + if haveAbnormalData: + safe_make_dir(abnormalPath) + for info in listTmp: + if info.tspDiff >= tspRangeThreshold: + path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + info.fileExt + shutil.copy(info.picturePath, path) + else: + path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt + shutil.copy(info.picturePath, path) + else: + safe_make_dir(notMatchPath) + for info in listTmp: + newFilePath = notMatchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt + shutil.copy(info.picturePath, newFilePath) + + +def main(): + if not initPrimaryId(): + print("Initialize primaryId failed. exit.") + return + + if not initSyncConfigParams(): + print("Initialized Sync config parameter failed. exit.") + return + + initResultDir() + + print(f"PrimaryId={primaryId}, frameRate={frameRate}, tspRangeThreshold={tspRangeThreshold}") + handleSyncFrames() + + return + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description="Synchronize frames support for 'Orbbec Astra2'") + parser.add_argument('frames_dir', type=str, help="Frames directory") + parser.add_argument('main_script_root_dir', type=str, help="SyncFramesMain.py working directory") + args = parser.parse_args() + + sourceRootPath = args.frames_dir + sourceFramesPath = f"{args.frames_dir}/TotalModeFrames" + mainPythonWorkPath = args.main_script_root_dir + print(f"Start of Astra2 synchronize frame. sourceRootPath={sourceRootPath}") + + main() + + print("Finish of Astra2 synchronize frame.") diff --git a/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch-systemTimestamp.py b/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch-systemTimestamp.py index 302917cb..7bec6097 100644 --- a/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch-systemTimestamp.py +++ b/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch-systemTimestamp.py @@ -1,403 +1,403 @@ -import os.path -import argparse -import sys -import json -import shutil -import configparser - -from pathlib import Path -from datetime import datetime - -## Config.ini configuration -# Unit: FPS. Please fill in according to the actual dataset frame rate, -# otherwise it will cause inaccurate matching. -frameRate = -1 -# Unit: ms. When the timestamp range difference of a matched frame group -# is greater than or equal to tspRangeThreshold, the file name will be marked. -tspRangeThreshold = -1 - -## Parsed automatically by Python script, DO NOT modify -primaryId = '-1' # Host ID -mainPythonWorkPath = "" # Working directory of SyncFramesMain.py -sourceFramesPath = "" # DO NOT modify, fixed value, path to TotalMode directory -sourceRootPath = "" # Root directory containing TotalMode -resultPath = "" # Path to save sync analysis results -streamProfileDict = dict() # Store Python results - -class PictureInfo(object): - class Struct(object): - def __init__(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt): - self.deviceId = deviceId - self.sensorType = sensorType - self.syncTimeStamp = syncTimeStamp - self.picturePath = picturePath - self.deviceIdFull = deviceIdFull - self.fileExt = fileExt - - def make_struct(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt): - return self.Struct(deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt) - -class StreamProfileInfo: - def __init__(self, sensorType, width, height, format, fps): - self.sensorType = sensorType - self.width = width - self.height = height - self.format = format - self.fps = fps - -def initPrimaryId(): - global primaryId - - deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" - if not os.path.exists(deviceInfoPath): - print(f"Initialize primaryId failed. {deviceInfoPath} not exists") - return False - - with open(deviceInfoPath, 'r') as f: - data = json.load(f) - - if not 'devices' in data: - print(f"Initialize primaryId failed. {deviceInfoPath} not contain item 'devices'") - return False - - for item in data['devices']: - if 'isPrimaryDevice' in item and 'index' in item and item['isPrimaryDevice']: - primaryId = str(item['index']) - return True - - return False - -def initSyncConfigParams(): - global frameRate, tspRangeThreshold - - configPath = f"{mainPythonWorkPath}/Config.ini" - if not os.path.exists(configPath): - print(f"Initliaze synchronized config parameter failed. {configPath} not exists.") - return False - - # Create ConfigParser object - config = configparser.ConfigParser() - - # Read ini file - config.read(configPath, 'utf-8') - - if not config.has_option('Parameter', 'frameRate'): - print(f"Initliaze synchronized config parameter failed. Not define 'frameRate' in ${configPath}") - return False - - if not config.has_option('Parameter', 'tspRangeThreshold'): - print(f"Initliaze synchronized config parameter failed. Not define 'tspRangeThreshold' in ${configPath}") - return False - - frameRate = config.getfloat('Parameter', 'frameRate') - if frameRate <= 0 or frameRate >= 1000: - print(f"Initliaze synchronized config parameter failed. Invalid frameRate={frameRate}") - return False - - tspRangeThreshold = config.getfloat('Parameter', 'tspRangeThreshold') - if tspRangeThreshold <= 0: - print(f"Initliaze synchronized config parameter failed. Invalid tspRangeThreshold={tspRangeThreshold}") - return False - - return True - -def getDeviceCount(): - deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" - if not os.path.exists(deviceInfoPath): - print(f"Get device count failed. {deviceInfoPath} not exists") - return 0 - - with open(deviceInfoPath, 'r') as f: - data = json.load(f) - - if not 'devices' in data: - print(f"Get device count failed. {deviceInfoPath} not contain item 'devices'") - return 0 - - return len(data['devices']) - -def initProfileInfoDict(): - global streamProfileDict - - streamProfileDict = dict() - profilePath = f"{sourceRootPath}/StreamProfileInfo.txt" - if not os.path.exists(profilePath): - print(f"Initialize profile information dictionary failed. {profilePath} not exists") - return False - - with open(profilePath, 'r') as f: - data = json.load(f) - - if not 'streamProfiles' in data: - print(f"Initialize profile information dictionary failed. {profilePath} not contain item 'streamProfiles'") - return False - - for item in data['streamProfiles']: - if 'sensorType' in item and 'width' in item and 'height' in item and 'format' in item and 'fps' in item: - profileInfo = StreamProfileInfo(item['sensorType'], item['width'], item['height'], item['format'], item['fps']) - streamProfileDict.setdefault(item['sensorType'], profileInfo) - else: - print(f"Initialize profile information dictionary. Error invalid StreamProfile, {item}") - - return len(streamProfileDict.items()) > 0 - -def initResultDir(): - global resultPath - timeText = datetime.now().strftime("%Y-%m-%d_%H%M%S") - resultPath = f"{sourceRootPath}/results-{timeText}" - if not os.path.exists(resultPath): - os.makedirs(resultPath) - -def isFrameFile(fileName): - fileExt = os.path.splitext(fileName) - if len(fileExt) < 2: - return False - - frameExts = {".jpeg", ".jpg", ".png", ".raw", "bmp"} - return fileExt[1] in frameExts - -def initPictureInfoDictionary(rootFilePath, pictureInfoDict): - frameFileCount = 0 - for dirpath, dirnames, filenames in os.walk(rootFilePath): - # print(f"dirpath={dirpath}, dirpath.basename=" + os.path.basename(dirpath)) - for fileName in filenames: - filePath = os.path.join(dirpath, fileName) - if not isFrameFile(fileName): - continue - - frameFileCount += 1 - fileNameNoExt = os.path.splitext(fileName)[0] - pictureNameList = fileNameNoExt.split('_') - deviceId = pictureNameList[2][5:] - sensorType = pictureNameList[0].replace('#', '_') - syncTimeStamp = int(pictureNameList[5][1:]) - - # Create struct - pictureInfo = PictureInfo() - info = pictureInfo.make_struct(deviceId, sensorType, syncTimeStamp, filePath, os.path.basename(dirpath), os.path.splitext(fileName)[1]) - - # Format dictionary: one key corresponds to one array - pictureInfoDict.setdefault(deviceId, []).append(info) - - if 0 == frameFileCount: - print("initialize pictureInfoDict failed. Not found frame file") - - -def matchFrame(pictureInfoDict): - global primaryId, frameRate - global streamProfileDict - - # Get comparison image array, take the Color array of the first device for comparison - compareList = [] - for key in pictureInfoDict: - listTmp = list(pictureInfoDict[key]) - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == 'color': - compareList.append(info) - - # Dynamically analyze based on stream opening status to reduce loop iterations - hasColorProfile = 'OB_SENSOR_COLOR' in streamProfileDict - hasDepthProfile = 'OB_SENSOR_DEPTH' in streamProfileDict - hasIRProfile = 'OB_SENSOR_IR' in streamProfileDict - hasIRLeftProfile = 'OB_SENSOR_IR_LEFT' in streamProfileDict - hasIRRightProfile = 'OB_SENSOR_IR_RIGHT' in streamProfileDict - - # Match adjacent frames - resultDict = {} - consumedList = [] - dictIndex = 0 - frameTspHalfGap = int(1000.0/frameRate/2.0+0.5) - for comparePic in compareList: - resultDict.setdefault(dictIndex, []).append(comparePic) - for key in pictureInfoDict: - listTmp = list(pictureInfoDict[key]) - # Compare Color - if hasColorProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'color' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Compare Depth - if hasDepthProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'depth' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # IR - if hasIRProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'ir' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Left IR - if hasIRLeftProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'ir_left' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Right IR - if hasIRRightProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'ir_right' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Calculate deviation - minTsp = min(resultDict[dictIndex], key=lambda x: x.syncTimeStamp) - for info in resultDict[dictIndex]: - info.tspDiff = info.syncTimeStamp - minTsp.syncTimeStamp - - dictIndex += 1 - - return resultDict - - -def safe_make_dir(path): - if not os.path.exists(path): - os.makedirs(path) - - -def handleSyncFrames(): - global resultPath - global sourceFramesPath - global streamProfileDict - - fp = open(f"{resultPath}/frameMatchLog.txt", "w") - - if not initProfileInfoDict(): - print("Initialize stream profile dictionary failed. exit") - return - print(f"Stream profiles: {streamProfileDict}") - streamProfileCount = len(streamProfileDict.items()) - - pictureInfoDict = {} - - initPictureInfoDictionary(Path(sourceFramesPath), pictureInfoDict) - if len(pictureInfoDict) <= 0: - print("init pictureInfoDict failed. pictureInfoDict.len = 0") - return - - deviceCount = getDeviceCount() - print("=================device count:%d" % deviceCount) - - resultDict = {} - resultDict = matchFrame(pictureInfoDict) - - for key in resultDict: - fp.write("===================result key:%s\n" % key) - print("===================result key:%s" % key) - listTmp = list(resultDict[key]) - for info in listTmp: - fp.write("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s\n" % ( - info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) - print("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % ( - info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) - - matchPath = f"{resultPath}/matchFrames/" - safe_make_dir(matchPath) - notMatchPath = f"{resultPath}/notMatchFrames/" - abnormalPath = f"{resultPath}/abnormal/" - - for key in resultDict: - listTmp = list(resultDict[key]) - if (len(listTmp) == (deviceCount * streamProfileCount)): - haveAbnormalData = False - for info in listTmp: - if info.tspDiff >= tspRangeThreshold: - path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + info.fileExt - shutil.copy(info.picturePath, path) - haveAbnormalData = True - else: - path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt - shutil.copy(info.picturePath, path) - - if haveAbnormalData: - safe_make_dir(abnormalPath) - for info in listTmp: - if info.tspDiff >= tspRangeThreshold: - path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + info.fileExt - shutil.copy(info.picturePath, path) - else: - path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt - shutil.copy(info.picturePath, path) - else: - safe_make_dir(notMatchPath) - for info in listTmp: - newFilePath = notMatchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt - shutil.copy(info.picturePath, newFilePath) - -def main(): - if not initPrimaryId(): - print("Initialize primaryId failed. exit.") - return - - if not initSyncConfigParams(): - print("Initialized Sync config parameter failed. exit.") - return - - initResultDir() - - print(f"PrimaryId={primaryId}, frameRate={frameRate}, tspRangeThreshold={tspRangeThreshold}") - handleSyncFrames() - - return - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description="Synchronize frames support for 'Orbbec Gemini 2'") - parser.add_argument('frames_dir', type=str, help="Frames directory") - parser.add_argument('main_script_root_dir', type=str, help="SyncFramesMain.py working directory") - args = parser.parse_args() - - sourceRootPath = args.frames_dir - sourceFramesPath = f"{args.frames_dir}/TotalModeFrames" - mainPythonWorkPath = args.main_script_root_dir - print(f"Start of Gemini2 synchronize frame. sourceRootPath={sourceRootPath}") - - main() - - print("Finish of Gemini2 synchronize frame.") +import os.path +import argparse +import sys +import json +import shutil +import configparser + +from pathlib import Path +from datetime import datetime + +## Config.ini configuration +# Unit: FPS. Please fill in according to the actual dataset frame rate, +# otherwise it will cause inaccurate matching. +frameRate = -1 +# Unit: ms. When the timestamp range difference of a matched frame group +# is greater than or equal to tspRangeThreshold, the file name will be marked. +tspRangeThreshold = -1 + +## Parsed automatically by Python script, DO NOT modify +primaryId = '-1' # Host ID +mainPythonWorkPath = "" # Working directory of SyncFramesMain.py +sourceFramesPath = "" # DO NOT modify, fixed value, path to TotalMode directory +sourceRootPath = "" # Root directory containing TotalMode +resultPath = "" # Path to save sync analysis results +streamProfileDict = dict() # Store Python results + +class PictureInfo(object): + class Struct(object): + def __init__(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt): + self.deviceId = deviceId + self.sensorType = sensorType + self.syncTimeStamp = syncTimeStamp + self.picturePath = picturePath + self.deviceIdFull = deviceIdFull + self.fileExt = fileExt + + def make_struct(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt): + return self.Struct(deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt) + +class StreamProfileInfo: + def __init__(self, sensorType, width, height, format, fps): + self.sensorType = sensorType + self.width = width + self.height = height + self.format = format + self.fps = fps + +def initPrimaryId(): + global primaryId + + deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" + if not os.path.exists(deviceInfoPath): + print(f"Initialize primaryId failed. {deviceInfoPath} not exists") + return False + + with open(deviceInfoPath, 'r') as f: + data = json.load(f) + + if not 'devices' in data: + print(f"Initialize primaryId failed. {deviceInfoPath} not contain item 'devices'") + return False + + for item in data['devices']: + if 'isPrimaryDevice' in item and 'index' in item and item['isPrimaryDevice']: + primaryId = str(item['index']) + return True + + return False + +def initSyncConfigParams(): + global frameRate, tspRangeThreshold + + configPath = f"{mainPythonWorkPath}/Config.ini" + if not os.path.exists(configPath): + print(f"Initliaze synchronized config parameter failed. {configPath} not exists.") + return False + + # Create ConfigParser object + config = configparser.ConfigParser() + + # Read ini file + config.read(configPath, 'utf-8') + + if not config.has_option('Parameter', 'frameRate'): + print(f"Initliaze synchronized config parameter failed. Not define 'frameRate' in ${configPath}") + return False + + if not config.has_option('Parameter', 'tspRangeThreshold'): + print(f"Initliaze synchronized config parameter failed. Not define 'tspRangeThreshold' in ${configPath}") + return False + + frameRate = config.getfloat('Parameter', 'frameRate') + if frameRate <= 0 or frameRate >= 1000: + print(f"Initliaze synchronized config parameter failed. Invalid frameRate={frameRate}") + return False + + tspRangeThreshold = config.getfloat('Parameter', 'tspRangeThreshold') + if tspRangeThreshold <= 0: + print(f"Initliaze synchronized config parameter failed. Invalid tspRangeThreshold={tspRangeThreshold}") + return False + + return True + +def getDeviceCount(): + deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" + if not os.path.exists(deviceInfoPath): + print(f"Get device count failed. {deviceInfoPath} not exists") + return 0 + + with open(deviceInfoPath, 'r') as f: + data = json.load(f) + + if not 'devices' in data: + print(f"Get device count failed. {deviceInfoPath} not contain item 'devices'") + return 0 + + return len(data['devices']) + +def initProfileInfoDict(): + global streamProfileDict + + streamProfileDict = dict() + profilePath = f"{sourceRootPath}/StreamProfileInfo.txt" + if not os.path.exists(profilePath): + print(f"Initialize profile information dictionary failed. {profilePath} not exists") + return False + + with open(profilePath, 'r') as f: + data = json.load(f) + + if not 'streamProfiles' in data: + print(f"Initialize profile information dictionary failed. {profilePath} not contain item 'streamProfiles'") + return False + + for item in data['streamProfiles']: + if 'sensorType' in item and 'width' in item and 'height' in item and 'format' in item and 'fps' in item: + profileInfo = StreamProfileInfo(item['sensorType'], item['width'], item['height'], item['format'], item['fps']) + streamProfileDict.setdefault(item['sensorType'], profileInfo) + else: + print(f"Initialize profile information dictionary. Error invalid StreamProfile, {item}") + + return len(streamProfileDict.items()) > 0 + +def initResultDir(): + global resultPath + timeText = datetime.now().strftime("%Y-%m-%d_%H%M%S") + resultPath = f"{sourceRootPath}/results-{timeText}" + if not os.path.exists(resultPath): + os.makedirs(resultPath) + +def isFrameFile(fileName): + fileExt = os.path.splitext(fileName) + if len(fileExt) < 2: + return False + + frameExts = {".jpeg", ".jpg", ".png", ".raw", "bmp"} + return fileExt[1] in frameExts + +def initPictureInfoDictionary(rootFilePath, pictureInfoDict): + frameFileCount = 0 + for dirpath, dirnames, filenames in os.walk(rootFilePath): + # print(f"dirpath={dirpath}, dirpath.basename=" + os.path.basename(dirpath)) + for fileName in filenames: + filePath = os.path.join(dirpath, fileName) + if not isFrameFile(fileName): + continue + + frameFileCount += 1 + fileNameNoExt = os.path.splitext(fileName)[0] + pictureNameList = fileNameNoExt.split('_') + deviceId = pictureNameList[2][5:] + sensorType = pictureNameList[0].replace('#', '_') + syncTimeStamp = int(pictureNameList[5][1:]) + + # Create struct + pictureInfo = PictureInfo() + info = pictureInfo.make_struct(deviceId, sensorType, syncTimeStamp, filePath, os.path.basename(dirpath), os.path.splitext(fileName)[1]) + + # Format dictionary: one key corresponds to one array + pictureInfoDict.setdefault(deviceId, []).append(info) + + if 0 == frameFileCount: + print("initialize pictureInfoDict failed. Not found frame file") + + +def matchFrame(pictureInfoDict): + global primaryId, frameRate + global streamProfileDict + + # Get comparison image array, take the Color array of the first device for comparison + compareList = [] + for key in pictureInfoDict: + listTmp = list(pictureInfoDict[key]) + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == 'color': + compareList.append(info) + + # Dynamically analyze based on stream opening status to reduce loop iterations + hasColorProfile = 'OB_SENSOR_COLOR' in streamProfileDict + hasDepthProfile = 'OB_SENSOR_DEPTH' in streamProfileDict + hasIRProfile = 'OB_SENSOR_IR' in streamProfileDict + hasIRLeftProfile = 'OB_SENSOR_IR_LEFT' in streamProfileDict + hasIRRightProfile = 'OB_SENSOR_IR_RIGHT' in streamProfileDict + + # Match adjacent frames + resultDict = {} + consumedList = [] + dictIndex = 0 + frameTspHalfGap = int(1000.0/frameRate/2.0+0.5) + for comparePic in compareList: + resultDict.setdefault(dictIndex, []).append(comparePic) + for key in pictureInfoDict: + listTmp = list(pictureInfoDict[key]) + # Compare Color + if hasColorProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'color' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Compare Depth + if hasDepthProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'depth' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # IR + if hasIRProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'ir' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Left IR + if hasIRLeftProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'ir_left' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Right IR + if hasIRRightProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'ir_right' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Calculate deviation + minTsp = min(resultDict[dictIndex], key=lambda x: x.syncTimeStamp) + for info in resultDict[dictIndex]: + info.tspDiff = info.syncTimeStamp - minTsp.syncTimeStamp + + dictIndex += 1 + + return resultDict + + +def safe_make_dir(path): + if not os.path.exists(path): + os.makedirs(path) + + +def handleSyncFrames(): + global resultPath + global sourceFramesPath + global streamProfileDict + + fp = open(f"{resultPath}/frameMatchLog.txt", "w") + + if not initProfileInfoDict(): + print("Initialize stream profile dictionary failed. exit") + return + print(f"Stream profiles: {streamProfileDict}") + streamProfileCount = len(streamProfileDict.items()) + + pictureInfoDict = {} + + initPictureInfoDictionary(Path(sourceFramesPath), pictureInfoDict) + if len(pictureInfoDict) <= 0: + print("init pictureInfoDict failed. pictureInfoDict.len = 0") + return + + deviceCount = getDeviceCount() + print("=================device count:%d" % deviceCount) + + resultDict = {} + resultDict = matchFrame(pictureInfoDict) + + for key in resultDict: + fp.write("===================result key:%s\n" % key) + print("===================result key:%s" % key) + listTmp = list(resultDict[key]) + for info in listTmp: + fp.write("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s\n" % ( + info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) + print("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % ( + info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) + + matchPath = f"{resultPath}/matchFrames/" + safe_make_dir(matchPath) + notMatchPath = f"{resultPath}/notMatchFrames/" + abnormalPath = f"{resultPath}/abnormal/" + + for key in resultDict: + listTmp = list(resultDict[key]) + if (len(listTmp) == (deviceCount * streamProfileCount)): + haveAbnormalData = False + for info in listTmp: + if info.tspDiff >= tspRangeThreshold: + path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + info.fileExt + shutil.copy(info.picturePath, path) + haveAbnormalData = True + else: + path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt + shutil.copy(info.picturePath, path) + + if haveAbnormalData: + safe_make_dir(abnormalPath) + for info in listTmp: + if info.tspDiff >= tspRangeThreshold: + path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + info.fileExt + shutil.copy(info.picturePath, path) + else: + path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt + shutil.copy(info.picturePath, path) + else: + safe_make_dir(notMatchPath) + for info in listTmp: + newFilePath = notMatchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt + shutil.copy(info.picturePath, newFilePath) + +def main(): + if not initPrimaryId(): + print("Initialize primaryId failed. exit.") + return + + if not initSyncConfigParams(): + print("Initialized Sync config parameter failed. exit.") + return + + initResultDir() + + print(f"PrimaryId={primaryId}, frameRate={frameRate}, tspRangeThreshold={tspRangeThreshold}") + handleSyncFrames() + + return + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description="Synchronize frames support for 'Orbbec Gemini 2'") + parser.add_argument('frames_dir', type=str, help="Frames directory") + parser.add_argument('main_script_root_dir', type=str, help="SyncFramesMain.py working directory") + args = parser.parse_args() + + sourceRootPath = args.frames_dir + sourceFramesPath = f"{args.frames_dir}/TotalModeFrames" + mainPythonWorkPath = args.main_script_root_dir + print(f"Start of Gemini2 synchronize frame. sourceRootPath={sourceRootPath}") + + main() + + print("Finish of Gemini2 synchronize frame.") diff --git a/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch.py b/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch.py index 9b89a655..8d32f384 100644 --- a/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch.py +++ b/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch.py @@ -1,425 +1,425 @@ -import os.path -import argparse -import sys -import json -import shutil -import configparser - -from pathlib import Path -from datetime import datetime - -import os -import re - -## Config.ini configuration -# Unit: FPS. Please fill in according to the actual dataset frame rate, -# otherwise it will cause inaccurate matching. -frameRate = -1 -# Unit: ms. When the timestamp range difference of a matched frame group -# is greater than or equal to tspRangeThreshold, the file name will be marked. -tspRangeThreshold = -1 - -## Parsed automatically by Python script, DO NOT modify -primaryId = '-1' # Host ID -mainPythonWorkPath = "" # Working directory of SyncFramesMain.py -sourceFramesPath = "" # DO NOT modify, fixed value, path to TotalMode directory -sourceRootPath = "" # Root directory containing TotalMode -resultPath = "" # Path to save sync analysis results -streamProfileDict = dict() # Store Python results - -class PictureInfo(object): - class Struct(object): - def __init__(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt): - self.deviceId = deviceId - self.sensorType = sensorType - self.syncTimeStamp = syncTimeStamp - self.picturePath = picturePath - self.deviceIdFull = deviceIdFull - self.fileExt = fileExt - - def make_struct(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt): - return self.Struct(deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt) - -class StreamProfileInfo: - def __init__(self, sensorType, width, height, format, fps): - self.sensorType = sensorType - self.width = width - self.height = height - self.format = format - self.fps = fps - -def initPrimaryId(): - global primaryId - - deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" - if not os.path.exists(deviceInfoPath): - print(f"Initialize primaryId failed. {deviceInfoPath} not exists") - return False - - with open(deviceInfoPath, 'r') as f: - data = json.load(f) - - if not 'devices' in data: - print(f"Initialize primaryId failed. {deviceInfoPath} not contain item 'devices'") - return False - - for item in data['devices']: - if 'isPrimaryDevice' in item and 'index' in item and item['isPrimaryDevice']: - primaryId = str(item['index']) - return True - - return False - -def initSyncConfigParams(): - global frameRate, tspRangeThreshold - - configPath = f"{mainPythonWorkPath}/Config.ini" - if not os.path.exists(configPath): - print(f"Initliaze synchronized config parameter failed. {configPath} not exists.") - return False - - # Create ConfigParser object - config = configparser.ConfigParser() - - # Read ini file - config.read(configPath, 'utf-8') - - if not config.has_option('Parameter', 'frameRate'): - print(f"Initliaze synchronized config parameter failed. Not define 'frameRate' in ${configPath}") - return False - - if not config.has_option('Parameter', 'tspRangeThreshold'): - print(f"Initliaze synchronized config parameter failed. Not define 'tspRangeThreshold' in ${configPath}") - return False - - frameRate = config.getfloat('Parameter', 'frameRate') - if frameRate <= 0 or frameRate >= 1000: - print(f"Initliaze synchronized config parameter failed. Invalid frameRate={frameRate}") - return False - - tspRangeThreshold = config.getfloat('Parameter', 'tspRangeThreshold') - if tspRangeThreshold <= 0: - print(f"Initliaze synchronized config parameter failed. Invalid tspRangeThreshold={tspRangeThreshold}") - return False - - return True - -def getDeviceCount(): - deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" - if not os.path.exists(deviceInfoPath): - print(f"Get device count failed. {deviceInfoPath} not exists") - return 0 - - with open(deviceInfoPath, 'r') as f: - data = json.load(f) - - if not 'devices' in data: - print(f"Get device count failed. {deviceInfoPath} not contain item 'devices'") - return 0 - - return len(data['devices']) - -def initProfileInfoDict(): - global streamProfileDict - - streamProfileDict = dict() - profilePath = f"{sourceRootPath}/StreamProfileInfo.txt" - if not os.path.exists(profilePath): - print(f"Initialize profile information dictionary failed. {profilePath} not exists") - return False - - with open(profilePath, 'r') as f: - data = json.load(f) - - if not 'streamProfiles' in data: - print(f"Initialize profile information dictionary failed. {profilePath} not contain item 'streamProfiles'") - return False - - for item in data['streamProfiles']: - if 'sensorType' in item and 'width' in item and 'height' in item and 'format' in item and 'fps' in item: - profileInfo = StreamProfileInfo(item['sensorType'], item['width'], item['height'], item['format'], item['fps']) - streamProfileDict.setdefault(item['sensorType'], profileInfo) - else: - print(f"Initialize profile information dictionary. Error invalid StreamProfile, {item}") - - return len(streamProfileDict.items()) > 0 - -def initResultDir(): - global resultPath - timeText = datetime.now().strftime("%Y-%m-%d_%H%M%S") - resultPath = f"{sourceRootPath}/results-{timeText}" - if not os.path.exists(resultPath): - os.makedirs(resultPath) - -def isFrameFile(fileName): - fileExt = os.path.splitext(fileName) - if len(fileExt) < 2: - return False - - frameExts = {".jpeg", ".jpg", ".png", ".raw", "bmp"} - return fileExt[1] in frameExts - -def extract_number(filename): - """Extract the numeric part after 'g' in the filename""" - match_g = re.search(r'g(\d+)', filename) - if match_g: - return int(match_g.group(1)) - - """Extract the numeric part after 'd' in the filename""" - match_d = re.search(r'd(\d+)', filename) - if match_d: - return int(match_d.group(1)) - return float('inf') - -def initPictureInfoDictionary(rootFilePath, pictureInfoDict): - frameFileCount = 0 - for dirpath, dirnames, filenames in os.walk(rootFilePath): - filenames.sort(key=extract_number) # Sort filenames by the numeric part after 'd' and 'g' - for fileName in filenames: - filePath = os.path.join(dirpath, fileName) - if not isFrameFile(fileName): - continue - - frameFileCount += 1 - fileNameNoExt = os.path.splitext(fileName)[0] - pictureNameList = fileNameNoExt.split('_') - deviceId = pictureNameList[2][5:] - sensorType = pictureNameList[0].replace('#', '_') - syncTimeStamp = int(pictureNameList[3][1:]) - - # Create struct - pictureInfo = PictureInfo() - info = pictureInfo.make_struct(deviceId, sensorType, syncTimeStamp, filePath, os.path.basename(dirpath), os.path.splitext(fileName)[1]) - - # Format dictionary: one key corresponds to one array - pictureInfoDict.setdefault(deviceId, []).append(info) - - if 0 == frameFileCount: - print("initialize pictureInfoDict failed. Not found frame file") - - -def matchFrame(pictureInfoDict): - global primaryId, frameRate - global streamProfileDict - - # Get comparison image array, use the Color array of the first device for comparison - compareList = [] - for key in pictureInfoDict: - listTmp = list(pictureInfoDict[key]) - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == 'color': - compareList.append(info) - - # Dynamically analyze based on stream opening status to reduce loop iterations - hasColorProfile = 'OB_SENSOR_COLOR' in streamProfileDict - hasDepthProfile = 'OB_SENSOR_DEPTH' in streamProfileDict - hasIRProfile = 'OB_SENSOR_IR' in streamProfileDict - hasIRLeftProfile = 'OB_SENSOR_IR_LEFT' in streamProfileDict - hasIRRightProfile = 'OB_SENSOR_IR_RIGHT' in streamProfileDict - - # Match adjacent frames - resultDict = {} - consumedList = [] - dictIndex = 0 - frameTspHalfGap = int(1000.0/frameRate/2.0+0.5) - for comparePic in compareList: - resultDict.setdefault(dictIndex, []).append(comparePic) - for key in pictureInfoDict: - listTmp = list(pictureInfoDict[key]) - # Compare color - if hasColorProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'color' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Compare depth - if hasDepthProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'depth' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Compare IR - if hasIRProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'ir' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Compare left IR - if hasIRLeftProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'ir_left' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Compare right IR - if hasIRRightProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'ir_right' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Calculate deviation - minTsp = min(resultDict[dictIndex], key=lambda x: x.syncTimeStamp) - for info in resultDict[dictIndex]: - info.tspDiff = info.syncTimeStamp - minTsp.syncTimeStamp - - dictIndex += 1 - - return resultDict - - -def safe_make_dir(path): - if not os.path.exists(path): - os.makedirs(path) - - -def handleSyncFrames(): - global resultPath - global sourceFramesPath - global streamProfileDict - - fp = open(f"{resultPath}/frameMatchLog.txt", "w") - - if not initProfileInfoDict(): - print("Initialize stream profile dictionary failed. exit") - return - print(f"Stream profiles: {streamProfileDict}") - streamProfileCount = len(streamProfileDict.items()) - - pictureInfoDict = {} - - initPictureInfoDictionary(Path(sourceFramesPath), pictureInfoDict) - if len(pictureInfoDict) <= 0: - print("init pictureInfoDict failed. pictureInfoDict.len = 0") - return - - # # Dump pictureInfoDict - # for key in pictureInfoDict: - # print("===================key:%s" % key) - # listTmp = list(pictureInfoDict[key]) - # for info in listTmp: - # print("=====================value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % (info.deviceId,info.sensorType,info.syncTimeStamp,info.picturePath)) - - deviceCount = getDeviceCount() - print("=================device count:%d" % deviceCount) - - resultDict = {} - resultDict = matchFrame(pictureInfoDict) - - for key in resultDict: - fp.write("===================result key:%s\n" % key) - print("===================result key:%s" % key) - listTmp = list(resultDict[key]) - for info in listTmp: - fp.write("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s\n" % ( - info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) - print("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % ( - info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) - - matchPath = f"{resultPath}/matchFrames/" - safe_make_dir(matchPath) - notMatchPath = f"{resultPath}/notMatchFrames/" - abnormalPath = f"{resultPath}/abnormal/" - - for key in resultDict: - listTmp = list(resultDict[key]) - if (len(listTmp) == (deviceCount * streamProfileCount)): - haveAbnormalData = False - for info in listTmp: - if info.tspDiff >= tspRangeThreshold: - path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + info.fileExt - shutil.copy(info.picturePath, path) - haveAbnormalData = True - else: - path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt - shutil.copy(info.picturePath, path) - - if haveAbnormalData: - safe_make_dir(abnormalPath) - for info in listTmp: - if info.tspDiff >= tspRangeThreshold: - path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + info.fileExt - shutil.copy(info.picturePath, path) - else: - path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt - shutil.copy(info.picturePath, path) - else: - safe_make_dir(notMatchPath) - for info in listTmp: - newFilePath = notMatchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt - shutil.copy(info.picturePath, newFilePath) - -def main(): - if not initPrimaryId(): - print("Initialize primaryId failed. exit.") - return - - if not initSyncConfigParams(): - print("Initialized Sync config parameter failed. exit.") - return - - initResultDir() - - print(f"PrimaryId={primaryId}, frameRate={frameRate}, tspRangeThreshold={tspRangeThreshold}") - handleSyncFrames() - - return - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description="Synchronize frames support for 'Orbbec Devices'") - parser.add_argument('frames_dir', type=str, help="Frames directory") - parser.add_argument('main_script_root_dir', type=str, help="SyncFramesMain.py working directory") - args = parser.parse_args() - - sourceRootPath = args.frames_dir - sourceFramesPath = f"{args.frames_dir}/TotalModeFrames" - mainPythonWorkPath = args.main_script_root_dir - print(f"Start of CommonFrameMatch synchronize frame. sourceRootPath={sourceRootPath}") - - main() - - print("Finish of CommonFrameMatch synchronize frame.") +import os.path +import argparse +import sys +import json +import shutil +import configparser + +from pathlib import Path +from datetime import datetime + +import os +import re + +## Config.ini configuration +# Unit: FPS. Please fill in according to the actual dataset frame rate, +# otherwise it will cause inaccurate matching. +frameRate = -1 +# Unit: ms. When the timestamp range difference of a matched frame group +# is greater than or equal to tspRangeThreshold, the file name will be marked. +tspRangeThreshold = -1 + +## Parsed automatically by Python script, DO NOT modify +primaryId = '-1' # Host ID +mainPythonWorkPath = "" # Working directory of SyncFramesMain.py +sourceFramesPath = "" # DO NOT modify, fixed value, path to TotalMode directory +sourceRootPath = "" # Root directory containing TotalMode +resultPath = "" # Path to save sync analysis results +streamProfileDict = dict() # Store Python results + +class PictureInfo(object): + class Struct(object): + def __init__(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt): + self.deviceId = deviceId + self.sensorType = sensorType + self.syncTimeStamp = syncTimeStamp + self.picturePath = picturePath + self.deviceIdFull = deviceIdFull + self.fileExt = fileExt + + def make_struct(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt): + return self.Struct(deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt) + +class StreamProfileInfo: + def __init__(self, sensorType, width, height, format, fps): + self.sensorType = sensorType + self.width = width + self.height = height + self.format = format + self.fps = fps + +def initPrimaryId(): + global primaryId + + deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" + if not os.path.exists(deviceInfoPath): + print(f"Initialize primaryId failed. {deviceInfoPath} not exists") + return False + + with open(deviceInfoPath, 'r') as f: + data = json.load(f) + + if not 'devices' in data: + print(f"Initialize primaryId failed. {deviceInfoPath} not contain item 'devices'") + return False + + for item in data['devices']: + if 'isPrimaryDevice' in item and 'index' in item and item['isPrimaryDevice']: + primaryId = str(item['index']) + return True + + return False + +def initSyncConfigParams(): + global frameRate, tspRangeThreshold + + configPath = f"{mainPythonWorkPath}/Config.ini" + if not os.path.exists(configPath): + print(f"Initliaze synchronized config parameter failed. {configPath} not exists.") + return False + + # Create ConfigParser object + config = configparser.ConfigParser() + + # Read ini file + config.read(configPath, 'utf-8') + + if not config.has_option('Parameter', 'frameRate'): + print(f"Initliaze synchronized config parameter failed. Not define 'frameRate' in ${configPath}") + return False + + if not config.has_option('Parameter', 'tspRangeThreshold'): + print(f"Initliaze synchronized config parameter failed. Not define 'tspRangeThreshold' in ${configPath}") + return False + + frameRate = config.getfloat('Parameter', 'frameRate') + if frameRate <= 0 or frameRate >= 1000: + print(f"Initliaze synchronized config parameter failed. Invalid frameRate={frameRate}") + return False + + tspRangeThreshold = config.getfloat('Parameter', 'tspRangeThreshold') + if tspRangeThreshold <= 0: + print(f"Initliaze synchronized config parameter failed. Invalid tspRangeThreshold={tspRangeThreshold}") + return False + + return True + +def getDeviceCount(): + deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" + if not os.path.exists(deviceInfoPath): + print(f"Get device count failed. {deviceInfoPath} not exists") + return 0 + + with open(deviceInfoPath, 'r') as f: + data = json.load(f) + + if not 'devices' in data: + print(f"Get device count failed. {deviceInfoPath} not contain item 'devices'") + return 0 + + return len(data['devices']) + +def initProfileInfoDict(): + global streamProfileDict + + streamProfileDict = dict() + profilePath = f"{sourceRootPath}/StreamProfileInfo.txt" + if not os.path.exists(profilePath): + print(f"Initialize profile information dictionary failed. {profilePath} not exists") + return False + + with open(profilePath, 'r') as f: + data = json.load(f) + + if not 'streamProfiles' in data: + print(f"Initialize profile information dictionary failed. {profilePath} not contain item 'streamProfiles'") + return False + + for item in data['streamProfiles']: + if 'sensorType' in item and 'width' in item and 'height' in item and 'format' in item and 'fps' in item: + profileInfo = StreamProfileInfo(item['sensorType'], item['width'], item['height'], item['format'], item['fps']) + streamProfileDict.setdefault(item['sensorType'], profileInfo) + else: + print(f"Initialize profile information dictionary. Error invalid StreamProfile, {item}") + + return len(streamProfileDict.items()) > 0 + +def initResultDir(): + global resultPath + timeText = datetime.now().strftime("%Y-%m-%d_%H%M%S") + resultPath = f"{sourceRootPath}/results-{timeText}" + if not os.path.exists(resultPath): + os.makedirs(resultPath) + +def isFrameFile(fileName): + fileExt = os.path.splitext(fileName) + if len(fileExt) < 2: + return False + + frameExts = {".jpeg", ".jpg", ".png", ".raw", "bmp"} + return fileExt[1] in frameExts + +def extract_number(filename): + """Extract the numeric part after 'g' in the filename""" + match_g = re.search(r'g(\d+)', filename) + if match_g: + return int(match_g.group(1)) + + """Extract the numeric part after 'd' in the filename""" + match_d = re.search(r'd(\d+)', filename) + if match_d: + return int(match_d.group(1)) + return float('inf') + +def initPictureInfoDictionary(rootFilePath, pictureInfoDict): + frameFileCount = 0 + for dirpath, dirnames, filenames in os.walk(rootFilePath): + filenames.sort(key=extract_number) # Sort filenames by the numeric part after 'd' and 'g' + for fileName in filenames: + filePath = os.path.join(dirpath, fileName) + if not isFrameFile(fileName): + continue + + frameFileCount += 1 + fileNameNoExt = os.path.splitext(fileName)[0] + pictureNameList = fileNameNoExt.split('_') + deviceId = pictureNameList[2][5:] + sensorType = pictureNameList[0].replace('#', '_') + syncTimeStamp = int(pictureNameList[3][1:]) + + # Create struct + pictureInfo = PictureInfo() + info = pictureInfo.make_struct(deviceId, sensorType, syncTimeStamp, filePath, os.path.basename(dirpath), os.path.splitext(fileName)[1]) + + # Format dictionary: one key corresponds to one array + pictureInfoDict.setdefault(deviceId, []).append(info) + + if 0 == frameFileCount: + print("initialize pictureInfoDict failed. Not found frame file") + + +def matchFrame(pictureInfoDict): + global primaryId, frameRate + global streamProfileDict + + # Get comparison image array, use the Color array of the first device for comparison + compareList = [] + for key in pictureInfoDict: + listTmp = list(pictureInfoDict[key]) + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == 'color': + compareList.append(info) + + # Dynamically analyze based on stream opening status to reduce loop iterations + hasColorProfile = 'OB_SENSOR_COLOR' in streamProfileDict + hasDepthProfile = 'OB_SENSOR_DEPTH' in streamProfileDict + hasIRProfile = 'OB_SENSOR_IR' in streamProfileDict + hasIRLeftProfile = 'OB_SENSOR_IR_LEFT' in streamProfileDict + hasIRRightProfile = 'OB_SENSOR_IR_RIGHT' in streamProfileDict + + # Match adjacent frames + resultDict = {} + consumedList = [] + dictIndex = 0 + frameTspHalfGap = int(1000.0/frameRate/2.0+0.5) + for comparePic in compareList: + resultDict.setdefault(dictIndex, []).append(comparePic) + for key in pictureInfoDict: + listTmp = list(pictureInfoDict[key]) + # Compare color + if hasColorProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'color' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Compare depth + if hasDepthProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'depth' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Compare IR + if hasIRProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'ir' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Compare left IR + if hasIRLeftProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'ir_left' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Compare right IR + if hasIRRightProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'ir_right' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Calculate deviation + minTsp = min(resultDict[dictIndex], key=lambda x: x.syncTimeStamp) + for info in resultDict[dictIndex]: + info.tspDiff = info.syncTimeStamp - minTsp.syncTimeStamp + + dictIndex += 1 + + return resultDict + + +def safe_make_dir(path): + if not os.path.exists(path): + os.makedirs(path) + + +def handleSyncFrames(): + global resultPath + global sourceFramesPath + global streamProfileDict + + fp = open(f"{resultPath}/frameMatchLog.txt", "w") + + if not initProfileInfoDict(): + print("Initialize stream profile dictionary failed. exit") + return + print(f"Stream profiles: {streamProfileDict}") + streamProfileCount = len(streamProfileDict.items()) + + pictureInfoDict = {} + + initPictureInfoDictionary(Path(sourceFramesPath), pictureInfoDict) + if len(pictureInfoDict) <= 0: + print("init pictureInfoDict failed. pictureInfoDict.len = 0") + return + + # # Dump pictureInfoDict + # for key in pictureInfoDict: + # print("===================key:%s" % key) + # listTmp = list(pictureInfoDict[key]) + # for info in listTmp: + # print("=====================value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % (info.deviceId,info.sensorType,info.syncTimeStamp,info.picturePath)) + + deviceCount = getDeviceCount() + print("=================device count:%d" % deviceCount) + + resultDict = {} + resultDict = matchFrame(pictureInfoDict) + + for key in resultDict: + fp.write("===================result key:%s\n" % key) + print("===================result key:%s" % key) + listTmp = list(resultDict[key]) + for info in listTmp: + fp.write("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s\n" % ( + info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) + print("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % ( + info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) + + matchPath = f"{resultPath}/matchFrames/" + safe_make_dir(matchPath) + notMatchPath = f"{resultPath}/notMatchFrames/" + abnormalPath = f"{resultPath}/abnormal/" + + for key in resultDict: + listTmp = list(resultDict[key]) + if (len(listTmp) == (deviceCount * streamProfileCount)): + haveAbnormalData = False + for info in listTmp: + if info.tspDiff >= tspRangeThreshold: + path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + info.fileExt + shutil.copy(info.picturePath, path) + haveAbnormalData = True + else: + path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt + shutil.copy(info.picturePath, path) + + if haveAbnormalData: + safe_make_dir(abnormalPath) + for info in listTmp: + if info.tspDiff >= tspRangeThreshold: + path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + info.fileExt + shutil.copy(info.picturePath, path) + else: + path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt + shutil.copy(info.picturePath, path) + else: + safe_make_dir(notMatchPath) + for info in listTmp: + newFilePath = notMatchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt + shutil.copy(info.picturePath, newFilePath) + +def main(): + if not initPrimaryId(): + print("Initialize primaryId failed. exit.") + return + + if not initSyncConfigParams(): + print("Initialized Sync config parameter failed. exit.") + return + + initResultDir() + + print(f"PrimaryId={primaryId}, frameRate={frameRate}, tspRangeThreshold={tspRangeThreshold}") + handleSyncFrames() + + return + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description="Synchronize frames support for 'Orbbec Devices'") + parser.add_argument('frames_dir', type=str, help="Frames directory") + parser.add_argument('main_script_root_dir', type=str, help="SyncFramesMain.py working directory") + args = parser.parse_args() + + sourceRootPath = args.frames_dir + sourceFramesPath = f"{args.frames_dir}/TotalModeFrames" + mainPythonWorkPath = args.main_script_root_dir + print(f"Start of CommonFrameMatch synchronize frame. sourceRootPath={sourceRootPath}") + + main() + + print("Finish of CommonFrameMatch synchronize frame.") diff --git a/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch_Gemini2VL.py b/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch_Gemini2VL.py index 2d769150..8f8e0846 100644 --- a/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch_Gemini2VL.py +++ b/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch_Gemini2VL.py @@ -1,410 +1,410 @@ -import os.path -import argparse -import sys -import json -import shutil -import configparser - -from pathlib import Path -from datetime import datetime - -## Config.ini configuration -# Unit: FPS. Please fill in according to the actual dataset frame rate, -# otherwise it will cause inaccurate matching. -frameRate = -1 -# Unit: ms. When the timestamp range difference of a matched frame group -# is greater than or equal to tspRangeThreshold, the file name will be marked. -tspRangeThreshold = -1 - -## Parsed automatically by Python script, DO NOT modify -primaryId = '-1' # Host ID -mainPythonWorkPath = "" # Working directory of SyncFramesMain.py -sourceFramesPath = "" # DO NOT modify, fixed value, path to TotalMode directory -sourceRootPath = "" # Root directory containing TotalMode -resultPath = "" # Path to save sync analysis results -streamProfileDict = dict() # Store Python results - -class PictureInfo(object): - class Struct(object): - def __init__(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt): - self.deviceId = deviceId - self.sensorType = sensorType - self.syncTimeStamp = syncTimeStamp - self.picturePath = picturePath - self.deviceIdFull = deviceIdFull - self.fileExt = fileExt - - def make_struct(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt): - return self.Struct(deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt) - -class StreamProfileInfo: - def __init__(self, sensorType, width, height, format, fps): - self.sensorType = sensorType - self.width = width - self.height = height - self.format = format - self.fps = fps - -def initPrimaryId(): - global primaryId - - deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" - if not os.path.exists(deviceInfoPath): - print(f"Initialize primaryId failed. {deviceInfoPath} not exists") - return False - - with open(deviceInfoPath, 'r') as f: - data = json.load(f) - - if not 'devices' in data: - print(f"Initialize primaryId failed. {deviceInfoPath} not contain item 'devices'") - return False - - for item in data['devices']: - if 'isPrimaryDevice' in item and 'index' in item and item['isPrimaryDevice']: - primaryId = str(item['index']) - return True - - return False - -def initSyncConfigParams(): - global frameRate, tspRangeThreshold - - configPath = f"{mainPythonWorkPath}/Config.ini" - if not os.path.exists(configPath): - print(f"Initliaze synchronized config parameter failed. {configPath} not exists.") - return False - - # Create ConfigParser object - config = configparser.ConfigParser() - - # Read ini file - config.read(configPath, 'utf-8') - - if not config.has_option('Parameter', 'frameRate'): - print(f"Initliaze synchronized config parameter failed. Not define 'frameRate' in ${configPath}") - return False - - if not config.has_option('Parameter', 'tspRangeThreshold'): - print(f"Initliaze synchronized config parameter failed. Not define 'tspRangeThreshold' in ${configPath}") - return False - - frameRate = config.getfloat('Parameter', 'frameRate') - if frameRate <= 0 or frameRate >= 1000: - print(f"Initliaze synchronized config parameter failed. Invalid frameRate={frameRate}") - return False - - tspRangeThreshold = config.getfloat('Parameter', 'tspRangeThreshold') - if tspRangeThreshold <= 0: - print(f"Initliaze synchronized config parameter failed. Invalid tspRangeThreshold={tspRangeThreshold}") - return False - - return True - -def getDeviceCount(): - deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" - if not os.path.exists(deviceInfoPath): - print(f"Get device count failed. {deviceInfoPath} not exists") - return 0 - - with open(deviceInfoPath, 'r') as f: - data = json.load(f) - - if not 'devices' in data: - print(f"Get device count failed. {deviceInfoPath} not contain item 'devices'") - return 0 - - return len(data['devices']) - -def initProfileInfoDict(): - global streamProfileDict - - streamProfileDict = dict() - profilePath = f"{sourceRootPath}/StreamProfileInfo.txt" - if not os.path.exists(profilePath): - print(f"Initialize profile information dictionary failed. {profilePath} not exists") - return False - - with open(profilePath, 'r') as f: - data = json.load(f) - - if not 'streamProfiles' in data: - print(f"Initialize profile information dictionary failed. {profilePath} not contain item 'streamProfiles'") - return False - - for item in data['streamProfiles']: - if 'sensorType' in item and 'width' in item and 'height' in item and 'format' in item and 'fps' in item: - profileInfo = StreamProfileInfo(item['sensorType'], item['width'], item['height'], item['format'], item['fps']) - streamProfileDict.setdefault(item['sensorType'], profileInfo) - else: - print(f"Initialize profile information dictionary. Error invalid StreamProfile, {item}") - - return len(streamProfileDict.items()) > 0 - -def initResultDir(): - global resultPath - timeText = datetime.now().strftime("%Y-%m-%d_%H%M%S") - resultPath = f"{sourceRootPath}/results-{timeText}" - if not os.path.exists(resultPath): - os.makedirs(resultPath) - -def isFrameFile(fileName): - fileExt = os.path.splitext(fileName) - if len(fileExt) < 2: - return False - - frameExts = {".jpeg", ".jpg", ".png", ".raw", "bmp"} - return fileExt[1] in frameExts - -def initPictureInfoDictionary(rootFilePath, pictureInfoDict): - frameFileCount = 0 - for dirpath, dirnames, filenames in os.walk(rootFilePath): - # print(f"dirpath={dirpath}, dirpath.basename=" + os.path.basename(dirpath)) - for fileName in filenames: - filePath = os.path.join(dirpath, fileName) - if not isFrameFile(fileName): - continue - - frameFileCount += 1 - fileNameNoExt = os.path.splitext(fileName)[0] - pictureNameList = fileNameNoExt.split('_') - deviceId = pictureNameList[2][5:] - sensorType = pictureNameList[0].replace('#', '_') - syncTimeStamp = int(pictureNameList[3][1:]) - - # Create structure - pictureInfo = PictureInfo() - info = pictureInfo.make_struct(deviceId, sensorType, syncTimeStamp, filePath, os.path.basename(dirpath), os.path.splitext(fileName)[1]) - - # Format dictionary: one key corresponds to one array - pictureInfoDict.setdefault(deviceId, []).append(info) - - if 0 == frameFileCount: - print("initialize pictureInfoDict failed. Not found frame file") - - -def matchFrame(pictureInfoDict): - global primaryId, frameRate - global streamProfileDict - - # Get comparison image array, take the Color array of the first device for comparison - compareList = [] - for key in pictureInfoDict: - listTmp = list(pictureInfoDict[key]) - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == 'color': - compareList.append(info) - - # Dynamically analyze based on stream status to reduce loop iterations - hasColorProfile = 'OB_SENSOR_COLOR' in streamProfileDict - hasDepthProfile = 'OB_SENSOR_DEPTH' in streamProfileDict - hasIRProfile = 'OB_SENSOR_IR' in streamProfileDict - hasIRLeftProfile = 'OB_SENSOR_IR_LEFT' in streamProfileDict - hasIRRightProfile = 'OB_SENSOR_IR_RIGHT' in streamProfileDict - - # Match adjacent frames - resultDict = {} - consumedList = [] - dictIndex = 0 - frameTspHalfGap = int(1000.0/frameRate/2.0+0.5) - for comparePic in compareList: - resultDict.setdefault(dictIndex, []).append(comparePic) - for key in pictureInfoDict: - listTmp = list(pictureInfoDict[key]) - # Compare color - if hasColorProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'color' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Compare depth - if hasDepthProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'depth' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Compare IR - if hasIRProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'ir' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Compare left IR - if hasIRLeftProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'ir_left' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Compare right IR - if hasIRRightProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'ir_right' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Calculate deviation - minTsp = min(resultDict[dictIndex], key=lambda x: x.syncTimeStamp) - for info in resultDict[dictIndex]: - info.tspDiff = info.syncTimeStamp - minTsp.syncTimeStamp - - dictIndex += 1 - - return resultDict - - -def safe_make_dir(path): - if not os.path.exists(path): - os.makedirs(path) - - -def handleSyncFrames(): - global resultPath - global sourceFramesPath - global streamProfileDict - - fp = open(f"{resultPath}/frameMatchLog.txt", "w") - - if not initProfileInfoDict(): - print("Initialize stream profile dictionary failed. exit") - return - print(f"Stream profiles: {streamProfileDict}") - streamProfileCount = len(streamProfileDict.items()) - - pictureInfoDict = {} - - initPictureInfoDictionary(Path(sourceFramesPath), pictureInfoDict) - if len(pictureInfoDict) <= 0: - print("init pictureInfoDict failed. pictureInfoDict.len = 0") - return - - # # Dump pictureInfoDict - # for key in pictureInfoDict: - # print("===================key:%s" % key) - # listTmp = list(pictureInfoDict[key]) - # for info in listTmp: - # print("=====================value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % (info.deviceId,info.sensorType,info.syncTimeStamp,info.picturePath)) - - deviceCount = getDeviceCount() - print("=================device count:%d" % deviceCount) - - resultDict = {} - resultDict = matchFrame(pictureInfoDict) - - for key in resultDict: - fp.write("===================result key:%s\n" % key) - print("===================result key:%s" % key) - listTmp = list(resultDict[key]) - for info in listTmp: - fp.write("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s\n" % ( - info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) - print("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % ( - info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) - - matchPath = f"{resultPath}/matchFrames/" - safe_make_dir(matchPath) - notMatchPath = f"{resultPath}/notMatchFrames/" - abnormalPath = f"{resultPath}/abnormal/" - - for key in resultDict: - listTmp = list(resultDict[key]) - if (len(listTmp) == (deviceCount * streamProfileCount)): - haveAbnormalData = False - for info in listTmp: - if info.tspDiff >= tspRangeThreshold: - path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + info.fileExt - shutil.copy(info.picturePath, path) - haveAbnormalData = True - else: - path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt - shutil.copy(info.picturePath, path) - - if haveAbnormalData: - safe_make_dir(abnormalPath) - for info in listTmp: - if info.tspDiff >= tspRangeThreshold: - path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + info.fileExt - shutil.copy(info.picturePath, path) - else: - path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt - shutil.copy(info.picturePath, path) - else: - safe_make_dir(notMatchPath) - for info in listTmp: - newFilePath = notMatchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt - shutil.copy(info.picturePath, newFilePath) - -def main(): - if not initPrimaryId(): - print("Initialize primaryId failed. exit.") - return - - if not initSyncConfigParams(): - print("Initialized Sync config parameter failed. exit.") - return - - initResultDir() - - print(f"PrimaryId={primaryId}, frameRate={frameRate}, tspRangeThreshold={tspRangeThreshold}") - handleSyncFrames() - - return - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description="Synchronize frames support for 'Orbbec Gemini 2 VL'") - parser.add_argument('frames_dir', type=str, help="Frames directory") - parser.add_argument('main_script_root_dir', type=str, help="SyncFramesMain.py working directory") - args = parser.parse_args() - - sourceRootPath = args.frames_dir - sourceFramesPath = f"{args.frames_dir}/TotalModeFrames" - mainPythonWorkPath = args.main_script_root_dir - print(f"Start of Gemini2VL synchronize frame. sourceRootPath={sourceRootPath}") - - main() - - print("Finish of Gemini2VL synchronize frame.") +import os.path +import argparse +import sys +import json +import shutil +import configparser + +from pathlib import Path +from datetime import datetime + +## Config.ini configuration +# Unit: FPS. Please fill in according to the actual dataset frame rate, +# otherwise it will cause inaccurate matching. +frameRate = -1 +# Unit: ms. When the timestamp range difference of a matched frame group +# is greater than or equal to tspRangeThreshold, the file name will be marked. +tspRangeThreshold = -1 + +## Parsed automatically by Python script, DO NOT modify +primaryId = '-1' # Host ID +mainPythonWorkPath = "" # Working directory of SyncFramesMain.py +sourceFramesPath = "" # DO NOT modify, fixed value, path to TotalMode directory +sourceRootPath = "" # Root directory containing TotalMode +resultPath = "" # Path to save sync analysis results +streamProfileDict = dict() # Store Python results + +class PictureInfo(object): + class Struct(object): + def __init__(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt): + self.deviceId = deviceId + self.sensorType = sensorType + self.syncTimeStamp = syncTimeStamp + self.picturePath = picturePath + self.deviceIdFull = deviceIdFull + self.fileExt = fileExt + + def make_struct(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt): + return self.Struct(deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt) + +class StreamProfileInfo: + def __init__(self, sensorType, width, height, format, fps): + self.sensorType = sensorType + self.width = width + self.height = height + self.format = format + self.fps = fps + +def initPrimaryId(): + global primaryId + + deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" + if not os.path.exists(deviceInfoPath): + print(f"Initialize primaryId failed. {deviceInfoPath} not exists") + return False + + with open(deviceInfoPath, 'r') as f: + data = json.load(f) + + if not 'devices' in data: + print(f"Initialize primaryId failed. {deviceInfoPath} not contain item 'devices'") + return False + + for item in data['devices']: + if 'isPrimaryDevice' in item and 'index' in item and item['isPrimaryDevice']: + primaryId = str(item['index']) + return True + + return False + +def initSyncConfigParams(): + global frameRate, tspRangeThreshold + + configPath = f"{mainPythonWorkPath}/Config.ini" + if not os.path.exists(configPath): + print(f"Initliaze synchronized config parameter failed. {configPath} not exists.") + return False + + # Create ConfigParser object + config = configparser.ConfigParser() + + # Read ini file + config.read(configPath, 'utf-8') + + if not config.has_option('Parameter', 'frameRate'): + print(f"Initliaze synchronized config parameter failed. Not define 'frameRate' in ${configPath}") + return False + + if not config.has_option('Parameter', 'tspRangeThreshold'): + print(f"Initliaze synchronized config parameter failed. Not define 'tspRangeThreshold' in ${configPath}") + return False + + frameRate = config.getfloat('Parameter', 'frameRate') + if frameRate <= 0 or frameRate >= 1000: + print(f"Initliaze synchronized config parameter failed. Invalid frameRate={frameRate}") + return False + + tspRangeThreshold = config.getfloat('Parameter', 'tspRangeThreshold') + if tspRangeThreshold <= 0: + print(f"Initliaze synchronized config parameter failed. Invalid tspRangeThreshold={tspRangeThreshold}") + return False + + return True + +def getDeviceCount(): + deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" + if not os.path.exists(deviceInfoPath): + print(f"Get device count failed. {deviceInfoPath} not exists") + return 0 + + with open(deviceInfoPath, 'r') as f: + data = json.load(f) + + if not 'devices' in data: + print(f"Get device count failed. {deviceInfoPath} not contain item 'devices'") + return 0 + + return len(data['devices']) + +def initProfileInfoDict(): + global streamProfileDict + + streamProfileDict = dict() + profilePath = f"{sourceRootPath}/StreamProfileInfo.txt" + if not os.path.exists(profilePath): + print(f"Initialize profile information dictionary failed. {profilePath} not exists") + return False + + with open(profilePath, 'r') as f: + data = json.load(f) + + if not 'streamProfiles' in data: + print(f"Initialize profile information dictionary failed. {profilePath} not contain item 'streamProfiles'") + return False + + for item in data['streamProfiles']: + if 'sensorType' in item and 'width' in item and 'height' in item and 'format' in item and 'fps' in item: + profileInfo = StreamProfileInfo(item['sensorType'], item['width'], item['height'], item['format'], item['fps']) + streamProfileDict.setdefault(item['sensorType'], profileInfo) + else: + print(f"Initialize profile information dictionary. Error invalid StreamProfile, {item}") + + return len(streamProfileDict.items()) > 0 + +def initResultDir(): + global resultPath + timeText = datetime.now().strftime("%Y-%m-%d_%H%M%S") + resultPath = f"{sourceRootPath}/results-{timeText}" + if not os.path.exists(resultPath): + os.makedirs(resultPath) + +def isFrameFile(fileName): + fileExt = os.path.splitext(fileName) + if len(fileExt) < 2: + return False + + frameExts = {".jpeg", ".jpg", ".png", ".raw", "bmp"} + return fileExt[1] in frameExts + +def initPictureInfoDictionary(rootFilePath, pictureInfoDict): + frameFileCount = 0 + for dirpath, dirnames, filenames in os.walk(rootFilePath): + # print(f"dirpath={dirpath}, dirpath.basename=" + os.path.basename(dirpath)) + for fileName in filenames: + filePath = os.path.join(dirpath, fileName) + if not isFrameFile(fileName): + continue + + frameFileCount += 1 + fileNameNoExt = os.path.splitext(fileName)[0] + pictureNameList = fileNameNoExt.split('_') + deviceId = pictureNameList[2][5:] + sensorType = pictureNameList[0].replace('#', '_') + syncTimeStamp = int(pictureNameList[3][1:]) + + # Create structure + pictureInfo = PictureInfo() + info = pictureInfo.make_struct(deviceId, sensorType, syncTimeStamp, filePath, os.path.basename(dirpath), os.path.splitext(fileName)[1]) + + # Format dictionary: one key corresponds to one array + pictureInfoDict.setdefault(deviceId, []).append(info) + + if 0 == frameFileCount: + print("initialize pictureInfoDict failed. Not found frame file") + + +def matchFrame(pictureInfoDict): + global primaryId, frameRate + global streamProfileDict + + # Get comparison image array, take the Color array of the first device for comparison + compareList = [] + for key in pictureInfoDict: + listTmp = list(pictureInfoDict[key]) + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == 'color': + compareList.append(info) + + # Dynamically analyze based on stream status to reduce loop iterations + hasColorProfile = 'OB_SENSOR_COLOR' in streamProfileDict + hasDepthProfile = 'OB_SENSOR_DEPTH' in streamProfileDict + hasIRProfile = 'OB_SENSOR_IR' in streamProfileDict + hasIRLeftProfile = 'OB_SENSOR_IR_LEFT' in streamProfileDict + hasIRRightProfile = 'OB_SENSOR_IR_RIGHT' in streamProfileDict + + # Match adjacent frames + resultDict = {} + consumedList = [] + dictIndex = 0 + frameTspHalfGap = int(1000.0/frameRate/2.0+0.5) + for comparePic in compareList: + resultDict.setdefault(dictIndex, []).append(comparePic) + for key in pictureInfoDict: + listTmp = list(pictureInfoDict[key]) + # Compare color + if hasColorProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'color' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Compare depth + if hasDepthProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'depth' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Compare IR + if hasIRProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'ir' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Compare left IR + if hasIRLeftProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'ir_left' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Compare right IR + if hasIRRightProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'ir_right' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Calculate deviation + minTsp = min(resultDict[dictIndex], key=lambda x: x.syncTimeStamp) + for info in resultDict[dictIndex]: + info.tspDiff = info.syncTimeStamp - minTsp.syncTimeStamp + + dictIndex += 1 + + return resultDict + + +def safe_make_dir(path): + if not os.path.exists(path): + os.makedirs(path) + + +def handleSyncFrames(): + global resultPath + global sourceFramesPath + global streamProfileDict + + fp = open(f"{resultPath}/frameMatchLog.txt", "w") + + if not initProfileInfoDict(): + print("Initialize stream profile dictionary failed. exit") + return + print(f"Stream profiles: {streamProfileDict}") + streamProfileCount = len(streamProfileDict.items()) + + pictureInfoDict = {} + + initPictureInfoDictionary(Path(sourceFramesPath), pictureInfoDict) + if len(pictureInfoDict) <= 0: + print("init pictureInfoDict failed. pictureInfoDict.len = 0") + return + + # # Dump pictureInfoDict + # for key in pictureInfoDict: + # print("===================key:%s" % key) + # listTmp = list(pictureInfoDict[key]) + # for info in listTmp: + # print("=====================value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % (info.deviceId,info.sensorType,info.syncTimeStamp,info.picturePath)) + + deviceCount = getDeviceCount() + print("=================device count:%d" % deviceCount) + + resultDict = {} + resultDict = matchFrame(pictureInfoDict) + + for key in resultDict: + fp.write("===================result key:%s\n" % key) + print("===================result key:%s" % key) + listTmp = list(resultDict[key]) + for info in listTmp: + fp.write("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s\n" % ( + info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) + print("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % ( + info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) + + matchPath = f"{resultPath}/matchFrames/" + safe_make_dir(matchPath) + notMatchPath = f"{resultPath}/notMatchFrames/" + abnormalPath = f"{resultPath}/abnormal/" + + for key in resultDict: + listTmp = list(resultDict[key]) + if (len(listTmp) == (deviceCount * streamProfileCount)): + haveAbnormalData = False + for info in listTmp: + if info.tspDiff >= tspRangeThreshold: + path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + info.fileExt + shutil.copy(info.picturePath, path) + haveAbnormalData = True + else: + path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt + shutil.copy(info.picturePath, path) + + if haveAbnormalData: + safe_make_dir(abnormalPath) + for info in listTmp: + if info.tspDiff >= tspRangeThreshold: + path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + info.fileExt + shutil.copy(info.picturePath, path) + else: + path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt + shutil.copy(info.picturePath, path) + else: + safe_make_dir(notMatchPath) + for info in listTmp: + newFilePath = notMatchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + info.fileExt + shutil.copy(info.picturePath, newFilePath) + +def main(): + if not initPrimaryId(): + print("Initialize primaryId failed. exit.") + return + + if not initSyncConfigParams(): + print("Initialized Sync config parameter failed. exit.") + return + + initResultDir() + + print(f"PrimaryId={primaryId}, frameRate={frameRate}, tspRangeThreshold={tspRangeThreshold}") + handleSyncFrames() + + return + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description="Synchronize frames support for 'Orbbec Gemini 2 VL'") + parser.add_argument('frames_dir', type=str, help="Frames directory") + parser.add_argument('main_script_root_dir', type=str, help="SyncFramesMain.py working directory") + args = parser.parse_args() + + sourceRootPath = args.frames_dir + sourceFramesPath = f"{args.frames_dir}/TotalModeFrames" + mainPythonWorkPath = args.main_script_root_dir + print(f"Start of Gemini2VL synchronize frame. sourceRootPath={sourceRootPath}") + + main() + + print("Finish of Gemini2VL synchronize frame.") diff --git a/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch_g330.py b/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch_g330.py index 345cb9c5..400fac46 100644 --- a/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch_g330.py +++ b/orbbec_camera/examples/multi_camera_synced_verification_tool/multicamera_sync/Python/script/config_frameMatch_g330.py @@ -1,426 +1,426 @@ -import os.path -import argparse -import sys -import json -import shutil -import configparser - -from pathlib import Path -from datetime import datetime - -import os -import re - -## Config.ini configuration -# Unit: FPS. Please fill in according to the actual frame rate of the dataset, otherwise the matching will be inaccurate. -frameRate = -1 -# Unit: ms. When the timestamp range of a matched group of data frames is greater than or equal to tspRangeThreshold, the filename will be marked. -tspRangeThreshold = -1 - -## Automatically parsed by Python script, do not modify -primaryId = '-1' # Primary device ID -mainPythonWorkPath = "" # Working directory of SyncFramesMain.py -sourceFramesPath = "" # Do not modify, fixed value, path to TotalMode directory -sourceRootPath = "" # Root directory where TotalMode is stored -resultPath = "" # Save sync analysis results -streamProfileDict = dict() # Save Python results - -class PictureInfo(object): - class Struct(object): - def __init__(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt, exp, gain): - self.deviceId = deviceId - self.sensorType = sensorType - self.syncTimeStamp = syncTimeStamp - self.picturePath = picturePath - self.deviceIdFull = deviceIdFull - self.fileExt = fileExt - self.exp = exp - self.gain = gain - - def make_struct(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt, exp, gain): - return self.Struct(deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt, exp, gain) - -class StreamProfileInfo: - def __init__(self, sensorType, width, height, format, fps): - self.sensorType = sensorType - self.width = width - self.height = height - self.format = format - self.fps = fps - -def initPrimaryId(): - global primaryId - - deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" - if not os.path.exists(deviceInfoPath): - print(f"Initialize primaryId failed. {deviceInfoPath} not exists") - return False - - with open(deviceInfoPath, 'r') as f: - data = json.load(f) - - if not 'devices' in data: - print(f"Initialize primaryId failed. {deviceInfoPath} not contain item 'devices'") - return False - - for item in data['devices']: - if 'isPrimaryDevice' in item and 'index' in item and item['isPrimaryDevice']: - primaryId = str(item['index']) - return True - - return False - -def initSyncConfigParams(): - global frameRate, tspRangeThreshold - - configPath = f"{mainPythonWorkPath}/Config.ini" - if not os.path.exists(configPath): - print(f"Initliaze synchronized config parameter failed. {configPath} not exists.") - return False - - # Create ConfigParser object - config = configparser.ConfigParser() - - # Read ini file - config.read(configPath, 'utf-8') - - if not config.has_option('Parameter', 'frameRate'): - print(f"Initliaze synchronized config parameter failed. Not define 'frameRate' in ${configPath}") - return False - - if not config.has_option('Parameter', 'tspRangeThreshold'): - print(f"Initliaze synchronized config parameter failed. Not define 'tspRangeThreshold' in ${configPath}") - return False - - frameRate = config.getfloat('Parameter', 'frameRate') - if frameRate <= 0 or frameRate >= 1000: - print(f"Initliaze synchronized config parameter failed. Invalid frameRate={frameRate}") - return False - - tspRangeThreshold = config.getfloat('Parameter', 'tspRangeThreshold') - if tspRangeThreshold <= 0: - print(f"Initliaze synchronized config parameter failed. Invalid tspRangeThreshold={tspRangeThreshold}") - return False - - return True - -def getDeviceCount(): - deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" - if not os.path.exists(deviceInfoPath): - print(f"Get device count failed. {deviceInfoPath} not exists") - return 0 - - with open(deviceInfoPath, 'r') as f: - data = json.load(f) - - if not 'devices' in data: - print(f"Get device count failed. {deviceInfoPath} not contain item 'devices'") - return 0 - - return len(data['devices']) - -def initProfileInfoDict(): - global streamProfileDict - - streamProfileDict = dict() - profilePath = f"{sourceRootPath}/StreamProfileInfo.txt" - if not os.path.exists(profilePath): - print(f"Initialize profile information dictionary failed. {profilePath} not exists") - return False - - with open(profilePath, 'r') as f: - data = json.load(f) - - if not 'streamProfiles' in data: - print(f"Initialize profile information dictionary failed. {profilePath} not contain item 'streamProfiles'") - return False - - for item in data['streamProfiles']: - if 'sensorType' in item and 'width' in item and 'height' in item and 'format' in item and 'fps' in item: - profileInfo = StreamProfileInfo(item['sensorType'], item['width'], item['height'], item['format'], item['fps']) - streamProfileDict.setdefault(item['sensorType'], profileInfo) - else: - print(f"Initialize profile information dictionary. Error invalid StreamProfile, {item}") - - return len(streamProfileDict.items()) > 0 - -def initResultDir(): - global resultPath - timeText = datetime.now().strftime("%Y-%m-%d_%H%M%S") - resultPath = f"{sourceRootPath}/results-{timeText}" - if not os.path.exists(resultPath): - os.makedirs(resultPath) - -def isFrameFile(fileName): - fileExt = os.path.splitext(fileName) - if len(fileExt) < 2: - return False - - frameExts = {".jpeg", ".jpg", ".png", ".raw", "bmp"} - return fileExt[1] in frameExts - -def extract_number(filename): - match_d = re.search(r'_d(\d+)', filename) - if match_d: - return int(match_d.group(1)) - - match_g = re.search(r'_g(\d+)', filename) - if match_g: - return int(match_g.group(1)) - - return float('inf') - -def initPictureInfoDictionary(rootFilePath, pictureInfoDict): - frameFileCount = 0 - for dirpath, dirnames, filenames in os.walk(rootFilePath): - filenames.sort(key=extract_number) # Sort files by numbers following '_d' and '_g' in filename, ascending - for fileName in filenames: - filePath = os.path.join(dirpath, fileName) - if not isFrameFile(fileName): - continue - - frameFileCount += 1 - fileNameNoExt = os.path.splitext(fileName)[0] - pictureNameList = fileNameNoExt.split('_') - deviceId = pictureNameList[2][5:] - sensorType = pictureNameList[0].replace('#', '_') - syncTimeStamp = int(pictureNameList[3][1:]) - exp = str(pictureNameList[6][0:]) - gain = str(pictureNameList[7][0:]) - - # Create structure - pictureInfo = PictureInfo() - info = pictureInfo.make_struct(deviceId, sensorType, syncTimeStamp, filePath, os.path.basename(dirpath), os.path.splitext(fileName)[1],exp,gain) - - # Format dictionary: one key corresponds to one array - pictureInfoDict.setdefault(deviceId, []).append(info) - - if 0 == frameFileCount: - print("initialize pictureInfoDict failed. Not found frame file") - - -def matchFrame(pictureInfoDict): - global primaryId, frameRate - global streamProfileDict - - # Get comparison image array, use Color array of the first device for comparison - compareList = [] - for key in pictureInfoDict: - listTmp = list(pictureInfoDict[key]) - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == 'color': - compareList.append(info) - - # Dynamically analyze according to stream situation to reduce loop count - hasColorProfile = 'OB_SENSOR_COLOR' in streamProfileDict - hasDepthProfile = 'OB_SENSOR_DEPTH' in streamProfileDict - hasIRProfile = 'OB_SENSOR_IR' in streamProfileDict - hasIRLeftProfile = 'OB_SENSOR_IR_LEFT' in streamProfileDict - hasIRRightProfile = 'OB_SENSOR_IR_RIGHT' in streamProfileDict - - # Match adjacent frames - resultDict = {} - consumedList = [] - dictIndex = 0 - frameTspHalfGap = int(1000.0/frameRate/2.0+0.5) - for comparePic in compareList: - resultDict.setdefault(dictIndex, []).append(comparePic) - for key in pictureInfoDict: - listTmp = list(pictureInfoDict[key]) - # Compare color - if hasColorProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'color' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Compare depth - if hasDepthProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'depth' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Compare IR - if hasIRProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'ir' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Compare IR Left - if hasIRLeftProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'ir_left' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Compare IR Right - if hasIRRightProfile: - for info in listTmp: - if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: - continue - - if info in consumedList: - continue - - if info.sensorType == 'ir_right' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: - resultDict.setdefault(dictIndex, []).append(info) - consumedList.append(info) - break - - # Calculate deviation - minTsp = min(resultDict[dictIndex], key=lambda x: x.syncTimeStamp) - for info in resultDict[dictIndex]: - info.tspDiff = info.syncTimeStamp - minTsp.syncTimeStamp - - dictIndex += 1 - - return resultDict - - -def safe_make_dir(path): - if not os.path.exists(path): - os.makedirs(path) - - -def handleSyncFrames(): - global resultPath - global sourceFramesPath - global streamProfileDict - - fp = open(f"{resultPath}/frameMatchLog.txt", "w") - - if not initProfileInfoDict(): - print("Initialize stream profile dictionary failed. exit") - return - print(f"Stream profiles: {streamProfileDict}") - streamProfileCount = len(streamProfileDict.items()) - - pictureInfoDict = {} - - initPictureInfoDictionary(Path(sourceFramesPath), pictureInfoDict) - if len(pictureInfoDict) <= 0: - print("init pictureInfoDict failed. pictureInfoDict.len = 0") - return - - # # Dump pictureInfoDict - # for key in pictureInfoDict: - # print("===================key:%s" % key) - # listTmp = list(pictureInfoDict[key]) - # for info in listTmp: - # print("=====================value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % (info.deviceId,info.sensorType,info.syncTimeStamp,info.picturePath)) - - deviceCount = getDeviceCount() - print("=================device count:%d" % deviceCount) - - resultDict = {} - resultDict = matchFrame(pictureInfoDict) - - for key in resultDict: - fp.write("===================result key:%s\n" % key) - print("===================result key:%s" % key) - listTmp = list(resultDict[key]) - for info in listTmp: - fp.write("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s\n" % ( - info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) - print("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % ( - info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) - - matchPath = f"{resultPath}/matchFrames/" - safe_make_dir(matchPath) - notMatchPath = f"{resultPath}/notMatchFrames/" - abnormalPath = f"{resultPath}/abnormal/" - - for key in resultDict: - listTmp = list(resultDict[key]) - if (len(listTmp) == (deviceCount * streamProfileCount)): - haveAbnormalData = False - for info in listTmp: - if info.tspDiff >= tspRangeThreshold: - path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + "_"+ str(info.exp) + "_"+ str(info.gain) + info.fileExt - shutil.copy(info.picturePath, path) - haveAbnormalData = True - else: - path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_"+ str(info.exp) + "_"+ str(info.gain) + info.fileExt - shutil.copy(info.picturePath, path) - - if haveAbnormalData: - safe_make_dir(abnormalPath) - for info in listTmp: - if info.tspDiff >= tspRangeThreshold: - path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + "_"+ str(info.exp) + "_"+ str(info.gain) + info.fileExt - shutil.copy(info.picturePath, path) - else: - path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_"+ str(info.exp) + "_"+ str(info.gain) + info.fileExt - shutil.copy(info.picturePath, path) - else: - safe_make_dir(notMatchPath) - for info in listTmp: - newFilePath = notMatchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( - info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_"+ str(info.exp) + "_"+ str(info.gain) + info.fileExt - shutil.copy(info.picturePath, newFilePath) - -def main(): - if not initPrimaryId(): - print("Initialize primaryId failed. exit.") - return - - if not initSyncConfigParams(): - print("Initialized Sync config parameter failed. exit.") - return - - initResultDir() - - print(f"PrimaryId={primaryId}, frameRate={frameRate}, tspRangeThreshold={tspRangeThreshold}") - handleSyncFrames() - - return - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description="Synchronize frames support for 'Orbbec Devices'") - parser.add_argument('frames_dir', type=str, help="Frames directory") - parser.add_argument('main_script_root_dir', type=str, help="SyncFramesMain.py working directory") - args = parser.parse_args() - - sourceRootPath = args.frames_dir - sourceFramesPath = f"{args.frames_dir}/TotalModeFrames" - mainPythonWorkPath = args.main_script_root_dir - print(f"Start of CommonFrameMatch synchronize frame. sourceRootPath={sourceRootPath}") - - main() - - print("Finish of CommonFrameMatch synchronize frame.") +import os.path +import argparse +import sys +import json +import shutil +import configparser + +from pathlib import Path +from datetime import datetime + +import os +import re + +## Config.ini configuration +# Unit: FPS. Please fill in according to the actual frame rate of the dataset, otherwise the matching will be inaccurate. +frameRate = -1 +# Unit: ms. When the timestamp range of a matched group of data frames is greater than or equal to tspRangeThreshold, the filename will be marked. +tspRangeThreshold = -1 + +## Automatically parsed by Python script, do not modify +primaryId = '-1' # Primary device ID +mainPythonWorkPath = "" # Working directory of SyncFramesMain.py +sourceFramesPath = "" # Do not modify, fixed value, path to TotalMode directory +sourceRootPath = "" # Root directory where TotalMode is stored +resultPath = "" # Save sync analysis results +streamProfileDict = dict() # Save Python results + +class PictureInfo(object): + class Struct(object): + def __init__(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt, exp, gain): + self.deviceId = deviceId + self.sensorType = sensorType + self.syncTimeStamp = syncTimeStamp + self.picturePath = picturePath + self.deviceIdFull = deviceIdFull + self.fileExt = fileExt + self.exp = exp + self.gain = gain + + def make_struct(self, deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt, exp, gain): + return self.Struct(deviceId, sensorType, syncTimeStamp, picturePath, deviceIdFull, fileExt, exp, gain) + +class StreamProfileInfo: + def __init__(self, sensorType, width, height, format, fps): + self.sensorType = sensorType + self.width = width + self.height = height + self.format = format + self.fps = fps + +def initPrimaryId(): + global primaryId + + deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" + if not os.path.exists(deviceInfoPath): + print(f"Initialize primaryId failed. {deviceInfoPath} not exists") + return False + + with open(deviceInfoPath, 'r') as f: + data = json.load(f) + + if not 'devices' in data: + print(f"Initialize primaryId failed. {deviceInfoPath} not contain item 'devices'") + return False + + for item in data['devices']: + if 'isPrimaryDevice' in item and 'index' in item and item['isPrimaryDevice']: + primaryId = str(item['index']) + return True + + return False + +def initSyncConfigParams(): + global frameRate, tspRangeThreshold + + configPath = f"{mainPythonWorkPath}/Config.ini" + if not os.path.exists(configPath): + print(f"Initliaze synchronized config parameter failed. {configPath} not exists.") + return False + + # Create ConfigParser object + config = configparser.ConfigParser() + + # Read ini file + config.read(configPath, 'utf-8') + + if not config.has_option('Parameter', 'frameRate'): + print(f"Initliaze synchronized config parameter failed. Not define 'frameRate' in ${configPath}") + return False + + if not config.has_option('Parameter', 'tspRangeThreshold'): + print(f"Initliaze synchronized config parameter failed. Not define 'tspRangeThreshold' in ${configPath}") + return False + + frameRate = config.getfloat('Parameter', 'frameRate') + if frameRate <= 0 or frameRate >= 1000: + print(f"Initliaze synchronized config parameter failed. Invalid frameRate={frameRate}") + return False + + tspRangeThreshold = config.getfloat('Parameter', 'tspRangeThreshold') + if tspRangeThreshold <= 0: + print(f"Initliaze synchronized config parameter failed. Invalid tspRangeThreshold={tspRangeThreshold}") + return False + + return True + +def getDeviceCount(): + deviceInfoPath = f"{sourceRootPath}/DevicesInfo.txt" + if not os.path.exists(deviceInfoPath): + print(f"Get device count failed. {deviceInfoPath} not exists") + return 0 + + with open(deviceInfoPath, 'r') as f: + data = json.load(f) + + if not 'devices' in data: + print(f"Get device count failed. {deviceInfoPath} not contain item 'devices'") + return 0 + + return len(data['devices']) + +def initProfileInfoDict(): + global streamProfileDict + + streamProfileDict = dict() + profilePath = f"{sourceRootPath}/StreamProfileInfo.txt" + if not os.path.exists(profilePath): + print(f"Initialize profile information dictionary failed. {profilePath} not exists") + return False + + with open(profilePath, 'r') as f: + data = json.load(f) + + if not 'streamProfiles' in data: + print(f"Initialize profile information dictionary failed. {profilePath} not contain item 'streamProfiles'") + return False + + for item in data['streamProfiles']: + if 'sensorType' in item and 'width' in item and 'height' in item and 'format' in item and 'fps' in item: + profileInfo = StreamProfileInfo(item['sensorType'], item['width'], item['height'], item['format'], item['fps']) + streamProfileDict.setdefault(item['sensorType'], profileInfo) + else: + print(f"Initialize profile information dictionary. Error invalid StreamProfile, {item}") + + return len(streamProfileDict.items()) > 0 + +def initResultDir(): + global resultPath + timeText = datetime.now().strftime("%Y-%m-%d_%H%M%S") + resultPath = f"{sourceRootPath}/results-{timeText}" + if not os.path.exists(resultPath): + os.makedirs(resultPath) + +def isFrameFile(fileName): + fileExt = os.path.splitext(fileName) + if len(fileExt) < 2: + return False + + frameExts = {".jpeg", ".jpg", ".png", ".raw", "bmp"} + return fileExt[1] in frameExts + +def extract_number(filename): + match_d = re.search(r'_d(\d+)', filename) + if match_d: + return int(match_d.group(1)) + + match_g = re.search(r'_g(\d+)', filename) + if match_g: + return int(match_g.group(1)) + + return float('inf') + +def initPictureInfoDictionary(rootFilePath, pictureInfoDict): + frameFileCount = 0 + for dirpath, dirnames, filenames in os.walk(rootFilePath): + filenames.sort(key=extract_number) # Sort files by numbers following '_d' and '_g' in filename, ascending + for fileName in filenames: + filePath = os.path.join(dirpath, fileName) + if not isFrameFile(fileName): + continue + + frameFileCount += 1 + fileNameNoExt = os.path.splitext(fileName)[0] + pictureNameList = fileNameNoExt.split('_') + deviceId = pictureNameList[2][5:] + sensorType = pictureNameList[0].replace('#', '_') + syncTimeStamp = int(pictureNameList[3][1:]) + exp = str(pictureNameList[6][0:]) + gain = str(pictureNameList[7][0:]) + + # Create structure + pictureInfo = PictureInfo() + info = pictureInfo.make_struct(deviceId, sensorType, syncTimeStamp, filePath, os.path.basename(dirpath), os.path.splitext(fileName)[1],exp,gain) + + # Format dictionary: one key corresponds to one array + pictureInfoDict.setdefault(deviceId, []).append(info) + + if 0 == frameFileCount: + print("initialize pictureInfoDict failed. Not found frame file") + + +def matchFrame(pictureInfoDict): + global primaryId, frameRate + global streamProfileDict + + # Get comparison image array, use Color array of the first device for comparison + compareList = [] + for key in pictureInfoDict: + listTmp = list(pictureInfoDict[key]) + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == 'color': + compareList.append(info) + + # Dynamically analyze according to stream situation to reduce loop count + hasColorProfile = 'OB_SENSOR_COLOR' in streamProfileDict + hasDepthProfile = 'OB_SENSOR_DEPTH' in streamProfileDict + hasIRProfile = 'OB_SENSOR_IR' in streamProfileDict + hasIRLeftProfile = 'OB_SENSOR_IR_LEFT' in streamProfileDict + hasIRRightProfile = 'OB_SENSOR_IR_RIGHT' in streamProfileDict + + # Match adjacent frames + resultDict = {} + consumedList = [] + dictIndex = 0 + frameTspHalfGap = int(1000.0/frameRate/2.0+0.5) + for comparePic in compareList: + resultDict.setdefault(dictIndex, []).append(comparePic) + for key in pictureInfoDict: + listTmp = list(pictureInfoDict[key]) + # Compare color + if hasColorProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'color' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Compare depth + if hasDepthProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'depth' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Compare IR + if hasIRProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'ir' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Compare IR Left + if hasIRLeftProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'ir_left' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Compare IR Right + if hasIRRightProfile: + for info in listTmp: + if info.deviceId == primaryId and info.sensorType == comparePic.sensorType: + continue + + if info in consumedList: + continue + + if info.sensorType == 'ir_right' and abs(info.syncTimeStamp - comparePic.syncTimeStamp) < frameTspHalfGap: + resultDict.setdefault(dictIndex, []).append(info) + consumedList.append(info) + break + + # Calculate deviation + minTsp = min(resultDict[dictIndex], key=lambda x: x.syncTimeStamp) + for info in resultDict[dictIndex]: + info.tspDiff = info.syncTimeStamp - minTsp.syncTimeStamp + + dictIndex += 1 + + return resultDict + + +def safe_make_dir(path): + if not os.path.exists(path): + os.makedirs(path) + + +def handleSyncFrames(): + global resultPath + global sourceFramesPath + global streamProfileDict + + fp = open(f"{resultPath}/frameMatchLog.txt", "w") + + if not initProfileInfoDict(): + print("Initialize stream profile dictionary failed. exit") + return + print(f"Stream profiles: {streamProfileDict}") + streamProfileCount = len(streamProfileDict.items()) + + pictureInfoDict = {} + + initPictureInfoDictionary(Path(sourceFramesPath), pictureInfoDict) + if len(pictureInfoDict) <= 0: + print("init pictureInfoDict failed. pictureInfoDict.len = 0") + return + + # # Dump pictureInfoDict + # for key in pictureInfoDict: + # print("===================key:%s" % key) + # listTmp = list(pictureInfoDict[key]) + # for info in listTmp: + # print("=====================value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % (info.deviceId,info.sensorType,info.syncTimeStamp,info.picturePath)) + + deviceCount = getDeviceCount() + print("=================device count:%d" % deviceCount) + + resultDict = {} + resultDict = matchFrame(pictureInfoDict) + + for key in resultDict: + fp.write("===================result key:%s\n" % key) + print("===================result key:%s" % key) + listTmp = list(resultDict[key]) + for info in listTmp: + fp.write("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s\n" % ( + info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) + print("=====================result value : deviceId:%s\tsensorType:%s\tsyncTimeStamp:%s\tpicturePath:%s" % ( + info.deviceId, info.sensorType, info.syncTimeStamp, info.picturePath)) + + matchPath = f"{resultPath}/matchFrames/" + safe_make_dir(matchPath) + notMatchPath = f"{resultPath}/notMatchFrames/" + abnormalPath = f"{resultPath}/abnormal/" + + for key in resultDict: + listTmp = list(resultDict[key]) + if (len(listTmp) == (deviceCount * streamProfileCount)): + haveAbnormalData = False + for info in listTmp: + if info.tspDiff >= tspRangeThreshold: + path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + "_"+ str(info.exp) + "_"+ str(info.gain) + info.fileExt + shutil.copy(info.picturePath, path) + haveAbnormalData = True + else: + path = matchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_"+ str(info.exp) + "_"+ str(info.gain) + info.fileExt + shutil.copy(info.picturePath, path) + + if haveAbnormalData: + safe_make_dir(abnormalPath) + for info in listTmp: + if info.tspDiff >= tspRangeThreshold: + path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_xxxxxx" + "_"+ str(info.exp) + "_"+ str(info.gain) + info.fileExt + shutil.copy(info.picturePath, path) + else: + path = abnormalPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_"+ str(info.exp) + "_"+ str(info.gain) + info.fileExt + shutil.copy(info.picturePath, path) + else: + safe_make_dir(notMatchPath) + for info in listTmp: + newFilePath = notMatchPath + str(key) + "_" + info.sensorType + "_" + info.deviceIdFull + "_" + str( + info.syncTimeStamp) + "_[" + str(info.tspDiff) + "]" + "_"+ str(info.exp) + "_"+ str(info.gain) + info.fileExt + shutil.copy(info.picturePath, newFilePath) + +def main(): + if not initPrimaryId(): + print("Initialize primaryId failed. exit.") + return + + if not initSyncConfigParams(): + print("Initialized Sync config parameter failed. exit.") + return + + initResultDir() + + print(f"PrimaryId={primaryId}, frameRate={frameRate}, tspRangeThreshold={tspRangeThreshold}") + handleSyncFrames() + + return + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description="Synchronize frames support for 'Orbbec Devices'") + parser.add_argument('frames_dir', type=str, help="Frames directory") + parser.add_argument('main_script_root_dir', type=str, help="SyncFramesMain.py working directory") + args = parser.parse_args() + + sourceRootPath = args.frames_dir + sourceFramesPath = f"{args.frames_dir}/TotalModeFrames" + mainPythonWorkPath = args.main_script_root_dir + print(f"Start of CommonFrameMatch synchronize frame. sourceRootPath={sourceRootPath}") + + main() + + print("Finish of CommonFrameMatch synchronize frame.") diff --git a/orbbec_camera_msgs/msg/DeviceInfo.msg b/orbbec_camera_msgs/msg/DeviceInfo.msg index 4763a37a..4a035711 100644 --- a/orbbec_camera_msgs/msg/DeviceInfo.msg +++ b/orbbec_camera_msgs/msg/DeviceInfo.msg @@ -1,7 +1,7 @@ -std_msgs/Header header -string name -string serial_number -string firmware_version -string supported_min_sdk_version -string current_sdk_version -string hardware_version +std_msgs/Header header +string name +string serial_number +string firmware_version +string supported_min_sdk_version +string current_sdk_version +string hardware_version diff --git a/orbbec_camera_msgs/srv/GetCameraInfo.srv b/orbbec_camera_msgs/srv/GetCameraInfo.srv index b68fb771..64b5d0f0 100644 --- a/orbbec_camera_msgs/srv/GetCameraInfo.srv +++ b/orbbec_camera_msgs/srv/GetCameraInfo.srv @@ -1,2 +1,2 @@ ---- -sensor_msgs/CameraInfo info +--- +sensor_msgs/CameraInfo info diff --git a/orbbec_camera_msgs/srv/GetDeviceInfo.srv b/orbbec_camera_msgs/srv/GetDeviceInfo.srv index be08a553..32f711d2 100644 --- a/orbbec_camera_msgs/srv/GetDeviceInfo.srv +++ b/orbbec_camera_msgs/srv/GetDeviceInfo.srv @@ -1,4 +1,4 @@ ---- -DeviceInfo info -bool success +--- +DeviceInfo info +bool success string message \ No newline at end of file diff --git a/orbbec_description/urdf/astra_2.urdf.xacro b/orbbec_description/urdf/astra_2.urdf.xacro index d3a4a3f1..295b0bac 100755 --- a/orbbec_description/urdf/astra_2.urdf.xacro +++ b/orbbec_description/urdf/astra_2.urdf.xacro @@ -1,418 +1,418 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/orbbec_description/urdf/gemini_2.urdf.xacro b/orbbec_description/urdf/gemini_2.urdf.xacro index dab6f664..20125eca 100755 --- a/orbbec_description/urdf/gemini_2.urdf.xacro +++ b/orbbec_description/urdf/gemini_2.urdf.xacro @@ -1,471 +1,471 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/orbbec_description/urdf/gemini_2_L.urdf.xacro b/orbbec_description/urdf/gemini_2_L.urdf.xacro index 27064d92..4f9805bd 100644 --- a/orbbec_description/urdf/gemini_2_L.urdf.xacro +++ b/orbbec_description/urdf/gemini_2_L.urdf.xacro @@ -1,524 +1,524 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/orbbec_description/urdf/gemini_335_L_336_L.urdf.xacro b/orbbec_description/urdf/gemini_335_L_336_L.urdf.xacro index 676e76f2..43733811 100644 --- a/orbbec_description/urdf/gemini_335_L_336_L.urdf.xacro +++ b/orbbec_description/urdf/gemini_335_L_336_L.urdf.xacro @@ -1,524 +1,524 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a1146a6e54a5ffe3b3a06eecbf00559a2644636a Mon Sep 17 00:00:00 2001 From: slz Date: Thu, 6 Aug 2026 11:04:51 +0800 Subject: [PATCH 24/48] fix: let rclcpp handle shutdown signals --- orbbec_camera/src/ob_camera_node_driver.cpp | 89 +++++++++------------ 1 file changed, 36 insertions(+), 53 deletions(-) diff --git a/orbbec_camera/src/ob_camera_node_driver.cpp b/orbbec_camera/src/ob_camera_node_driver.cpp index 98c6ef07..2e0fb382 100644 --- a/orbbec_camera/src/ob_camera_node_driver.cpp +++ b/orbbec_camera/src/ob_camera_node_driver.cpp @@ -71,63 +71,46 @@ std::string makeDefaultSdkLogFileName() { } } // namespace -void signalHandler(int sig) { - // Prevent recursive signal handling +void crashSignalHandler(int sig) { + // Prevent recursive crash signal handling. static std::atomic in_signal_handler{false}; if (in_signal_handler.exchange(true)) { - // Already in signal handler, force exit immediately _exit(sig); } std::cerr << "Received signal: " << sig << std::endl; - if (sig == SIGINT || sig == SIGTERM) { - static int signal_count = 0; - signal_count++; + std::filesystem::path log_dir = getLogDirectoryForCamera(g_camera_name); - if (signal_count <= 3) { - rclcpp::shutdown(); - // Give some time for graceful shutdown - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - } else if (signal_count >= 5) { - // Force exit after second signal - std::cout << "Force exit due to multiple signals" << std::endl; - _exit(sig); - } - in_signal_handler.store(false); - } else { - std::filesystem::path log_dir = getLogDirectoryForCamera(g_camera_name); + // get current time + std::time_t now = std::time(nullptr); + std::tm *local_time = std::localtime(&now); - // get current time - std::time_t now = std::time(nullptr); - std::tm *local_time = std::localtime(&now); + // format date and time, format "2024_05_20_12_34_56" + std::ostringstream time_stream; + time_stream << std::put_time(local_time, "%Y_%m_%d_%H_%M_%S"); - // format date and time to string, format as "2024_05_20_12_34_56" - std::ostringstream time_stream; - time_stream << std::put_time(local_time, "%Y_%m_%d_%H_%M_%S"); + // generate log file name + std::string log_file_name = g_camera_name + "_crash_stack_trace_" + time_stream.str() + ".log"; + std::filesystem::path log_file_path = log_dir / log_file_name; - // generate log file name - std::string log_file_name = g_camera_name + "_crash_stack_trace_" + time_stream.str() + ".log"; - std::filesystem::path log_file_path = log_dir / log_file_name; - - if (!std::filesystem::exists(log_dir)) { - std::filesystem::create_directories(log_dir); - } - - std::cerr << "Log crash stack trace to " << log_file_path.string() << std::endl; - std::ofstream log_file(log_file_path, std::ios::app); - - if (log_file.is_open()) { - log_file << "Received signal: " << sig << std::endl; - - backward::StackTrace st; - st.load_here(32); // Capture stack - backward::Printer p; - p.print(st, log_file); // Print stack to log file - } - - log_file.close(); - _exit(sig); // Use _exit instead of exit to avoid cleanup that may crash + if (!std::filesystem::exists(log_dir)) { + std::filesystem::create_directories(log_dir); } + + std::cerr << "Log crash stack trace to " << log_file_path.string() << std::endl; + std::ofstream log_file(log_file_path, std::ios::app); + + if (log_file.is_open()) { + log_file << "Received signal: " << sig << std::endl; + + backward::StackTrace st; + st.load_here(32); // Capture stack + backward::Printer p; + p.print(st, log_file); // Print stack to log file + } + + log_file.close(); + _exit(sig); // Use _exit instead of exit to avoid cleanup that may crash } namespace orbbec_camera { @@ -255,13 +238,13 @@ OBCameraNodeDriver::~OBCameraNodeDriver() { } void OBCameraNodeDriver::init() { - // Set signal handlers for crash reporting - signal(SIGSEGV, signalHandler); // segment fault - signal(SIGABRT, signalHandler); // abort - signal(SIGFPE, signalHandler); // float point exception - signal(SIGILL, signalHandler); // illegal instruction - signal(SIGINT, signalHandler); - signal(SIGTERM, signalHandler); + // Keep SIGINT/SIGTERM managed by rclcpp. Overriding them from a composable node bypasses + // rclcpp's deferred signal handling and can leave SDK streaming threads running after the ROS + // context has already been shut down. + signal(SIGSEGV, crashSignalHandler); // segment fault + signal(SIGABRT, crashSignalHandler); // abort + signal(SIGFPE, crashSignalHandler); // float point exception + signal(SIGILL, crashSignalHandler); // illegal instruction ob::Context::setExtensionsDirectory(extension_path_.c_str()); g_camera_name = declare_parameter("camera_name", g_camera_name); auto log_level_str = declare_parameter("log_level", "info"); From 5cfb1fa7f26a2856b587a9189223152b75d12fbd Mon Sep 17 00:00:00 2001 From: ob-yalian Date: Fri, 7 Aug 2026 15:59:41 +0800 Subject: [PATCH 25/48] fix: remove redundant sync mode checks in setupDevices --- orbbec_camera/src/ob_camera_node.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index 615941db..7a31ff20 100644 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -1817,8 +1817,6 @@ void OBCameraNode::setupDevices() { << (device_->getBoolProperty(OB_PROP_SDK_GYRO_FRAME_TRANSFORMED_BOOL) ? "ON" : "OFF")); } if (isGemini335PID(pid_) && !intra_camera_sync_reference_.empty() && - (sync_mode_ == OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING || - sync_mode_ == OB_MULTI_DEVICE_SYNC_MODE_HARDWARE_TRIGGERING) && device_->isPropertySupported(OB_PROP_INTRA_CAMERA_SYNC_REFERENCE_INT, OB_PERMISSION_WRITE)) { if (intra_camera_sync_reference_ == "Start") { TRY_TO_SET_PROPERTY(setIntProperty, OB_PROP_INTRA_CAMERA_SYNC_REFERENCE_INT, 0); From 7c5e26f13b298c59f27ab9587ba9d64586cdd93a Mon Sep 17 00:00:00 2001 From: slz Date: Tue, 11 Aug 2026 10:29:35 +0800 Subject: [PATCH 26/48] feat: rotate frame timestamp CSV files --- .../frame_timestamp_csv_logger.h | 9 +- .../src/frame_timestamp_csv_logger.cpp | 88 ++++++++++++++++--- 2 files changed, 84 insertions(+), 13 deletions(-) diff --git a/orbbec_camera/include/orbbec_camera/frame_timestamp_csv_logger.h b/orbbec_camera/include/orbbec_camera/frame_timestamp_csv_logger.h index e8fe8bfc..3ce38971 100644 --- a/orbbec_camera/include/orbbec_camera/frame_timestamp_csv_logger.h +++ b/orbbec_camera/include/orbbec_camera/frame_timestamp_csv_logger.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -139,18 +140,22 @@ class FrameTimestampCsvLogger { static std::string csvHeader(); void writerThreadMain(); - void openCsvIfNeeded(); + std::string csvFilePathForIndex(uint64_t file_index) const; + bool openCsvFile(uint64_t file_index); + bool rotateCsvFile(); rclcpp::Logger logger_; bool enabled_ = false; bool csv_enabled_ = false; bool drop_log_enabled_ = false; std::atomic_bool shutdown_requested_{false}; - bool csv_writer_failed_ = false; + std::atomic_bool csv_writer_failed_{false}; bool queue_warning_active_ = false; std::string csv_file_path_; std::ofstream csv_stream_; std::thread writer_thread_; + uint64_t csv_file_index_ = 0; + uint64_t csv_rows_written_ = 0; uint64_t next_row_id_ = 1; std::unordered_map pending_rows_; diff --git a/orbbec_camera/src/frame_timestamp_csv_logger.cpp b/orbbec_camera/src/frame_timestamp_csv_logger.cpp index 3b516e07..ff3b8fb6 100644 --- a/orbbec_camera/src/frame_timestamp_csv_logger.cpp +++ b/orbbec_camera/src/frame_timestamp_csv_logger.cpp @@ -12,6 +12,8 @@ namespace { constexpr size_t kCompletedQueueSoftLimit = 1000; constexpr size_t kFlushBatchSize = 100; +// The header occupies the first row, leaving 1,024,575 rows for frame data. +constexpr uint64_t kMaxCsvRowsPerFileIncludingHeader = 1'024'576; constexpr auto kFlushInterval = std::chrono::seconds(1); int64_t getExpectedIntervalUs(const std::shared_ptr &frame) { @@ -58,7 +60,10 @@ FrameTimestampCsvLogger::FrameTimestampCsvLogger(bool drop_log_enabled, } if (csv_enabled_) { - openCsvIfNeeded(); + if (!openCsvFile(0)) { + csv_enabled_ = false; + csv_writer_failed_ = true; + } } enabled_ = csv_enabled_ || drop_log_enabled_; @@ -568,10 +573,33 @@ void FrameTimestampCsvLogger::writerThreadMain() { } for (const auto &row : rows_to_write) { - if (csv_stream_.is_open()) { - csv_stream_ << serializeRow(row) << "\n"; - rows_since_flush++; + if (csv_rows_written_ >= kMaxCsvRowsPerFileIncludingHeader) { + if (!rotateCsvFile()) { + csv_writer_failed_ = true; + break; + } + rows_since_flush = 0; + last_flush = std::chrono::steady_clock::now(); } + + if (!csv_stream_.is_open()) { + csv_writer_failed_ = true; + break; + } + + csv_stream_ << serializeRow(row) << "\n"; + if (!csv_stream_) { + RCLCPP_ERROR_STREAM(logger_, "Failed to write frame timestamp CSV file: " + << csvFilePathForIndex(csv_file_index_)); + csv_writer_failed_ = true; + break; + } + ++csv_rows_written_; + ++rows_since_flush; + } + + if (csv_writer_failed_) { + break; } const auto now = std::chrono::steady_clock::now(); @@ -589,16 +617,54 @@ void FrameTimestampCsvLogger::writerThreadMain() { } } -void FrameTimestampCsvLogger::openCsvIfNeeded() { - csv_stream_.open(csv_file_path_, std::ios::out | std::ios::trunc); - if (!csv_stream_.is_open()) { - RCLCPP_ERROR_STREAM(logger_, "Failed to open frame timestamp CSV file: " << csv_file_path_); - csv_enabled_ = false; - csv_writer_failed_ = true; - return; +std::string FrameTimestampCsvLogger::csvFilePathForIndex(uint64_t file_index) const { + if (file_index == 0) { + return csv_file_path_; } + + const std::filesystem::path original_path(csv_file_path_); + const auto indexed_filename = original_path.stem().string() + "_" + std::to_string(file_index) + + original_path.extension().string(); + return (original_path.parent_path() / indexed_filename).string(); +} + +bool FrameTimestampCsvLogger::openCsvFile(uint64_t file_index) { + const auto file_path = csvFilePathForIndex(file_index); + csv_stream_.clear(); + csv_stream_.open(file_path, std::ios::out | std::ios::trunc); + if (!csv_stream_.is_open()) { + RCLCPP_ERROR_STREAM(logger_, "Failed to open frame timestamp CSV file: " << file_path); + return false; + } + csv_stream_ << csvHeader() << "\n"; csv_stream_.flush(); + if (!csv_stream_) { + RCLCPP_ERROR_STREAM(logger_, "Failed to write frame timestamp CSV header: " << file_path); + csv_stream_.close(); + return false; + } + + csv_file_index_ = file_index; + csv_rows_written_ = 1; + return true; +} + +bool FrameTimestampCsvLogger::rotateCsvFile() { + if (csv_stream_.is_open()) { + csv_stream_.flush(); + csv_stream_.close(); + } + + const auto next_file_index = csv_file_index_ + 1; + if (!openCsvFile(next_file_index)) { + return false; + } + + RCLCPP_INFO_STREAM(logger_, "Frame timestamp CSV reached " + << kMaxCsvRowsPerFileIncludingHeader << " rows; continuing in " + << csvFilePathForIndex(csv_file_index_)); + return true; } } // namespace orbbec_camera From 7981240a4023274332e2d7a67c54a814dc64ab66 Mon Sep 17 00:00:00 2001 From: ob-yalian Date: Tue, 11 Aug 2026 13:44:05 +0800 Subject: [PATCH 27/48] fix: update optional boolean parameters to allow unset values in launch configuration --- orbbec_camera/launch/gemini_330_series.launch.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/orbbec_camera/launch/gemini_330_series.launch.py b/orbbec_camera/launch/gemini_330_series.launch.py index 741cdc94..a8860183 100644 --- a/orbbec_camera/launch/gemini_330_series.launch.py +++ b/orbbec_camera/launch/gemini_330_series.launch.py @@ -7,6 +7,12 @@ from launch_ros.actions import PushRosNamespace, ComposableNodeContainer, Node from launch_ros.descriptions import ComposableNode +OPTIONAL_BOOLEAN_PARAMS = { + 'enable_hardware_noise_removal_filter', + 'enable_noise_removal_filter', +} + + def load_yaml(file_path): with open(file_path, 'r') as f: return yaml.safe_load(f) @@ -47,6 +53,10 @@ def load_parameters(context, args): result = {} for key, value in default_params.items(): + # An empty optional boolean means "auto". Do not pass it to the ROS node, + # because a declared bool parameter cannot represent an unset value. + if key in OPTIONAL_BOOLEAN_PARAMS and value == '': + continue if key in skip_convert: result[key] = value elif 'enable_pub_plugins' in key: @@ -225,8 +235,9 @@ def generate_launch_description(): DeclareLaunchArgument('enable_hdr_merge', default_value='false'), DeclareLaunchArgument('enable_sequence_id_filter', default_value='false'), DeclareLaunchArgument('enable_threshold_filter', default_value='false'), - DeclareLaunchArgument('enable_hardware_noise_removal_filter', default_value='false'), - DeclareLaunchArgument('enable_noise_removal_filter', default_value='true'), + # Empty means that the node will not change the device's current setting. + DeclareLaunchArgument('enable_hardware_noise_removal_filter', default_value=''), + DeclareLaunchArgument('enable_noise_removal_filter', default_value=''), DeclareLaunchArgument('enable_disp_outliers_filter', default_value='false'), DeclareLaunchArgument('enable_spatial_filter', default_value='false'), DeclareLaunchArgument('enable_temporal_filter', default_value='false'), From f09051fb03ad6a9fb00fd9465f1bee54149151e6 Mon Sep 17 00:00:00 2001 From: slz Date: Tue, 11 Aug 2026 13:56:40 +0800 Subject: [PATCH 28/48] fix: reorganize bundled SDK layout Keep the vendor SDK filenames unchanged. Downstream packages can find the versioned orbbec_camera ROS package and link its installed OrbbecSDK library instead of requiring OrbbecSDKConfigVersion.cmake. --- .gitignore | 1 + orbbec_camera/CMakeLists.txt | 5 +- .../include/libobsensor/ObSensor.h | 0 .../include/libobsensor/ObSensor.hpp | 0 .../include/libobsensor/h/Advanced.h | 0 .../include/libobsensor/h/ApplicationConfig.h | 0 .../include/libobsensor/h/Context.h | 0 .../include/libobsensor/h/Device.h | 0 .../{ => arm64}/include/libobsensor/h/Error.h | 0 .../include/libobsensor/h/Export.h | 0 .../include/libobsensor/h/Filter.h | 0 .../{ => arm64}/include/libobsensor/h/Frame.h | 0 .../include/libobsensor/h/MultipleDevices.h | 0 .../include/libobsensor/h/ObTypes.h | 0 .../include/libobsensor/h/Pipeline.h | 0 .../include/libobsensor/h/Property.h | 0 .../include/libobsensor/h/RecordPlayback.h | 0 .../include/libobsensor/h/Sensor.h | 0 .../include/libobsensor/h/StreamProfile.h | 0 .../include/libobsensor/h/TypeHelper.h | 0 .../{ => arm64}/include/libobsensor/h/Utils.h | 0 .../include/libobsensor/h/Version.h | 0 .../libobsensor/hpp/ApplicationConfig.hpp | 0 .../include/libobsensor/hpp/Context.hpp | 0 .../include/libobsensor/hpp/Device.hpp | 0 .../include/libobsensor/hpp/Error.hpp | 0 .../include/libobsensor/hpp/Filter.hpp | 0 .../include/libobsensor/hpp/Frame.hpp | 0 .../include/libobsensor/hpp/Pipeline.hpp | 0 .../libobsensor/hpp/RecordPlayback.hpp | 0 .../include/libobsensor/hpp/Sensor.hpp | 0 .../include/libobsensor/hpp/StreamProfile.hpp | 0 .../include/libobsensor/hpp/TypeHelper.hpp | 0 .../include/libobsensor/hpp/Types.hpp | 0 .../include/libobsensor/hpp/Utils.hpp | 0 .../include/libobsensor/hpp/Version.hpp | 0 .../lib}/OrbbecSDKConfig-release.cmake | 0 .../arm64 => arm64/lib}/OrbbecSDKConfig.cmake | 0 .../lib}/OrbbecSDKVersion.cmake | 0 .../extensions/depthengine/libdepthengine.so | 0 .../depthengine/libdepthengine.so.2.0 | Bin .../libengine_infer_encry.so | Bin .../libenhanced_depth_filter.so | Bin .../extensions/filters/libFilterProcessor.so | Bin .../extensions/filters/libob_priv_filter.so | Bin .../firmwareupdater/libfirmwareupdater.so | Bin .../frameprocessor/libob_frame_processor.so | Bin .../{lib/arm64 => arm64/lib}/libOrbbecSDK.so | 0 .../arm64 => arm64/lib}/libOrbbecSDK.so.2 | 0 .../arm64 => arm64/lib}/libOrbbecSDK.so.2.9.3 | Bin .../SDK/x64/include/libobsensor/ObSensor.h | 24 + .../SDK/x64/include/libobsensor/ObSensor.hpp | 22 + .../SDK/x64/include/libobsensor/h/Advanced.h | 419 +++ .../include/libobsensor/h/ApplicationConfig.h | 267 ++ .../SDK/x64/include/libobsensor/h/Context.h | 323 +++ .../SDK/x64/include/libobsensor/h/Device.h | 1068 ++++++++ .../SDK/x64/include/libobsensor/h/Error.h | 85 + .../SDK/x64/include/libobsensor/h/Export.h | 43 + .../SDK/x64/include/libobsensor/h/Filter.h | 283 ++ .../SDK/x64/include/libobsensor/h/Frame.h | 715 +++++ .../include/libobsensor/h/MultipleDevices.h | 131 + .../SDK/x64/include/libobsensor/h/ObTypes.h | 2288 ++++++++++++++++ .../SDK/x64/include/libobsensor/h/Pipeline.h | 411 +++ .../SDK/x64/include/libobsensor/h/Property.h | 1160 ++++++++ .../include/libobsensor/h/RecordPlayback.h | 141 + .../SDK/x64/include/libobsensor/h/Sensor.h | 138 + .../x64/include/libobsensor/h/StreamProfile.h | 505 ++++ .../x64/include/libobsensor/h/TypeHelper.h | 165 ++ .../SDK/x64/include/libobsensor/h/Utils.h | 136 + .../SDK/x64/include/libobsensor/h/Version.h | 56 + .../libobsensor/hpp/ApplicationConfig.hpp | 404 +++ .../x64/include/libobsensor/hpp/Context.hpp | 424 +++ .../x64/include/libobsensor/hpp/Device.hpp | 2006 ++++++++++++++ .../SDK/x64/include/libobsensor/hpp/Error.hpp | 124 + .../x64/include/libobsensor/hpp/Filter.hpp | 2346 +++++++++++++++++ .../SDK/x64/include/libobsensor/hpp/Frame.hpp | 1344 ++++++++++ .../x64/include/libobsensor/hpp/Pipeline.hpp | 528 ++++ .../libobsensor/hpp/RecordPlayback.hpp | 197 ++ .../x64/include/libobsensor/hpp/Sensor.hpp | 239 ++ .../include/libobsensor/hpp/StreamProfile.hpp | 603 +++++ .../include/libobsensor/hpp/TypeHelper.hpp | 234 ++ .../SDK/x64/include/libobsensor/hpp/Types.hpp | 5 + .../SDK/x64/include/libobsensor/hpp/Utils.hpp | 206 ++ .../x64/include/libobsensor/hpp/Version.hpp | 62 + .../lib}/OrbbecSDKConfig-release.cmake | 0 .../x64 => x64/lib}/OrbbecSDKConfig.cmake | 0 .../x64 => x64/lib}/OrbbecSDKVersion.cmake | 0 .../extensions/depthengine/libdepthengine.so | 0 .../depthengine/libdepthengine.so.2.0 | Bin .../extensions/filters/libFilterProcessor.so | Bin .../extensions/filters/libob_priv_filter.so | Bin .../firmwareupdater/libfirmwareupdater.so | Bin .../frameprocessor/libob_frame_processor.so | Bin .../SDK/{lib/x64 => x64/lib}/libOrbbecSDK.so | 0 .../{lib/x64 => x64/lib}/libOrbbecSDK.so.2 | 0 .../x64 => x64/lib}/libOrbbecSDK.so.2.9.3 | Bin 96 files changed, 17106 insertions(+), 2 deletions(-) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/ObSensor.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/ObSensor.hpp (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/Advanced.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/ApplicationConfig.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/Context.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/Device.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/Error.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/Export.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/Filter.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/Frame.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/MultipleDevices.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/ObTypes.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/Pipeline.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/Property.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/RecordPlayback.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/Sensor.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/StreamProfile.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/TypeHelper.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/Utils.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/h/Version.h (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/hpp/ApplicationConfig.hpp (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/hpp/Context.hpp (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/hpp/Device.hpp (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/hpp/Error.hpp (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/hpp/Filter.hpp (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/hpp/Frame.hpp (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/hpp/Pipeline.hpp (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/hpp/RecordPlayback.hpp (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/hpp/Sensor.hpp (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/hpp/StreamProfile.hpp (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/hpp/TypeHelper.hpp (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/hpp/Types.hpp (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/hpp/Utils.hpp (100%) rename orbbec_camera/SDK/{ => arm64}/include/libobsensor/hpp/Version.hpp (100%) rename orbbec_camera/SDK/{lib/arm64 => arm64/lib}/OrbbecSDKConfig-release.cmake (100%) rename orbbec_camera/SDK/{lib/arm64 => arm64/lib}/OrbbecSDKConfig.cmake (100%) rename orbbec_camera/SDK/{lib/arm64 => arm64/lib}/OrbbecSDKVersion.cmake (100%) rename orbbec_camera/SDK/{lib/arm64 => arm64/lib}/extensions/depthengine/libdepthengine.so (100%) rename orbbec_camera/SDK/{lib/arm64 => arm64/lib}/extensions/depthengine/libdepthengine.so.2.0 (100%) rename orbbec_camera/SDK/{lib/arm64 => arm64/lib}/extensions/filters/enhanced_depth_filter/libengine_infer_encry.so (100%) rename orbbec_camera/SDK/{lib/arm64 => arm64/lib}/extensions/filters/enhanced_depth_filter/libenhanced_depth_filter.so (100%) rename orbbec_camera/SDK/{lib/arm64 => arm64/lib}/extensions/filters/libFilterProcessor.so (100%) rename orbbec_camera/SDK/{lib/arm64 => arm64/lib}/extensions/filters/libob_priv_filter.so (100%) rename orbbec_camera/SDK/{lib/arm64 => arm64/lib}/extensions/firmwareupdater/libfirmwareupdater.so (100%) rename orbbec_camera/SDK/{lib/arm64 => arm64/lib}/extensions/frameprocessor/libob_frame_processor.so (100%) rename orbbec_camera/SDK/{lib/arm64 => arm64/lib}/libOrbbecSDK.so (100%) rename orbbec_camera/SDK/{lib/arm64 => arm64/lib}/libOrbbecSDK.so.2 (100%) rename orbbec_camera/SDK/{lib/arm64 => arm64/lib}/libOrbbecSDK.so.2.9.3 (100%) create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/ObSensor.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/ObSensor.hpp create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/Advanced.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/ApplicationConfig.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/Context.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/Device.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/Error.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/Export.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/Filter.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/Frame.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/MultipleDevices.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/ObTypes.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/Pipeline.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/Property.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/RecordPlayback.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/Sensor.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/StreamProfile.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/TypeHelper.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/Utils.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/h/Version.h create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/hpp/ApplicationConfig.hpp create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/hpp/Context.hpp create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/hpp/Device.hpp create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/hpp/Error.hpp create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/hpp/Filter.hpp create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/hpp/Frame.hpp create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/hpp/Pipeline.hpp create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/hpp/RecordPlayback.hpp create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/hpp/Sensor.hpp create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/hpp/StreamProfile.hpp create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/hpp/TypeHelper.hpp create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/hpp/Types.hpp create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/hpp/Utils.hpp create mode 100644 orbbec_camera/SDK/x64/include/libobsensor/hpp/Version.hpp rename orbbec_camera/SDK/{lib/x64 => x64/lib}/OrbbecSDKConfig-release.cmake (100%) rename orbbec_camera/SDK/{lib/x64 => x64/lib}/OrbbecSDKConfig.cmake (100%) rename orbbec_camera/SDK/{lib/x64 => x64/lib}/OrbbecSDKVersion.cmake (100%) rename orbbec_camera/SDK/{lib/x64 => x64/lib}/extensions/depthengine/libdepthengine.so (100%) rename orbbec_camera/SDK/{lib/x64 => x64/lib}/extensions/depthengine/libdepthengine.so.2.0 (100%) rename orbbec_camera/SDK/{lib/x64 => x64/lib}/extensions/filters/libFilterProcessor.so (100%) rename orbbec_camera/SDK/{lib/x64 => x64/lib}/extensions/filters/libob_priv_filter.so (100%) rename orbbec_camera/SDK/{lib/x64 => x64/lib}/extensions/firmwareupdater/libfirmwareupdater.so (100%) rename orbbec_camera/SDK/{lib/x64 => x64/lib}/extensions/frameprocessor/libob_frame_processor.so (100%) rename orbbec_camera/SDK/{lib/x64 => x64/lib}/libOrbbecSDK.so (100%) rename orbbec_camera/SDK/{lib/x64 => x64/lib}/libOrbbecSDK.so.2 (100%) rename orbbec_camera/SDK/{lib/x64 => x64/lib}/libOrbbecSDK.so.2.9.3 (100%) 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 From 1733d513f58ac2d417d2907d5b2b019e0b2ffffa Mon Sep 17 00:00:00 2001 From: slz Date: Tue, 11 Aug 2026 14:32:26 +0800 Subject: [PATCH 29/48] fix: preserve SIGTERM shutdown on older ROS 2 Forward SIGTERM to rclcpp's SIGINT path on releases that predate native SIGTERM handling, while leaving shutdown signal ownership with rclcpp on newer releases. --- orbbec_camera/src/ob_camera_node_driver.cpp | 26 ++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/orbbec_camera/src/ob_camera_node_driver.cpp b/orbbec_camera/src/ob_camera_node_driver.cpp index 2e0fb382..fab84cc1 100644 --- a/orbbec_camera/src/ob_camera_node_driver.cpp +++ b/orbbec_camera/src/ob_camera_node_driver.cpp @@ -22,6 +22,13 @@ #include #include #include +#if __has_include() +#include +#define ORBBEC_RCLCPP_HANDLES_SIGTERM \ + ((RCLCPP_VERSION_MAJOR > 13) || (RCLCPP_VERSION_MAJOR == 13 && RCLCPP_VERSION_MINOR >= 1)) +#else +#define ORBBEC_RCLCPP_HANDLES_SIGTERM 0 +#endif #include #include #include @@ -113,6 +120,14 @@ void crashSignalHandler(int sig) { _exit(sig); // Use _exit instead of exit to avoid cleanup that may crash } +#if !ORBBEC_RCLCPP_HANDLES_SIGTERM +void forwardSigtermToRclcpp(int) { + // Older rclcpp versions such as Foxy's only handle SIGINT. Forward SIGTERM to that signal-safe + // shutdown path instead of calling rclcpp::shutdown() directly from this signal handler. + kill(getpid(), SIGINT); +} +#endif + namespace orbbec_camera { backward::SignalHandling OBCameraNodeDriver::sh; @@ -238,9 +253,14 @@ OBCameraNodeDriver::~OBCameraNodeDriver() { } void OBCameraNodeDriver::init() { - // Keep SIGINT/SIGTERM managed by rclcpp. Overriding them from a composable node bypasses - // rclcpp's deferred signal handling and can leave SDK streaming threads running after the ROS - // context has already been shut down. + // Keep shutdown signals managed by rclcpp. Overriding them from a composable node bypasses its + // deferred signal handling and can leave SDK streaming threads running after the ROS context has + // already been shut down. +#if !ORBBEC_RCLCPP_HANDLES_SIGTERM + // Older rclcpp versions such as Foxy's predate native SIGTERM handling, so translate it to the + // SIGINT path that rclcpp does manage. Newer distributions handle both signals themselves. + signal(SIGTERM, forwardSigtermToRclcpp); +#endif signal(SIGSEGV, crashSignalHandler); // segment fault signal(SIGABRT, crashSignalHandler); // abort signal(SIGFPE, crashSignalHandler); // float point exception From 61ee663864286aa79844df6f0bb42d46132dac17 Mon Sep 17 00:00:00 2001 From: ob-yalian Date: Tue, 11 Aug 2026 16:44:22 +0800 Subject: [PATCH 30/48] feat: enhance GMSL camera support and configuration options --- orbbec_camera/examples/README.MD | 4 +--- .../gmsl_camera/multi_gmsl_camera.launch.py | 24 +++++++++++++++---- .../multi_gmsl_camera_synced.launch.py | 24 +++++++++++++++---- .../include/orbbec_camera/constants.h | 5 ++++ orbbec_camera/launch/gemini345_lg.launch.py | 2 ++ .../launch/gemini_301_series.launch.py | 2 ++ orbbec_camera/src/ob_camera_node_driver.cpp | 2 +- 7 files changed, 49 insertions(+), 14 deletions(-) diff --git a/orbbec_camera/examples/README.MD b/orbbec_camera/examples/README.MD index 7755bddf..51cd7ffd 100644 --- a/orbbec_camera/examples/README.MD +++ b/orbbec_camera/examples/README.MD @@ -7,8 +7,6 @@ These simple examples demonstrate how to easily use the camera with OrbbecSDK_RO | Name | Description | Experience Level | Document | | :---------------------------------------------------------------------------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | ----------------------------------------------------------------------------- | | [Net_camera](./net_camera) | How to use Net camera in OrbbecSDK_ROS2(Only Femto Mega nad Gemini 335Le) | ⭐️ | [Net_camera](https://orbbec.github.io/OrbbecSDK_ROS2/source/5_advanced_guide/configuration/net_camera.html) | -| [Gmsl_camera](./gmsl_camera) | How to use GMSL camera.(Only Gemini 335Lg) | ⭐️ | [Gmsl_camera](https://orbbec.github.io/OrbbecSDK_ROS2/source/5_advanced_guide/multi_camera/gmsl_camera.html) | +| [Gmsl_camera](./gmsl_camera) | How to use GMSL cameras (Gemini 335Lg, 338Lg, 345Lg, and 305g). | ⭐️ | [Gmsl_camera](https://orbbec.github.io/OrbbecSDK_ROS2/source/5_advanced_guide/multi_camera/gmsl_camera.html) | | [Benchmark](./benchmark) | The goal of this tool is to benchmark the performance of various OrbbecSDK_ROS2 camera configurations. | ⭐️⭐️ | [Benchmark](https://orbbec.github.io/OrbbecSDK_ROS2/source/5_advanced_guide/performance/benchmark.html) | | [Multi_camera_synced_verification_tool](./multi_camera_synced_verification_tool) | How to verify the synchronization accuracy of multi-camera synchronization. | ⭐️⭐️⭐️ | [Multi_camera_synced_verification_tool](https://orbbec.github.io/OrbbecSDK_ROS2/source/5_advanced_guide/multi_camera/multi_camera_synced_verification_tool.html) | - - diff --git a/orbbec_camera/examples/gmsl_camera/multi_gmsl_camera.launch.py b/orbbec_camera/examples/gmsl_camera/multi_gmsl_camera.launch.py index 139b08b9..03c64764 100644 --- a/orbbec_camera/examples/gmsl_camera/multi_gmsl_camera.launch.py +++ b/orbbec_camera/examples/gmsl_camera/multi_gmsl_camera.launch.py @@ -11,6 +11,19 @@ from launch.substitutions import TextSubstitution from launch_ros.descriptions import ComposableNode +GMSL_CAMERA_LAUNCH_DIRS = { + "gemini_330_gmsl.launch.py": ("examples", "gmsl_camera"), # Gemini 335Lg / 338Lg + "gemini_301_series.launch.py": ("launch",), # Gemini 305G / 309G + "gemini345_lg.launch.py": ("launch",), # Gemini 345Lg +} + + +def get_camera_launch_file(package_dir, launch_file_name): + return os.path.join( + package_dir, *GMSL_CAMERA_LAUNCH_DIRS[launch_file_name], launch_file_name + ) + + def load_yaml(file_path): with open(file_path, "r") as f: return yaml.safe_load(f) @@ -43,9 +56,6 @@ def convert_value(value): def generate_launch_description(): # Include launch files package_dir = get_package_share_directory("orbbec_camera") - launch_file_dir = os.path.join( - package_dir, "examples/gmsl_camera" #or launch - ) config_file_dir = os.path.join(package_dir, "config") secondary_config_file_path = os.path.join(config_file_dir, "camera_secondary_params.yaml") @@ -67,8 +77,10 @@ def generate_launch_description(): attach_to_shared_component_container_arg = TextSubstitution(text="true") launch1_include = IncludeLaunchDescription( + # Supported launch files: gemini_330_gmsl.launch.py, gemini_301_series.launch.py, + # and gemini345_lg.launch.py. PythonLaunchDescriptionSource( - os.path.join(launch_file_dir, "gemini_330_gmsl.launch.py") #or gemini345_lg.launch.py + get_camera_launch_file(package_dir, "gemini_330_gmsl.launch.py") ), launch_arguments={ "camera_name": "camera_01", @@ -82,8 +94,10 @@ def generate_launch_description(): ) launch2_include = IncludeLaunchDescription( + # Supported launch files: gemini_330_gmsl.launch.py, gemini_301_series.launch.py, + # and gemini345_lg.launch.py. PythonLaunchDescriptionSource( - os.path.join(launch_file_dir, "gemini_330_gmsl.launch.py")#or gemini345_lg.launch.py + get_camera_launch_file(package_dir, "gemini_330_gmsl.launch.py") ), launch_arguments={ "camera_name": "camera_02", diff --git a/orbbec_camera/examples/gmsl_camera/multi_gmsl_camera_synced.launch.py b/orbbec_camera/examples/gmsl_camera/multi_gmsl_camera_synced.launch.py index 5b172c43..3a1ca52a 100644 --- a/orbbec_camera/examples/gmsl_camera/multi_gmsl_camera_synced.launch.py +++ b/orbbec_camera/examples/gmsl_camera/multi_gmsl_camera_synced.launch.py @@ -11,6 +11,19 @@ from launch.substitutions import TextSubstitution from launch_ros.descriptions import ComposableNode +GMSL_CAMERA_LAUNCH_DIRS = { + "gemini_330_gmsl.launch.py": ("examples", "gmsl_camera"), # Gemini 335Lg / 338Lg + "gemini_301_series.launch.py": ("launch",), # Gemini 305G / 309G + "gemini345_lg.launch.py": ("launch",), # Gemini 345Lg +} + + +def get_camera_launch_file(package_dir, launch_file_name): + return os.path.join( + package_dir, *GMSL_CAMERA_LAUNCH_DIRS[launch_file_name], launch_file_name + ) + + def load_yaml(file_path): with open(file_path, "r") as f: return yaml.safe_load(f) @@ -43,9 +56,6 @@ def convert_value(value): def generate_launch_description(): # Include launch files package_dir = get_package_share_directory("orbbec_camera") - launch_file_dir = os.path.join( - package_dir, "examples/gmsl_camera" - ) config_file_dir = os.path.join(package_dir, "config") secondary_config_file_path = os.path.join(config_file_dir, "camera_secondary_params.yaml") @@ -67,8 +77,10 @@ def generate_launch_description(): attach_to_shared_component_container_arg = TextSubstitution(text="true") launch1_include = IncludeLaunchDescription( + # Supported launch files: gemini_330_gmsl.launch.py, gemini_301_series.launch.py, + # and gemini345_lg.launch.py. PythonLaunchDescriptionSource( - os.path.join(launch_file_dir, "gemini_330_gmsl.launch.py") + get_camera_launch_file(package_dir, "gemini_330_gmsl.launch.py") ), launch_arguments={ "camera_name": "camera_01", @@ -84,8 +96,10 @@ def generate_launch_description(): ) launch2_include = IncludeLaunchDescription( + # Supported launch files: gemini_330_gmsl.launch.py, gemini_301_series.launch.py, + # and gemini345_lg.launch.py. PythonLaunchDescriptionSource( - os.path.join(launch_file_dir, "gemini_330_gmsl.launch.py") + get_camera_launch_file(package_dir, "gemini_330_gmsl.launch.py") ), launch_arguments={ "camera_name": "camera_02", diff --git a/orbbec_camera/include/orbbec_camera/constants.h b/orbbec_camera/include/orbbec_camera/constants.h index 947a5df6..d52c1faf 100644 --- a/orbbec_camera/include/orbbec_camera/constants.h +++ b/orbbec_camera/include/orbbec_camera/constants.h @@ -154,4 +154,9 @@ inline bool isGemini305SeriesPID(uint32_t pid) { pid == GEMINI_309G_PID; } +inline bool isGmslCameraPID(uint32_t pid) { + return pid == GEMINI_335LG_PID || pid == GEMINI_338LG_PID || pid == GEMINI_345LG_PID || + pid == GEMINI_305G_PID || pid == GEMINI_309G_PID; +} + } // namespace orbbec_camera diff --git a/orbbec_camera/launch/gemini345_lg.launch.py b/orbbec_camera/launch/gemini345_lg.launch.py index 05fac10a..87e46fdd 100644 --- a/orbbec_camera/launch/gemini345_lg.launch.py +++ b/orbbec_camera/launch/gemini345_lg.launch.py @@ -222,6 +222,8 @@ def generate_launch_description(): DeclareLaunchArgument('config_file_path', default_value=''), DeclareLaunchArgument('enable_heartbeat', default_value='false'), DeclareLaunchArgument('enable_firmware_log', default_value='false'), + DeclareLaunchArgument('gmsl_trigger_fps', default_value='3000'), + DeclareLaunchArgument('enable_gmsl_trigger', default_value='false'), #color image transport plugins DeclareLaunchArgument('color.image_raw.enable_pub_plugins',default_value='["image_transport/compressed", "image_transport/raw", "image_transport/theora"]'), diff --git a/orbbec_camera/launch/gemini_301_series.launch.py b/orbbec_camera/launch/gemini_301_series.launch.py index 1c48e5a7..4339900b 100644 --- a/orbbec_camera/launch/gemini_301_series.launch.py +++ b/orbbec_camera/launch/gemini_301_series.launch.py @@ -274,6 +274,8 @@ def generate_launch_description(): DeclareLaunchArgument('config_file_path', default_value=''), DeclareLaunchArgument('enable_heartbeat', default_value='false'), DeclareLaunchArgument('enable_firmware_log', default_value='false'), + DeclareLaunchArgument('gmsl_trigger_fps', default_value='3000'), + DeclareLaunchArgument('enable_gmsl_trigger', default_value='false'), DeclareLaunchArgument('disparity_range_mode', default_value='-1'), DeclareLaunchArgument('disparity_search_offset', default_value='-1'), DeclareLaunchArgument('disparity_offset_config', default_value='false'), diff --git a/orbbec_camera/src/ob_camera_node_driver.cpp b/orbbec_camera/src/ob_camera_node_driver.cpp index f1674598..9afb2aec 100644 --- a/orbbec_camera/src/ob_camera_node_driver.cpp +++ b/orbbec_camera/src/ob_camera_node_driver.cpp @@ -1589,7 +1589,7 @@ void OBCameraNodeDriver::startDevice(const std::shared_ptr &list } auto pid = device->getDeviceInfo()->getPid(); - if (GEMINI_335LG_PID == pid || GEMINI_338LG_PID == pid) { + if (isGmslCameraPID(pid)) { ob_camera_node_->startGmslTrigger(); } // if (isGemini305SeriesPID(pid)) { From eda99faf427179f4c483e44ed64f1f9ba1d19e9b Mon Sep 17 00:00:00 2001 From: slz Date: Fri, 7 Aug 2026 15:42:44 +0800 Subject: [PATCH 31/48] fix: sort completed rows by row_id before writing CSV Sort completed rows in the writer thread so the CSV is always written in frame arrival order, even when color and depth frames complete concurrently on separate threads. --- orbbec_camera/src/frame_timestamp_csv_logger.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/orbbec_camera/src/frame_timestamp_csv_logger.cpp b/orbbec_camera/src/frame_timestamp_csv_logger.cpp index ff3b8fb6..2b34460d 100644 --- a/orbbec_camera/src/frame_timestamp_csv_logger.cpp +++ b/orbbec_camera/src/frame_timestamp_csv_logger.cpp @@ -572,6 +572,9 @@ void FrameTimestampCsvLogger::writerThreadMain() { rows_to_write.swap(completed_rows_); } + std::stable_sort(rows_to_write.begin(), rows_to_write.end(), + [](const auto &lhs, const auto &rhs) { return lhs.row_id < rhs.row_id; }); + for (const auto &row : rows_to_write) { if (csv_rows_written_ >= kMaxCsvRowsPerFileIncludingHeader) { if (!rotateCsvFile()) { From 29ee74835447a864890d8765782282cbec52eae9 Mon Sep 17 00:00:00 2001 From: ob-yalian Date: Wed, 12 Aug 2026 16:38:50 +0800 Subject: [PATCH 32/48] feat: enhance threshold filter configuration by allowing separate min and max values --- orbbec_camera/src/ob_camera_node.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index 3663e70a..b4874abe 100755 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -3243,6 +3243,10 @@ void OBCameraNode::setupDepthPostProcessFilter() { auto threshold_filter = filter->as(); if (threshold_filter_min_ != -1 && threshold_filter_max_ != -1) { threshold_filter->setValueRange(threshold_filter_min_, threshold_filter_max_); + } else if (threshold_filter_min_ != -1) { + threshold_filter->setConfigValue("min", threshold_filter_min_); + } else if (threshold_filter_max_ != -1) { + threshold_filter->setConfigValue("max", threshold_filter_max_); } RCLCPP_INFO_STREAM(logger_, "Current threshold filter value range: " << static_cast(threshold_filter->getConfigValue("min")) From 0facd2f1090736723805f6c886322ca08bee7b78 Mon Sep 17 00:00:00 2001 From: ob-yalian Date: Thu, 13 Aug 2026 15:43:36 +0800 Subject: [PATCH 33/48] feat: implement global image transport publisher management for camera reconnections --- .../include/orbbec_camera/image_publisher.h | 7 ++ orbbec_camera/src/image_publisher.cpp | 74 +++++++++++++++++++ orbbec_camera/src/ob_camera_node.cpp | 9 ++- orbbec_camera/src/ob_camera_node_driver.cpp | 1 + 4 files changed, 88 insertions(+), 3 deletions(-) diff --git a/orbbec_camera/include/orbbec_camera/image_publisher.h b/orbbec_camera/include/orbbec_camera/image_publisher.h index f114ec1d..32131d58 100644 --- a/orbbec_camera/include/orbbec_camera/image_publisher.h +++ b/orbbec_camera/include/orbbec_camera/image_publisher.h @@ -49,4 +49,11 @@ class image_transport_publisher : public image_publisher { private: std::shared_ptr image_publisher_impl; }; + +// Keep image_transport plugins and their DDS endpoints alive across camera reconnects. +std::shared_ptr getGlobalImageTransportPublisher(rclcpp::Node& node, + const std::string& topic_name, + const rmw_qos_profile_t& qos); +void releaseGlobalImageTransportPublisher(rclcpp::Node& node, const std::string& topic_name); +void clearGlobalImageTransportPublishers(rclcpp::Node& node); } // namespace orbbec_camera diff --git a/orbbec_camera/src/image_publisher.cpp b/orbbec_camera/src/image_publisher.cpp index 0998fedb..a207320e 100644 --- a/orbbec_camera/src/image_publisher.cpp +++ b/orbbec_camera/src/image_publisher.cpp @@ -14,8 +14,47 @@ #include "orbbec_camera/image_publisher.h" +#include +#include +#include + namespace orbbec_camera { +namespace { +using ImageTransportPublisherCacheKey = std::pair; + +struct CachedImageTransportPublisher { + rmw_qos_profile_t qos; + std::shared_ptr publisher; +}; + +using ImageTransportPublisherCache = + std::map; + +std::mutex& imageTransportPublisherCacheMutex() { + static std::mutex mutex; + return mutex; +} + +ImageTransportPublisherCache& imageTransportPublisherCache() { + static ImageTransportPublisherCache cache; + return cache; +} + +bool rmwTimeEqual(const rmw_time_t& lhs, const rmw_time_t& rhs) { + return lhs.sec == rhs.sec && lhs.nsec == rhs.nsec; +} + +bool qosProfilesEqual(const rmw_qos_profile_t& lhs, const rmw_qos_profile_t& rhs) { + return lhs.history == rhs.history && lhs.depth == rhs.depth && + lhs.reliability == rhs.reliability && lhs.durability == rhs.durability && + rmwTimeEqual(lhs.deadline, rhs.deadline) && rmwTimeEqual(lhs.lifespan, rhs.lifespan) && + lhs.liveliness == rhs.liveliness && + rmwTimeEqual(lhs.liveliness_lease_duration, rhs.liveliness_lease_duration) && + lhs.avoid_ros_namespace_conventions == rhs.avoid_ros_namespace_conventions; +} +} // namespace + // --- image_rcl_publisher implementation --- image_rcl_publisher::image_rcl_publisher(rclcpp::Node& node, const std::string& topic_name, const rmw_qos_profile_t& qos) { @@ -57,4 +96,39 @@ void image_transport_publisher::publish(sensor_msgs::msg::Image::UniquePtr image size_t image_transport_publisher::get_subscription_count() const { return image_publisher_impl->getNumSubscribers(); } + +std::shared_ptr getGlobalImageTransportPublisher(rclcpp::Node& node, + const std::string& topic_name, + const rmw_qos_profile_t& qos) { + const ImageTransportPublisherCacheKey key{node.get_fully_qualified_name(), topic_name}; + std::lock_guard lock(imageTransportPublisherCacheMutex()); + auto& cache = imageTransportPublisherCache(); + auto cached = cache.find(key); + if (cached != cache.end() && qosProfilesEqual(cached->second.qos, qos)) { + return cached->second.publisher; + } + + auto publisher = std::make_shared(node, topic_name, qos); + cache[key] = CachedImageTransportPublisher{qos, publisher}; + return publisher; +} + +void releaseGlobalImageTransportPublisher(rclcpp::Node& node, const std::string& topic_name) { + const ImageTransportPublisherCacheKey key{node.get_fully_qualified_name(), topic_name}; + std::lock_guard lock(imageTransportPublisherCacheMutex()); + imageTransportPublisherCache().erase(key); +} + +void clearGlobalImageTransportPublishers(rclcpp::Node& node) { + const std::string node_name = node.get_fully_qualified_name(); + std::lock_guard lock(imageTransportPublisherCacheMutex()); + auto& cache = imageTransportPublisherCache(); + for (auto publisher = cache.begin(); publisher != cache.end();) { + if (publisher->first.first == node_name) { + publisher = cache.erase(publisher); + } else { + ++publisher; + } + } +} } // namespace orbbec_camera diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index b4874abe..9d3b72c8 100755 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -5350,13 +5350,14 @@ void OBCameraNode::setupCameraInfo() { } void OBCameraNode::setupImagePublisher(const stream_index_pair &stream_index) { + const std::string topic = stream_name_[stream_index] + "/image_raw"; if (!enable_stream_[stream_index]) { + releaseGlobalImageTransportPublisher(*node_, topic); image_publishers_.erase(stream_index); compressed_image_publishers_.erase(stream_index); return; } - const std::string topic = stream_name_[stream_index] + "/image_raw"; auto image_qos_profile = getRMWQosProfileFromString(image_qos_[stream_index]); if (use_intra_process_) { image_qos_profile = rmw_qos_profile_default; @@ -5366,11 +5367,12 @@ void OBCameraNode::setupImagePublisher(const stream_index_pair &stream_index) { (stream_index == COLOR || stream_index == COLOR_LEFT || stream_index == COLOR_RIGHT) && format_[stream_index] == OB_FORMAT_MJPG; if (use_intra_process_ || is_mjpg_color_stream) { + releaseGlobalImageTransportPublisher(*node_, topic); image_publishers_[stream_index] = std::make_shared(*node_, topic, image_qos_profile); } else { image_publishers_[stream_index] = - std::make_shared(*node_, topic, image_qos_profile); + getGlobalImageTransportPublisher(*node_, topic, image_qos_profile); } if (is_mjpg_color_stream) { @@ -5535,7 +5537,7 @@ void OBCameraNode::syncSoftwareAlignment() { depth_unaligned_publisher_ = std::make_shared( *node_, "depth/image_unaligned", depth_image_qos_profile); } else { - depth_unaligned_publisher_ = std::make_shared( + depth_unaligned_publisher_ = getGlobalImageTransportPublisher( *node_, "depth/image_unaligned", depth_image_qos_profile); } } @@ -5543,6 +5545,7 @@ void OBCameraNode::syncSoftwareAlignment() { } align_filter_.reset(); + releaseGlobalImageTransportPublisher(*node_, "depth/image_unaligned"); depth_unaligned_publisher_.reset(); } diff --git a/orbbec_camera/src/ob_camera_node_driver.cpp b/orbbec_camera/src/ob_camera_node_driver.cpp index 9afb2aec..b18c1df1 100644 --- a/orbbec_camera/src/ob_camera_node_driver.cpp +++ b/orbbec_camera/src/ob_camera_node_driver.cpp @@ -273,6 +273,7 @@ OBCameraNodeDriver::~OBCameraNodeDriver() { orb_device_lock_shm_fd_ = -1; } shm_unlink(ORB_DEFAULT_LOCK_NAME.c_str()); + clearGlobalImageTransportPublishers(*this); } void OBCameraNodeDriver::init() { From 475dd3923e87575ac0369478236f1d0299b9326b Mon Sep 17 00:00:00 2001 From: ob-yalian Date: Tue, 18 Aug 2026 14:17:26 +0800 Subject: [PATCH 34/48] feat: add support for colorized depth images in camera node and update launch configurations --- README.MD | 6 ++ README_CN.MD | 5 ++ orbbec_camera/config/camera_params.yaml | 3 +- .../config/camera_secondary_params.yaml | 3 +- .../include/orbbec_camera/ob_camera_node.h | 3 + orbbec_camera/launch/astra.launch.py | 1 + orbbec_camera/launch/astra2.launch.py | 1 + orbbec_camera/launch/dabai_a.launch.py | 1 + orbbec_camera/launch/dabai_al.launch.py | 1 + orbbec_camera/launch/dabai_dcw2.launch.py | 1 + orbbec_camera/launch/dabai_max_pro.launch.py | 1 + orbbec_camera/launch/femto.launch.py | 1 + orbbec_camera/launch/femto_bolt.launch.py | 1 + orbbec_camera/launch/femto_mega.launch.py | 1 + orbbec_camera/launch/gemini2.launch.py | 1 + orbbec_camera/launch/gemini210.launch.py | 1 + orbbec_camera/launch/gemini2L.launch.py | 1 + orbbec_camera/launch/gemini345.launch.py | 1 + orbbec_camera/launch/gemini345_lg.launch.py | 1 + orbbec_camera/launch/gemini435_le.launch.py | 1 + .../launch/gemini_301_series.launch.py | 1 + .../launch/gemini_330_series.launch.py | 1 + .../gemini_330_series_low_cpu.launch.py | 1 + .../gemini_330_series_sdk_json.launch.py | 1 + .../gemini_intra_process_demo_launch.py | 1 + orbbec_camera/src/ob_camera_node.cpp | 57 +++++++++++++++++-- 26 files changed, 88 insertions(+), 9 deletions(-) diff --git a/README.MD b/README.MD index 0eef390a..9015817c 100644 --- a/README.MD +++ b/README.MD @@ -334,6 +334,8 @@ Launch camera node source ~/ros2_ws/install/setup.bash ros2 run orbbec_camera list_devices_node # Check if the camera is connected ros2 launch orbbec_camera gemini_330_series.launch.py # Or other launch file, see below table +# Optional: enable Jet colorized depth on /camera/depth/image_raw +ros2 launch orbbec_camera gemini_330_series.launch.py enable_depth_colorizer:=true ``` - On terminal 2 @@ -367,6 +369,10 @@ ros2 service call /camera/get_sdk_version orbbec_camera_msgs/srv/GetString '{}' For more usage details, please refer to the official [OrbbecSDK ROS2 documentation](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/4_application_guide/application_guide.html) +When `enable_depth_colorizer` is enabled, `depth/image_raw` directly publishes an `rgb8` image +(OpenCV Jet). When disabled, the topic continues to publish the raw `16UC1` depth image; the +colorized image uses a 0--10 m depth range for mapping. + ## Supported Devices Currently, the following devices are supported by the OrbbecSDK ROS2 Wrapper v2-main branch. More devices support will be added in the near future. If you can not find your device in the table below, try the [main](https://github.com/orbbec/OrbbecSDK_ROS2/tree/main) branch. diff --git a/README_CN.MD b/README_CN.MD index 0ae10dea..3ace3e42 100644 --- a/README_CN.MD +++ b/README_CN.MD @@ -333,6 +333,8 @@ sudo bash install_udev_rules.sh source ~/ros2_ws/install/setup.bash ros2 run orbbec_camera list_devices_node #检查相机是否已连接 ros2 launch orbbec_camera gemini_330_series.launch.py # 或其他启动文件,见下表 +# 可选:开启 Jet 伪彩色深度图,直接发布到 /camera/depth/image_raw +ros2 launch orbbec_camera gemini_330_series.launch.py enable_depth_colorizer:=true ``` - 终端 2 @@ -366,6 +368,9 @@ ros2 service call /camera/get_sdk_version orbbec_camera_msgs/srv/GetString '{}' 更多使用详情,请参考官方 [OrbbecSDK ROS2 文档](https://orbbec.github.io/OrbbecSDK_ROS2/zh/source/camera_devices/4_application_guide/application_guide.html) +开启 `enable_depth_colorizer` 后,`depth/image_raw` 直接发布 `rgb8` 彩色图(OpenCV Jet)。 +关闭时该话题仍发布原始 `16UC1` 深度图,彩色图使用 0--10 m 深度范围进行映射。 + ## 支持的设备 目前 v2-main 分支支持以下设备。更多设备支持将陆续增加。如果没有找到您的设备,请尝试 [main](https://github.com/orbbec/OrbbecSDK_ROS2/tree/main) 分支。 diff --git a/orbbec_camera/config/camera_params.yaml b/orbbec_camera/config/camera_params.yaml index 73587fce..6733d17c 100644 --- a/orbbec_camera/config/camera_params.yaml +++ b/orbbec_camera/config/camera_params.yaml @@ -1,6 +1,7 @@ # common params depth_registration: false enable_d2c_viewer: false +enable_depth_colorizer: false enable_point_cloud: false enable_colored_point_cloud: false enable_ldp: false @@ -61,5 +62,3 @@ right_ir_format: "ANY" # ir_height: 0 # ir_fps: 0 # ir_format: "ANY" - - diff --git a/orbbec_camera/config/camera_secondary_params.yaml b/orbbec_camera/config/camera_secondary_params.yaml index cf60bae9..eb23535e 100644 --- a/orbbec_camera/config/camera_secondary_params.yaml +++ b/orbbec_camera/config/camera_secondary_params.yaml @@ -1,6 +1,7 @@ # common params depth_registration: false enable_d2c_viewer: false +enable_depth_colorizer: false enable_point_cloud: false enable_colored_point_cloud: false enable_ldp: false @@ -61,5 +62,3 @@ right_ir_format: "ANY" # ir_height: 0 # ir_fps: 0 # ir_format: "ANY" - - diff --git a/orbbec_camera/include/orbbec_camera/ob_camera_node.h b/orbbec_camera/include/orbbec_camera/ob_camera_node.h index f21ad31c..f40cd81f 100644 --- a/orbbec_camera/include/orbbec_camera/ob_camera_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_camera_node.h @@ -558,6 +558,8 @@ class OBCameraNode { void publishRawDepthImage(const std::shared_ptr& depth_frame); + cv::Mat colorizeDepthImage(const cv::Mat& depth_image); + std::shared_ptr processDepthFrameFilter(std::shared_ptr& frame); std::shared_ptr processColorFrameFilter(std::shared_ptr& frame); @@ -799,6 +801,7 @@ class OBCameraNode { std::string color_info_url_; std::string ir_info_url_; std::optional camera_param_; + bool colorizer_enabled_ = false; bool enable_d2c_viewer_ = false; std::unique_ptr d2c_viewer_ = nullptr; std::map save_images_; diff --git a/orbbec_camera/launch/astra.launch.py b/orbbec_camera/launch/astra.launch.py index 0a498db9..ba4217b6 100644 --- a/orbbec_camera/launch/astra.launch.py +++ b/orbbec_camera/launch/astra.launch.py @@ -68,6 +68,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), + DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), DeclareLaunchArgument('enable_ldp', default_value='true'), DeclareLaunchArgument('ordered_pc', default_value='false'), DeclareLaunchArgument('use_hardware_time', default_value='false'), diff --git a/orbbec_camera/launch/astra2.launch.py b/orbbec_camera/launch/astra2.launch.py index d17f738d..f8d55d97 100644 --- a/orbbec_camera/launch/astra2.launch.py +++ b/orbbec_camera/launch/astra2.launch.py @@ -100,6 +100,7 @@ def generate_launch_description(): DeclareLaunchArgument('temporal_filter_weight', default_value='-1.0'), DeclareLaunchArgument('hole_filling_filter_mode', default_value=''), DeclareLaunchArgument("enable_d2c_viewer", default_value="false"), + DeclareLaunchArgument("enable_depth_colorizer", default_value="false"), DeclareLaunchArgument("enable_ldp", default_value="true"), DeclareLaunchArgument("ordered_pc", default_value="false"), DeclareLaunchArgument("enable_depth_scale", default_value="true"), diff --git a/orbbec_camera/launch/dabai_a.launch.py b/orbbec_camera/launch/dabai_a.launch.py index 33f2a11c..f7459b5c 100644 --- a/orbbec_camera/launch/dabai_a.launch.py +++ b/orbbec_camera/launch/dabai_a.launch.py @@ -158,6 +158,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), + DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('enable_ldp', default_value='true'), DeclareLaunchArgument('ldp_power_level', default_value='-1'), diff --git a/orbbec_camera/launch/dabai_al.launch.py b/orbbec_camera/launch/dabai_al.launch.py index 1773024c..d37939f4 100644 --- a/orbbec_camera/launch/dabai_al.launch.py +++ b/orbbec_camera/launch/dabai_al.launch.py @@ -158,6 +158,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), + DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('enable_ldp', default_value='true'), DeclareLaunchArgument('ldp_power_level', default_value='-1'), diff --git a/orbbec_camera/launch/dabai_dcw2.launch.py b/orbbec_camera/launch/dabai_dcw2.launch.py index 95a1eec0..6110f973 100644 --- a/orbbec_camera/launch/dabai_dcw2.launch.py +++ b/orbbec_camera/launch/dabai_dcw2.launch.py @@ -77,6 +77,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_level', default_value='info'), DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), + DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), DeclareLaunchArgument('enable_soft_filter', default_value='true'), DeclareLaunchArgument('enable_ldp', default_value='true'), DeclareLaunchArgument('soft_filter_max_diff', default_value='-1'), diff --git a/orbbec_camera/launch/dabai_max_pro.launch.py b/orbbec_camera/launch/dabai_max_pro.launch.py index 02757996..16b84b45 100644 --- a/orbbec_camera/launch/dabai_max_pro.launch.py +++ b/orbbec_camera/launch/dabai_max_pro.launch.py @@ -86,6 +86,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), + DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), DeclareLaunchArgument('enable_noise_removal_filter', default_value='true'), DeclareLaunchArgument('noise_removal_filter_min_diff', default_value='256'), DeclareLaunchArgument('noise_removal_filter_max_size', default_value='80'), diff --git a/orbbec_camera/launch/femto.launch.py b/orbbec_camera/launch/femto.launch.py index 6ea3f7aa..2d4253d1 100644 --- a/orbbec_camera/launch/femto.launch.py +++ b/orbbec_camera/launch/femto.launch.py @@ -77,6 +77,7 @@ def generate_launch_description(): DeclareLaunchArgument("log_file_name", default_value=""), DeclareLaunchArgument("enable_publish_extrinsic", default_value="false"), DeclareLaunchArgument("enable_d2c_viewer", default_value="false"), + DeclareLaunchArgument("enable_depth_colorizer", default_value="false"), DeclareLaunchArgument("enable_ldp", default_value="true"), DeclareLaunchArgument("enable_frame_sync", default_value="false"), DeclareLaunchArgument("ordered_pc", default_value="false"), diff --git a/orbbec_camera/launch/femto_bolt.launch.py b/orbbec_camera/launch/femto_bolt.launch.py index 7283f469..6ac85e79 100644 --- a/orbbec_camera/launch/femto_bolt.launch.py +++ b/orbbec_camera/launch/femto_bolt.launch.py @@ -80,6 +80,7 @@ def generate_launch_description(): DeclareLaunchArgument("log_file_name", default_value=""), DeclareLaunchArgument("enable_publish_extrinsic", default_value="false"), DeclareLaunchArgument("enable_d2c_viewer", default_value="false"), + DeclareLaunchArgument("enable_depth_colorizer", default_value="false"), DeclareLaunchArgument("enable_ldp", default_value="true"), DeclareLaunchArgument('enable_noise_removal_filter', default_value='false'), DeclareLaunchArgument('enable_decimation_filter', default_value='false'), diff --git a/orbbec_camera/launch/femto_mega.launch.py b/orbbec_camera/launch/femto_mega.launch.py index 040e0696..8b89b86d 100644 --- a/orbbec_camera/launch/femto_mega.launch.py +++ b/orbbec_camera/launch/femto_mega.launch.py @@ -86,6 +86,7 @@ def generate_launch_description(): DeclareLaunchArgument("log_file_name", default_value=""), DeclareLaunchArgument("enable_publish_extrinsic", default_value="false"), DeclareLaunchArgument("enable_d2c_viewer", default_value="false"), + DeclareLaunchArgument("enable_depth_colorizer", default_value="false"), DeclareLaunchArgument("enable_ldp", default_value="true"), DeclareLaunchArgument('enable_noise_removal_filter', default_value='false'), DeclareLaunchArgument('enable_decimation_filter', default_value='false'), diff --git a/orbbec_camera/launch/gemini2.launch.py b/orbbec_camera/launch/gemini2.launch.py index d0beb879..7b3bd1bc 100644 --- a/orbbec_camera/launch/gemini2.launch.py +++ b/orbbec_camera/launch/gemini2.launch.py @@ -92,6 +92,7 @@ def generate_launch_description(): DeclareLaunchArgument("log_file_name", default_value=""), DeclareLaunchArgument("enable_publish_extrinsic", default_value="false"), DeclareLaunchArgument("enable_d2c_viewer", default_value="false"), + DeclareLaunchArgument("enable_depth_colorizer", default_value="false"), DeclareLaunchArgument('disparity_to_depth_mode', default_value='SW'), DeclareLaunchArgument("enable_ldp", default_value="true"), DeclareLaunchArgument('enable_decimation_filter', default_value='false'), diff --git a/orbbec_camera/launch/gemini210.launch.py b/orbbec_camera/launch/gemini210.launch.py index e5da7d5f..10219f69 100644 --- a/orbbec_camera/launch/gemini210.launch.py +++ b/orbbec_camera/launch/gemini210.launch.py @@ -90,6 +90,7 @@ def generate_launch_description(): DeclareLaunchArgument("log_file_name", default_value=""), DeclareLaunchArgument("enable_publish_extrinsic", default_value="false"), DeclareLaunchArgument("enable_d2c_viewer", default_value="false"), + DeclareLaunchArgument("enable_depth_colorizer", default_value="false"), DeclareLaunchArgument('disparity_to_depth_mode', default_value='SW'), DeclareLaunchArgument("enable_ldp", default_value="true"), DeclareLaunchArgument('enable_decimation_filter', default_value='false'), diff --git a/orbbec_camera/launch/gemini2L.launch.py b/orbbec_camera/launch/gemini2L.launch.py index 81405065..64d27153 100644 --- a/orbbec_camera/launch/gemini2L.launch.py +++ b/orbbec_camera/launch/gemini2L.launch.py @@ -146,6 +146,7 @@ def generate_launch_description(): DeclareLaunchArgument("log_file_name", default_value=""), DeclareLaunchArgument("enable_publish_extrinsic", default_value="false"), DeclareLaunchArgument("enable_d2c_viewer", default_value="false"), + DeclareLaunchArgument("enable_depth_colorizer", default_value="false"), DeclareLaunchArgument("disparity_to_depth_mode", default_value="SW"), DeclareLaunchArgument("enable_ldp", default_value="true"), DeclareLaunchArgument("enable_decimation_filter", default_value="false"), diff --git a/orbbec_camera/launch/gemini345.launch.py b/orbbec_camera/launch/gemini345.launch.py index fd1e3167..fac15ca8 100644 --- a/orbbec_camera/launch/gemini345.launch.py +++ b/orbbec_camera/launch/gemini345.launch.py @@ -157,6 +157,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), + DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('enable_ldp', default_value='true'), DeclareLaunchArgument('ldp_power_level', default_value='-1'), diff --git a/orbbec_camera/launch/gemini345_lg.launch.py b/orbbec_camera/launch/gemini345_lg.launch.py index 87e46fdd..75159fc3 100644 --- a/orbbec_camera/launch/gemini345_lg.launch.py +++ b/orbbec_camera/launch/gemini345_lg.launch.py @@ -158,6 +158,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), + DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('enable_ldp', default_value='true'), DeclareLaunchArgument('ldp_power_level', default_value='-1'), diff --git a/orbbec_camera/launch/gemini435_le.launch.py b/orbbec_camera/launch/gemini435_le.launch.py index 726472be..fac6695b 100644 --- a/orbbec_camera/launch/gemini435_le.launch.py +++ b/orbbec_camera/launch/gemini435_le.launch.py @@ -188,6 +188,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), + DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('enable_ldp', default_value='true'), DeclareLaunchArgument('ldp_power_level', default_value='-1'), diff --git a/orbbec_camera/launch/gemini_301_series.launch.py b/orbbec_camera/launch/gemini_301_series.launch.py index 4339900b..88c5ed7a 100644 --- a/orbbec_camera/launch/gemini_301_series.launch.py +++ b/orbbec_camera/launch/gemini_301_series.launch.py @@ -206,6 +206,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), + DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('sync_mode', default_value='standalone'), DeclareLaunchArgument('depth_delay_us', default_value='0'), diff --git a/orbbec_camera/launch/gemini_330_series.launch.py b/orbbec_camera/launch/gemini_330_series.launch.py index a8860183..2b61316f 100644 --- a/orbbec_camera/launch/gemini_330_series.launch.py +++ b/orbbec_camera/launch/gemini_330_series.launch.py @@ -212,6 +212,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), + DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('enable_ldp', default_value='false'), DeclareLaunchArgument('ldp_power_level', default_value='-1'), diff --git a/orbbec_camera/launch/gemini_330_series_low_cpu.launch.py b/orbbec_camera/launch/gemini_330_series_low_cpu.launch.py index 36be361e..14364ec0 100644 --- a/orbbec_camera/launch/gemini_330_series_low_cpu.launch.py +++ b/orbbec_camera/launch/gemini_330_series_low_cpu.launch.py @@ -199,6 +199,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), + DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('enable_ldp', default_value='false'), DeclareLaunchArgument('ldp_power_level', default_value='-1'), diff --git a/orbbec_camera/launch/gemini_330_series_sdk_json.launch.py b/orbbec_camera/launch/gemini_330_series_sdk_json.launch.py index a41be6b1..e5d04a92 100644 --- a/orbbec_camera/launch/gemini_330_series_sdk_json.launch.py +++ b/orbbec_camera/launch/gemini_330_series_sdk_json.launch.py @@ -113,6 +113,7 @@ def generate_launch_description(): DeclareLaunchArgument('enable_frame_drop_log', default_value='false'), DeclareLaunchArgument('frame_timestamp_csv_file', default_value=''), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), + DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), DeclareLaunchArgument('show_fps_enable', default_value='false'), DeclareLaunchArgument('enumerate_net_device', default_value='true'), diff --git a/orbbec_camera/launch/gemini_intra_process_demo_launch.py b/orbbec_camera/launch/gemini_intra_process_demo_launch.py index 21cc4ae2..1149f3b2 100644 --- a/orbbec_camera/launch/gemini_intra_process_demo_launch.py +++ b/orbbec_camera/launch/gemini_intra_process_demo_launch.py @@ -117,6 +117,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), + DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('enable_ldp', default_value='true'), DeclareLaunchArgument('sync_mode', default_value='standalone'), diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index b4874abe..94fcd0f7 100755 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -66,6 +66,7 @@ namespace { constexpr char kEnhancedDepthSupportedTargetResolutions[] = "640x480/1280x720/1280x800"; constexpr char kEnhancedDepthSupportedDepthFormats[] = "Y10/Y11/Y12/Y14/Y16/Z16"; +constexpr double kColorizerMaxDistanceMm = 10000.0; std::string getDepthFilterStatusName(const std::string &filter_name) { if (filter_name == "SpatialAdvancedFilter") { @@ -4466,6 +4467,7 @@ void OBCameraNode::getParameters() { setAndGetNodeParameter(point_cloud_decimation_filter_factor_, "point_cloud_decimation_filter_factor", 1); setAndGetNodeParameter(point_cloud_qos_, "point_cloud_qos", "default"); + setAndGetNodeParameter(colorizer_enabled_, "enable_depth_colorizer", false); setAndGetNodeParameter(enable_d2c_viewer_, "enable_d2c_viewer", false); setAndGetNodeParameter(disparity_to_depth_mode_, "disparity_to_depth_mode", ""); disparity_to_depth_mode_ = @@ -5428,6 +5430,11 @@ void OBCameraNode::setupPublishers() { } } + if (colorizer_enabled_ && enable_stream_[DEPTH]) { + RCLCPP_INFO(logger_, + "Depth colorizer enabled, publishing Jet RGB images on depth/image_raw (0-10 m)"); + } + syncSoftwareAlignment(); if (enable_sync_output_accel_gyro_) { @@ -5601,6 +5608,34 @@ void OBCameraNode::publishRawDepthImage(const std::shared_ptr &depth_ depth_unaligned_publisher_->publish(std::move(image_msg)); } +cv::Mat OBCameraNode::colorizeDepthImage(const cv::Mat &depth_image) { + if (depth_image.empty() || depth_image.channels() != 1) { + return {}; + } + + cv::Mat depth_8u; + if (depth_image.type() == CV_16UC1 || depth_image.type() == CV_32FC1) { + depth_image.convertTo(depth_8u, CV_8UC1, 255.0 / kColorizerMaxDistanceMm); + } else if (depth_image.type() == CV_8UC1) { + depth_image.convertTo(depth_8u, CV_8UC1); + } else { + RCLCPP_WARN_THROTTLE(logger_, *node_->get_clock(), 5000, + "Unsupported depth image type for colorizer: %d", depth_image.type()); + return {}; + } + + cv::Mat colorized_bgr; + cv::applyColorMap(depth_8u, colorized_bgr, cv::COLORMAP_JET); + + cv::Mat invalid_depth_mask; + cv::compare(depth_image, cv::Scalar(0), invalid_depth_mask, cv::CMP_EQ); + colorized_bgr.setTo(cv::Scalar::all(0), invalid_depth_mask); + + cv::Mat colorized_rgb; + cv::cvtColor(colorized_bgr, colorized_rgb, cv::COLOR_BGR2RGB); + return colorized_rgb; +} + void OBCameraNode::publishDepthPointCloud(const std::shared_ptr &frame_set) { if (!depth_cloud_pub_ || depth_cloud_pub_->get_subscription_count() == 0 || !enable_point_cloud_) { @@ -6785,22 +6820,34 @@ void OBCameraNode::onNewFrameCallback(const std::shared_ptr &frame, camera_info_publishers_[stream_index]->publish(camera_info); publishMetadata(frame, stream_index, camera_info.header); - if (!has_raw_image_subscriber && !save_images_[stream_index]) { - return; - } + cv::Mat image_to_publish = image; + std::string image_encoding = encoding_[stream_index]; + uint32_t image_step = width * unit_step_size_[stream_index]; if (stream_index == DEPTH) { auto depth_scale = video_frame->as()->getValueScale(); image = image * depth_scale; + image_to_publish = image; + if (colorizer_enabled_ && has_raw_image_subscriber) { + auto colorized_image = colorizeDepthImage(image); + if (!colorized_image.empty()) { + image_to_publish = std::move(colorized_image); + image_encoding = sensor_msgs::image_encodings::RGB8; + image_step = static_cast(image_to_publish.cols * 3 * sizeof(uint8_t)); + } + } + } + if (!has_raw_image_subscriber && !save_images_[stream_index]) { + return; } CHECK(image_publishers_.count(stream_index) > 0); if (has_raw_image_subscriber || save_images_[stream_index]) { sensor_msgs::msg::Image::UniquePtr image_msg(new sensor_msgs::msg::Image()); - cv_bridge::CvImage(std_msgs::msg::Header(), encoding_[stream_index], image) + cv_bridge::CvImage(std_msgs::msg::Header(), image_encoding, image_to_publish) .toImageMsg(*image_msg); CHECK_NOTNULL(image_msg.get()); image_msg->header.stamp = timestamp; image_msg->is_bigendian = false; - image_msg->step = width * unit_step_size_[stream_index]; + image_msg->step = image_step; image_msg->header.frame_id = frame_id; saveImageToFile(stream_index, image, *image_msg); if (!has_raw_image_subscriber) { From 282ab4b022198276aa94dc5e23f720684166a88a Mon Sep 17 00:00:00 2001 From: slz Date: Tue, 18 Aug 2026 15:13:52 +0800 Subject: [PATCH 35/48] fix: update color image layout on profile switch --- orbbec_camera/src/ob_camera_node.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index 3663e70a..1aa56019 100755 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -3933,6 +3933,12 @@ void OBCameraNode::updateImageConfig(const stream_index_pair &stream_index) { encoding_[stream_index] = is_depth_stream ? sensor_msgs::image_encodings::TYPE_16UC1 : sensor_msgs::image_encodings::MONO16; unit_step_size_[stream_index] = sizeof(uint16_t); + } else if (is_color_stream && + (format == OB_FORMAT_YUYV || format == OB_FORMAT_UYVY || format == OB_FORMAT_I420 || + format == OB_FORMAT_NV12 || format == OB_FORMAT_NV21)) { + image_format_[stream_index] = CV_8UC3; + encoding_[stream_index] = sensor_msgs::image_encodings::RGB8; + unit_step_size_[stream_index] = 3 * sizeof(uint8_t); } else if (format == OB_FORMAT_MJPG || format == OB_FORMAT_MJPEG) { if (is_ir_stream) { image_format_[stream_index] = CV_8UC1; From afc64cbc7093400e5c6407f61dcf91c9533f12ca Mon Sep 17 00:00:00 2001 From: ob-yalian Date: Tue, 18 Aug 2026 17:36:51 +0800 Subject: [PATCH 36/48] feat: update depth colorizer implementation and configuration options --- README.MD | 15 ++- README_CN.MD | 14 ++- orbbec_camera/config/camera_params.yaml | 2 +- .../config/camera_secondary_params.yaml | 2 +- .../include/orbbec_camera/ob_camera_node.h | 2 +- orbbec_camera/launch/astra.launch.py | 2 +- orbbec_camera/launch/astra2.launch.py | 2 +- orbbec_camera/launch/dabai_a.launch.py | 5 +- orbbec_camera/launch/dabai_al.launch.py | 5 +- orbbec_camera/launch/dabai_dcw2.launch.py | 2 +- orbbec_camera/launch/dabai_max_pro.launch.py | 2 +- orbbec_camera/launch/femto.launch.py | 2 +- orbbec_camera/launch/femto_bolt.launch.py | 2 +- orbbec_camera/launch/femto_mega.launch.py | 2 +- orbbec_camera/launch/gemini2.launch.py | 2 +- orbbec_camera/launch/gemini210.launch.py | 2 +- orbbec_camera/launch/gemini2L.launch.py | 5 +- orbbec_camera/launch/gemini345.launch.py | 5 +- orbbec_camera/launch/gemini345_lg.launch.py | 5 +- orbbec_camera/launch/gemini435_le.launch.py | 5 +- .../launch/gemini_301_series.launch.py | 5 +- .../launch/gemini_330_series.launch.py | 4 +- .../gemini_330_series_low_cpu.launch.py | 4 +- .../gemini_330_series_sdk_json.launch.py | 5 +- .../gemini_intra_process_demo_launch.py | 5 +- orbbec_camera/src/ob_camera_node.cpp | 97 ++++++++++++++++--- 26 files changed, 144 insertions(+), 59 deletions(-) diff --git a/README.MD b/README.MD index 9015817c..73afb4ab 100644 --- a/README.MD +++ b/README.MD @@ -334,8 +334,8 @@ Launch camera node source ~/ros2_ws/install/setup.bash ros2 run orbbec_camera list_devices_node # Check if the camera is connected ros2 launch orbbec_camera gemini_330_series.launch.py # Or other launch file, see below table -# Optional: enable Jet colorized depth on /camera/depth/image_raw -ros2 launch orbbec_camera gemini_330_series.launch.py enable_depth_colorizer:=true +# Optional: publish OrbbecViewer-style colorized depth on /camera/depth/image_raw +ros2 launch orbbec_camera gemini_330_series.launch.py depth_colorizer_mode:=jet ``` - On terminal 2 @@ -369,9 +369,14 @@ ros2 service call /camera/get_sdk_version orbbec_camera_msgs/srv/GetString '{}' For more usage details, please refer to the official [OrbbecSDK ROS2 documentation](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/4_application_guide/application_guide.html) -When `enable_depth_colorizer` is enabled, `depth/image_raw` directly publishes an `rgb8` image -(OpenCV Jet). When disabled, the topic continues to publish the raw `16UC1` depth image; the -colorized image uses a 0--10 m depth range for mapping. +`depth_colorizer_mode` is a string render mode: + +- `none`: disable colorization and publish the raw `16UC1` depth image; +- `jet`: use the OrbbecViewer-style dynamic histogram, gamma, and Jet mapping; +- `jet_inv`: use the OrbbecViewer-style inverse Jet mapping; +- `gray`: use the OrbbecViewer-style grayscale mapping; + +The `jet` and `jet_inv` modes publish `rgb8`; `gray` publishes `mono8` on `depth/image_raw`. ## Supported Devices diff --git a/README_CN.MD b/README_CN.MD index 3ace3e42..962be62f 100644 --- a/README_CN.MD +++ b/README_CN.MD @@ -333,8 +333,8 @@ sudo bash install_udev_rules.sh source ~/ros2_ws/install/setup.bash ros2 run orbbec_camera list_devices_node #检查相机是否已连接 ros2 launch orbbec_camera gemini_330_series.launch.py # 或其他启动文件,见下表 -# 可选:开启 Jet 伪彩色深度图,直接发布到 /camera/depth/image_raw -ros2 launch orbbec_camera gemini_330_series.launch.py enable_depth_colorizer:=true +# 可选:使用 OrbbecViewer 风格发布伪彩色深度图到 /camera/depth/image_raw +ros2 launch orbbec_camera gemini_330_series.launch.py depth_colorizer_mode:=jet ``` - 终端 2 @@ -368,8 +368,14 @@ ros2 service call /camera/get_sdk_version orbbec_camera_msgs/srv/GetString '{}' 更多使用详情,请参考官方 [OrbbecSDK ROS2 文档](https://orbbec.github.io/OrbbecSDK_ROS2/zh/source/camera_devices/4_application_guide/application_guide.html) -开启 `enable_depth_colorizer` 后,`depth/image_raw` 直接发布 `rgb8` 彩色图(OpenCV Jet)。 -关闭时该话题仍发布原始 `16UC1` 深度图,彩色图使用 0--10 m 深度范围进行映射。 +`depth_colorizer_mode` 是字符串渲染模式: + +- `none`:关闭彩色化,`depth/image_raw` 发布原始 `16UC1` 深度图; +- `jet`:使用 OrbbecViewer 的动态直方图、伽马和 Jet 映射; +- `jet_inv`:使用 OrbbecViewer 风格的反向 Jet 映射; +- `gray`:使用 OrbbecViewer 风格的灰度映射; + +`jet` 和 `jet_inv` 模式发布 `rgb8`,`gray` 模式发布 `mono8` 到 `depth/image_raw`。 ## 支持的设备 diff --git a/orbbec_camera/config/camera_params.yaml b/orbbec_camera/config/camera_params.yaml index 6733d17c..d2cedfa3 100644 --- a/orbbec_camera/config/camera_params.yaml +++ b/orbbec_camera/config/camera_params.yaml @@ -1,7 +1,7 @@ # common params depth_registration: false enable_d2c_viewer: false -enable_depth_colorizer: false +depth_colorizer_mode: "none" enable_point_cloud: false enable_colored_point_cloud: false enable_ldp: false diff --git a/orbbec_camera/config/camera_secondary_params.yaml b/orbbec_camera/config/camera_secondary_params.yaml index eb23535e..2e865f80 100644 --- a/orbbec_camera/config/camera_secondary_params.yaml +++ b/orbbec_camera/config/camera_secondary_params.yaml @@ -1,7 +1,7 @@ # common params depth_registration: false enable_d2c_viewer: false -enable_depth_colorizer: false +depth_colorizer_mode: "none" enable_point_cloud: false enable_colored_point_cloud: false enable_ldp: false diff --git a/orbbec_camera/include/orbbec_camera/ob_camera_node.h b/orbbec_camera/include/orbbec_camera/ob_camera_node.h index f40cd81f..ba0bccf2 100644 --- a/orbbec_camera/include/orbbec_camera/ob_camera_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_camera_node.h @@ -801,7 +801,7 @@ class OBCameraNode { std::string color_info_url_; std::string ir_info_url_; std::optional camera_param_; - bool colorizer_enabled_ = false; + std::string colorizer_mode_ = "none"; bool enable_d2c_viewer_ = false; std::unique_ptr d2c_viewer_ = nullptr; std::map save_images_; diff --git a/orbbec_camera/launch/astra.launch.py b/orbbec_camera/launch/astra.launch.py index ba4217b6..72bcf7a7 100644 --- a/orbbec_camera/launch/astra.launch.py +++ b/orbbec_camera/launch/astra.launch.py @@ -68,7 +68,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), - DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), + DeclareLaunchArgument('depth_colorizer_mode', default_value='none'), DeclareLaunchArgument('enable_ldp', default_value='true'), DeclareLaunchArgument('ordered_pc', default_value='false'), DeclareLaunchArgument('use_hardware_time', default_value='false'), diff --git a/orbbec_camera/launch/astra2.launch.py b/orbbec_camera/launch/astra2.launch.py index f8d55d97..266848cf 100644 --- a/orbbec_camera/launch/astra2.launch.py +++ b/orbbec_camera/launch/astra2.launch.py @@ -100,7 +100,7 @@ def generate_launch_description(): DeclareLaunchArgument('temporal_filter_weight', default_value='-1.0'), DeclareLaunchArgument('hole_filling_filter_mode', default_value=''), DeclareLaunchArgument("enable_d2c_viewer", default_value="false"), - DeclareLaunchArgument("enable_depth_colorizer", default_value="false"), + DeclareLaunchArgument("depth_colorizer_mode", default_value="none"), DeclareLaunchArgument("enable_ldp", default_value="true"), DeclareLaunchArgument("ordered_pc", default_value="false"), DeclareLaunchArgument("enable_depth_scale", default_value="true"), diff --git a/orbbec_camera/launch/dabai_a.launch.py b/orbbec_camera/launch/dabai_a.launch.py index f7459b5c..111b14db 100644 --- a/orbbec_camera/launch/dabai_a.launch.py +++ b/orbbec_camera/launch/dabai_a.launch.py @@ -42,7 +42,8 @@ def load_parameters(context, args): if config_file_path: yaml_params = load_yaml(config_file_path) default_params = merge_params(default_params, yaml_params) - skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename'} + skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename', + 'depth_colorizer_mode'} result = {} for key, value in default_params.items(): @@ -158,7 +159,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), - DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), + DeclareLaunchArgument('depth_colorizer_mode', default_value='none'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('enable_ldp', default_value='true'), DeclareLaunchArgument('ldp_power_level', default_value='-1'), diff --git a/orbbec_camera/launch/dabai_al.launch.py b/orbbec_camera/launch/dabai_al.launch.py index d37939f4..54284e0d 100644 --- a/orbbec_camera/launch/dabai_al.launch.py +++ b/orbbec_camera/launch/dabai_al.launch.py @@ -42,7 +42,8 @@ def load_parameters(context, args): if config_file_path: yaml_params = load_yaml(config_file_path) default_params = merge_params(default_params, yaml_params) - skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename'} + skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename', + 'depth_colorizer_mode'} result = {} for key, value in default_params.items(): @@ -158,7 +159,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), - DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), + DeclareLaunchArgument('depth_colorizer_mode', default_value='none'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('enable_ldp', default_value='true'), DeclareLaunchArgument('ldp_power_level', default_value='-1'), diff --git a/orbbec_camera/launch/dabai_dcw2.launch.py b/orbbec_camera/launch/dabai_dcw2.launch.py index 6110f973..356109d4 100644 --- a/orbbec_camera/launch/dabai_dcw2.launch.py +++ b/orbbec_camera/launch/dabai_dcw2.launch.py @@ -77,7 +77,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_level', default_value='info'), DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), - DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), + DeclareLaunchArgument('depth_colorizer_mode', default_value='none'), DeclareLaunchArgument('enable_soft_filter', default_value='true'), DeclareLaunchArgument('enable_ldp', default_value='true'), DeclareLaunchArgument('soft_filter_max_diff', default_value='-1'), diff --git a/orbbec_camera/launch/dabai_max_pro.launch.py b/orbbec_camera/launch/dabai_max_pro.launch.py index 16b84b45..4e3af7a2 100644 --- a/orbbec_camera/launch/dabai_max_pro.launch.py +++ b/orbbec_camera/launch/dabai_max_pro.launch.py @@ -86,7 +86,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), - DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), + DeclareLaunchArgument('depth_colorizer_mode', default_value='none'), DeclareLaunchArgument('enable_noise_removal_filter', default_value='true'), DeclareLaunchArgument('noise_removal_filter_min_diff', default_value='256'), DeclareLaunchArgument('noise_removal_filter_max_size', default_value='80'), diff --git a/orbbec_camera/launch/femto.launch.py b/orbbec_camera/launch/femto.launch.py index 2d4253d1..2d34a233 100644 --- a/orbbec_camera/launch/femto.launch.py +++ b/orbbec_camera/launch/femto.launch.py @@ -77,7 +77,7 @@ def generate_launch_description(): DeclareLaunchArgument("log_file_name", default_value=""), DeclareLaunchArgument("enable_publish_extrinsic", default_value="false"), DeclareLaunchArgument("enable_d2c_viewer", default_value="false"), - DeclareLaunchArgument("enable_depth_colorizer", default_value="false"), + DeclareLaunchArgument("depth_colorizer_mode", default_value="none"), DeclareLaunchArgument("enable_ldp", default_value="true"), DeclareLaunchArgument("enable_frame_sync", default_value="false"), DeclareLaunchArgument("ordered_pc", default_value="false"), diff --git a/orbbec_camera/launch/femto_bolt.launch.py b/orbbec_camera/launch/femto_bolt.launch.py index 6ac85e79..68d9cb5f 100644 --- a/orbbec_camera/launch/femto_bolt.launch.py +++ b/orbbec_camera/launch/femto_bolt.launch.py @@ -80,7 +80,7 @@ def generate_launch_description(): DeclareLaunchArgument("log_file_name", default_value=""), DeclareLaunchArgument("enable_publish_extrinsic", default_value="false"), DeclareLaunchArgument("enable_d2c_viewer", default_value="false"), - DeclareLaunchArgument("enable_depth_colorizer", default_value="false"), + DeclareLaunchArgument("depth_colorizer_mode", default_value="none"), DeclareLaunchArgument("enable_ldp", default_value="true"), DeclareLaunchArgument('enable_noise_removal_filter', default_value='false'), DeclareLaunchArgument('enable_decimation_filter', default_value='false'), diff --git a/orbbec_camera/launch/femto_mega.launch.py b/orbbec_camera/launch/femto_mega.launch.py index 8b89b86d..6c98f871 100644 --- a/orbbec_camera/launch/femto_mega.launch.py +++ b/orbbec_camera/launch/femto_mega.launch.py @@ -86,7 +86,7 @@ def generate_launch_description(): DeclareLaunchArgument("log_file_name", default_value=""), DeclareLaunchArgument("enable_publish_extrinsic", default_value="false"), DeclareLaunchArgument("enable_d2c_viewer", default_value="false"), - DeclareLaunchArgument("enable_depth_colorizer", default_value="false"), + DeclareLaunchArgument("depth_colorizer_mode", default_value="none"), DeclareLaunchArgument("enable_ldp", default_value="true"), DeclareLaunchArgument('enable_noise_removal_filter', default_value='false'), DeclareLaunchArgument('enable_decimation_filter', default_value='false'), diff --git a/orbbec_camera/launch/gemini2.launch.py b/orbbec_camera/launch/gemini2.launch.py index 7b3bd1bc..6f26cb21 100644 --- a/orbbec_camera/launch/gemini2.launch.py +++ b/orbbec_camera/launch/gemini2.launch.py @@ -92,7 +92,7 @@ def generate_launch_description(): DeclareLaunchArgument("log_file_name", default_value=""), DeclareLaunchArgument("enable_publish_extrinsic", default_value="false"), DeclareLaunchArgument("enable_d2c_viewer", default_value="false"), - DeclareLaunchArgument("enable_depth_colorizer", default_value="false"), + DeclareLaunchArgument("depth_colorizer_mode", default_value="none"), DeclareLaunchArgument('disparity_to_depth_mode', default_value='SW'), DeclareLaunchArgument("enable_ldp", default_value="true"), DeclareLaunchArgument('enable_decimation_filter', default_value='false'), diff --git a/orbbec_camera/launch/gemini210.launch.py b/orbbec_camera/launch/gemini210.launch.py index 10219f69..e05413d6 100644 --- a/orbbec_camera/launch/gemini210.launch.py +++ b/orbbec_camera/launch/gemini210.launch.py @@ -90,7 +90,7 @@ def generate_launch_description(): DeclareLaunchArgument("log_file_name", default_value=""), DeclareLaunchArgument("enable_publish_extrinsic", default_value="false"), DeclareLaunchArgument("enable_d2c_viewer", default_value="false"), - DeclareLaunchArgument("enable_depth_colorizer", default_value="false"), + DeclareLaunchArgument("depth_colorizer_mode", default_value="none"), DeclareLaunchArgument('disparity_to_depth_mode', default_value='SW'), DeclareLaunchArgument("enable_ldp", default_value="true"), DeclareLaunchArgument('enable_decimation_filter', default_value='false'), diff --git a/orbbec_camera/launch/gemini2L.launch.py b/orbbec_camera/launch/gemini2L.launch.py index 64d27153..63668a47 100644 --- a/orbbec_camera/launch/gemini2L.launch.py +++ b/orbbec_camera/launch/gemini2L.launch.py @@ -64,7 +64,8 @@ def load_parameters(context, args): if config_file_path: yaml_params = load_yaml(config_file_path) default_params = merge_params(default_params, yaml_params) - skip_convert = {"config_file_path", "usb_port", "serial_number", 'bag_record_filename', 'bag_filename'} + skip_convert = {"config_file_path", "usb_port", "serial_number", 'bag_record_filename', 'bag_filename', + "depth_colorizer_mode"} return { key: (value if key in skip_convert else convert_value(value)) @@ -146,7 +147,7 @@ def generate_launch_description(): DeclareLaunchArgument("log_file_name", default_value=""), DeclareLaunchArgument("enable_publish_extrinsic", default_value="false"), DeclareLaunchArgument("enable_d2c_viewer", default_value="false"), - DeclareLaunchArgument("enable_depth_colorizer", default_value="false"), + DeclareLaunchArgument("depth_colorizer_mode", default_value="none"), DeclareLaunchArgument("disparity_to_depth_mode", default_value="SW"), DeclareLaunchArgument("enable_ldp", default_value="true"), DeclareLaunchArgument("enable_decimation_filter", default_value="false"), diff --git a/orbbec_camera/launch/gemini345.launch.py b/orbbec_camera/launch/gemini345.launch.py index fac15ca8..53c303a3 100644 --- a/orbbec_camera/launch/gemini345.launch.py +++ b/orbbec_camera/launch/gemini345.launch.py @@ -42,7 +42,8 @@ def load_parameters(context, args): if config_file_path: yaml_params = load_yaml(config_file_path) default_params = merge_params(default_params, yaml_params) - skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename'} + skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename', + 'depth_colorizer_mode'} result = {} for key, value in default_params.items(): @@ -157,7 +158,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), - DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), + DeclareLaunchArgument('depth_colorizer_mode', default_value='none'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('enable_ldp', default_value='true'), DeclareLaunchArgument('ldp_power_level', default_value='-1'), diff --git a/orbbec_camera/launch/gemini345_lg.launch.py b/orbbec_camera/launch/gemini345_lg.launch.py index 75159fc3..7419a3f3 100644 --- a/orbbec_camera/launch/gemini345_lg.launch.py +++ b/orbbec_camera/launch/gemini345_lg.launch.py @@ -42,7 +42,8 @@ def load_parameters(context, args): if config_file_path: yaml_params = load_yaml(config_file_path) default_params = merge_params(default_params, yaml_params) - skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename'} + skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename', + 'depth_colorizer_mode'} result = {} for key, value in default_params.items(): @@ -158,7 +159,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), - DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), + DeclareLaunchArgument('depth_colorizer_mode', default_value='none'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('enable_ldp', default_value='true'), DeclareLaunchArgument('ldp_power_level', default_value='-1'), diff --git a/orbbec_camera/launch/gemini435_le.launch.py b/orbbec_camera/launch/gemini435_le.launch.py index fac6695b..e0e26223 100644 --- a/orbbec_camera/launch/gemini435_le.launch.py +++ b/orbbec_camera/launch/gemini435_le.launch.py @@ -42,7 +42,8 @@ def load_parameters(context, args): if config_file_path: yaml_params = load_yaml(config_file_path) default_params = merge_params(default_params, yaml_params) - skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename'} + skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename', + 'depth_colorizer_mode'} result = {} for key, value in default_params.items(): @@ -188,7 +189,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), - DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), + DeclareLaunchArgument('depth_colorizer_mode', default_value='none'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('enable_ldp', default_value='true'), DeclareLaunchArgument('ldp_power_level', default_value='-1'), diff --git a/orbbec_camera/launch/gemini_301_series.launch.py b/orbbec_camera/launch/gemini_301_series.launch.py index 88c5ed7a..ffa977d7 100644 --- a/orbbec_camera/launch/gemini_301_series.launch.py +++ b/orbbec_camera/launch/gemini_301_series.launch.py @@ -64,7 +64,8 @@ def load_parameters(context, args): if config_file_path: yaml_params = load_yaml(config_file_path) default_params = merge_params(default_params, yaml_params) - skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename'} + skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename', + 'depth_colorizer_mode'} result = {} for key, value in default_params.items(): @@ -206,7 +207,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), - DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), + DeclareLaunchArgument('depth_colorizer_mode', default_value='none'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('sync_mode', default_value='standalone'), DeclareLaunchArgument('depth_delay_us', default_value='0'), diff --git a/orbbec_camera/launch/gemini_330_series.launch.py b/orbbec_camera/launch/gemini_330_series.launch.py index 2b61316f..4fc4954d 100644 --- a/orbbec_camera/launch/gemini_330_series.launch.py +++ b/orbbec_camera/launch/gemini_330_series.launch.py @@ -49,7 +49,7 @@ def load_parameters(context, args): yaml_params = load_yaml(config_file_path) default_params = merge_params(default_params, yaml_params) skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename', - 'enhanced_depth_model_path'} + 'enhanced_depth_model_path', 'depth_colorizer_mode'} result = {} for key, value in default_params.items(): @@ -212,7 +212,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), - DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), + DeclareLaunchArgument('depth_colorizer_mode', default_value='none'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('enable_ldp', default_value='false'), DeclareLaunchArgument('ldp_power_level', default_value='-1'), diff --git a/orbbec_camera/launch/gemini_330_series_low_cpu.launch.py b/orbbec_camera/launch/gemini_330_series_low_cpu.launch.py index 14364ec0..b412e194 100644 --- a/orbbec_camera/launch/gemini_330_series_low_cpu.launch.py +++ b/orbbec_camera/launch/gemini_330_series_low_cpu.launch.py @@ -43,7 +43,7 @@ def load_parameters(context, args): yaml_params = load_yaml(config_file_path) default_params = merge_params(default_params, yaml_params) skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename', - 'enhanced_depth_model_path'} + 'enhanced_depth_model_path', 'depth_colorizer_mode'} result = {} for key, value in default_params.items(): @@ -199,7 +199,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), - DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), + DeclareLaunchArgument('depth_colorizer_mode', default_value='none'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('enable_ldp', default_value='false'), DeclareLaunchArgument('ldp_power_level', default_value='-1'), diff --git a/orbbec_camera/launch/gemini_330_series_sdk_json.launch.py b/orbbec_camera/launch/gemini_330_series_sdk_json.launch.py index e5d04a92..9cab2b4a 100644 --- a/orbbec_camera/launch/gemini_330_series_sdk_json.launch.py +++ b/orbbec_camera/launch/gemini_330_series_sdk_json.launch.py @@ -41,7 +41,8 @@ def load_parameters(context, args): config_file_path = LaunchConfiguration('config_file_path').perform(context) if config_file_path: default_params = merge_params(default_params, load_yaml(config_file_path)) - skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename'} + skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename', + 'depth_colorizer_mode'} result = {} for key, value in default_params.items(): @@ -113,7 +114,7 @@ def generate_launch_description(): DeclareLaunchArgument('enable_frame_drop_log', default_value='false'), DeclareLaunchArgument('frame_timestamp_csv_file', default_value=''), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), - DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), + DeclareLaunchArgument('depth_colorizer_mode', default_value='none'), DeclareLaunchArgument('show_fps_enable', default_value='false'), DeclareLaunchArgument('enumerate_net_device', default_value='true'), diff --git a/orbbec_camera/launch/gemini_intra_process_demo_launch.py b/orbbec_camera/launch/gemini_intra_process_demo_launch.py index 1149f3b2..36df13fa 100644 --- a/orbbec_camera/launch/gemini_intra_process_demo_launch.py +++ b/orbbec_camera/launch/gemini_intra_process_demo_launch.py @@ -42,7 +42,8 @@ def load_parameters(context, args): if config_file_path: yaml_params = load_yaml(config_file_path) default_params = merge_params(default_params, yaml_params) - skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename'} + skip_convert = {'config_file_path', 'usb_port', 'serial_number', 'bag_record_filename', 'bag_filename', + 'depth_colorizer_mode'} return { key: (value if key in skip_convert else convert_value(value)) for key, value in default_params.items() @@ -117,7 +118,7 @@ def generate_launch_description(): DeclareLaunchArgument('log_file_name', default_value=''), DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'), DeclareLaunchArgument('enable_d2c_viewer', default_value='false'), - DeclareLaunchArgument('enable_depth_colorizer', default_value='false'), + DeclareLaunchArgument('depth_colorizer_mode', default_value='none'), DeclareLaunchArgument('disparity_to_depth_mode', default_value='HW'), DeclareLaunchArgument('enable_ldp', default_value='true'), DeclareLaunchArgument('sync_mode', default_value='standalone'), diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index 94fcd0f7..951dadd3 100755 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -66,7 +67,10 @@ namespace { constexpr char kEnhancedDepthSupportedTargetResolutions[] = "640x480/1280x720/1280x800"; constexpr char kEnhancedDepthSupportedDepthFormats[] = "Y10/Y11/Y12/Y14/Y16/Z16"; -constexpr double kColorizerMaxDistanceMm = 10000.0; +constexpr double kViewerColorizerGamma = 0.65; +constexpr uint16_t kViewerColorizerMaxDistanceMm = 10000; +constexpr uint16_t kViewerColorizerDefaultMinDistanceMm = 100; +constexpr uint16_t kViewerColorizerG305MinDistanceMm = 40; std::string getDepthFilterStatusName(const std::string &filter_name) { if (filter_name == "SpatialAdvancedFilter") { @@ -4467,7 +4471,10 @@ void OBCameraNode::getParameters() { setAndGetNodeParameter(point_cloud_decimation_filter_factor_, "point_cloud_decimation_filter_factor", 1); setAndGetNodeParameter(point_cloud_qos_, "point_cloud_qos", "default"); - setAndGetNodeParameter(colorizer_enabled_, "enable_depth_colorizer", false); + setAndGetNodeParameter(colorizer_mode_, "depth_colorizer_mode", "none"); + colorizer_mode_ = lowerParameterValue(colorizer_mode_); + colorizer_mode_ = normalizeClosedSetParameterValue( + logger_, "depth_colorizer_mode", colorizer_mode_, {"none", "jet", "jet_inv", "gray"}, "none"); setAndGetNodeParameter(enable_d2c_viewer_, "enable_d2c_viewer", false); setAndGetNodeParameter(disparity_to_depth_mode_, "disparity_to_depth_mode", ""); disparity_to_depth_mode_ = @@ -5430,9 +5437,10 @@ void OBCameraNode::setupPublishers() { } } - if (colorizer_enabled_ && enable_stream_[DEPTH]) { - RCLCPP_INFO(logger_, - "Depth colorizer enabled, publishing Jet RGB images on depth/image_raw (0-10 m)"); + if (colorizer_mode_ != "none" && enable_stream_[DEPTH]) { + RCLCPP_INFO_STREAM(logger_, "Depth colorizer mode '" + << colorizer_mode_ + << "' enabled, publishing colorized images on depth/image_raw"); } syncSoftwareAlignment(); @@ -5613,22 +5621,78 @@ cv::Mat OBCameraNode::colorizeDepthImage(const cv::Mat &depth_image) { return {}; } - cv::Mat depth_8u; - if (depth_image.type() == CV_16UC1 || depth_image.type() == CV_32FC1) { - depth_image.convertTo(depth_8u, CV_8UC1, 255.0 / kColorizerMaxDistanceMm); - } else if (depth_image.type() == CV_8UC1) { - depth_image.convertTo(depth_8u, CV_8UC1); - } else { + if (colorizer_mode_ == "none") { + return {}; + } + + if (depth_image.type() != CV_16UC1 && depth_image.type() != CV_32FC1 && + depth_image.type() != CV_8UC1) { RCLCPP_WARN_THROTTLE(logger_, *node_->get_clock(), 5000, "Unsupported depth image type for colorizer: %d", depth_image.type()); return {}; } - cv::Mat colorized_bgr; - cv::applyColorMap(depth_8u, colorized_bgr, cv::COLORMAP_JET); + cv::Mat depth_16u; + depth_image.convertTo(depth_16u, CV_16UC1); + + const uint16_t min_depth = isGemini305SeriesPID(pid_) ? kViewerColorizerG305MinDistanceMm + : kViewerColorizerDefaultMinDistanceMm; + const uint16_t max_depth = kViewerColorizerMaxDistanceMm; + const uint32_t value_range = static_cast(max_depth) - min_depth + 1; + std::array(kViewerColorizerMaxDistanceMm) + 1> histogram{}; + uint32_t valid_pixel_count = 0; + + for (int row = 0; row < depth_16u.rows; ++row) { + const auto *depth_row = depth_16u.ptr(row); + for (int col = 0; col < depth_16u.cols; ++col) { + const uint16_t depth_value = depth_row[col]; + if (depth_value >= min_depth && depth_value <= max_depth) { + ++histogram[depth_value]; + ++valid_pixel_count; + } + } + } + for (uint32_t depth_value = 1; depth_value <= max_depth; ++depth_value) { + histogram[depth_value] += histogram[depth_value - 1]; + } + + cv::Mat depth_8u(depth_16u.size(), CV_8UC1); + for (int row = 0; row < depth_16u.rows; ++row) { + const auto *depth_row = depth_16u.ptr(row); + auto *mapped_row = depth_8u.ptr(row); + for (int col = 0; col < depth_16u.cols; ++col) { + uint16_t depth_value = depth_row[col]; + if (depth_value > max_depth) { + depth_value = max_depth; + } + if (valid_pixel_count != 0 && depth_value >= min_depth) { + depth_value = static_cast(static_cast(value_range) * + histogram[depth_value] / valid_pixel_count + + min_depth); + } + const double normalized_depth = std::max( + 0.0, + std::min(1.0, (static_cast(depth_value) - min_depth) / (max_depth - min_depth))); + const double scale_value = 255.0 * std::pow(normalized_depth, kViewerColorizerGamma); + mapped_row[col] = static_cast(std::max(0.0, std::min(255.0, scale_value))); + } + } cv::Mat invalid_depth_mask; cv::compare(depth_image, cv::Scalar(0), invalid_depth_mask, cv::CMP_EQ); + depth_8u.setTo(cv::Scalar::all(0), invalid_depth_mask); + + if (colorizer_mode_ == "gray") { + return depth_8u; + } + if (colorizer_mode_ == "jet_inv") { + depth_8u = 255 - depth_8u; + depth_8u.setTo(cv::Scalar::all(0), invalid_depth_mask); + } + + cv::Mat colorized_bgr; + cv::applyColorMap(depth_8u, colorized_bgr, cv::COLORMAP_JET); + colorized_bgr.setTo(cv::Scalar::all(0), invalid_depth_mask); cv::Mat colorized_rgb; @@ -6827,12 +6891,13 @@ void OBCameraNode::onNewFrameCallback(const std::shared_ptr &frame, auto depth_scale = video_frame->as()->getValueScale(); image = image * depth_scale; image_to_publish = image; - if (colorizer_enabled_ && has_raw_image_subscriber) { + if (colorizer_mode_ != "none" && has_raw_image_subscriber) { auto colorized_image = colorizeDepthImage(image); if (!colorized_image.empty()) { image_to_publish = std::move(colorized_image); - image_encoding = sensor_msgs::image_encodings::RGB8; - image_step = static_cast(image_to_publish.cols * 3 * sizeof(uint8_t)); + image_encoding = colorizer_mode_ == "gray" ? sensor_msgs::image_encodings::MONO8 + : sensor_msgs::image_encodings::RGB8; + image_step = static_cast(image_to_publish.cols * image_to_publish.elemSize()); } } } From ac4346468eb8c51c0b4f9bc732e2ccd5ee621c0f Mon Sep 17 00:00:00 2001 From: slz Date: Tue, 18 Aug 2026 16:34:54 +0800 Subject: [PATCH 37/48] feat: configure image publisher history depth --- .../include/orbbec_camera/ob_camera_node.h | 4 ++ orbbec_camera/launch/astra.launch.py | 6 ++ orbbec_camera/launch/astra2.launch.py | 6 ++ orbbec_camera/launch/dabai_a.launch.py | 8 +++ orbbec_camera/launch/dabai_al.launch.py | 8 +++ orbbec_camera/launch/dabai_dcw2.launch.py | 6 ++ orbbec_camera/launch/dabai_max_pro.launch.py | 6 ++ orbbec_camera/launch/femto.launch.py | 6 ++ orbbec_camera/launch/femto_bolt.launch.py | 6 ++ orbbec_camera/launch/femto_mega.launch.py | 6 ++ orbbec_camera/launch/gemini2.launch.py | 6 ++ orbbec_camera/launch/gemini210.launch.py | 6 ++ orbbec_camera/launch/gemini2L.launch.py | 6 ++ orbbec_camera/launch/gemini345.launch.py | 8 +++ orbbec_camera/launch/gemini345_lg.launch.py | 8 +++ orbbec_camera/launch/gemini435_le.launch.py | 8 +++ .../launch/gemini_301_series.launch.py | 8 +++ .../launch/gemini_330_series.launch.py | 8 +++ .../gemini_330_series_low_cpu.launch.py | 8 +++ .../gemini_330_series_sdk_json.launch.py | 16 ++++++ .../gemini_intra_process_demo_launch.py | 8 +++ orbbec_camera/src/ob_camera_node.cpp | 57 ++++++++++++++----- 22 files changed, 196 insertions(+), 13 deletions(-) diff --git a/orbbec_camera/include/orbbec_camera/ob_camera_node.h b/orbbec_camera/include/orbbec_camera/ob_camera_node.h index f21ad31c..ec59c93a 100644 --- a/orbbec_camera/include/orbbec_camera/ob_camera_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_camera_node.h @@ -324,6 +324,8 @@ class OBCameraNode { void setupImagePublisher(const stream_index_pair& stream_index); + rmw_qos_profile_t getImageQosProfile(const stream_index_pair& stream_index) const; + void setupPipelineConfig(); void setupDiagnosticUpdater(); @@ -692,6 +694,8 @@ class OBCameraNode { std::string camera_link_frame_id_; bool depth_registration_ = false; std::map image_qos_; + std::map image_qos_history_; + std::map image_qos_depth_; std::map camera_info_qos_; std::map format_; std::map format_str_; diff --git a/orbbec_camera/launch/astra.launch.py b/orbbec_camera/launch/astra.launch.py index 0a498db9..3c1e838b 100644 --- a/orbbec_camera/launch/astra.launch.py +++ b/orbbec_camera/launch/astra.launch.py @@ -35,6 +35,8 @@ def generate_launch_description(): DeclareLaunchArgument('enable_color', default_value='true'), DeclareLaunchArgument('color_flip', default_value='false'), DeclareLaunchArgument('color_qos', default_value='default'), + DeclareLaunchArgument('color_qos_history', default_value='default'), + DeclareLaunchArgument('color_qos_depth', default_value='-1'), DeclareLaunchArgument('color_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_color_auto_exposure', default_value='true'), DeclareLaunchArgument('color_exposure', default_value='-1'), @@ -48,6 +50,8 @@ def generate_launch_description(): DeclareLaunchArgument('enable_depth', default_value='true'), DeclareLaunchArgument('depth_flip', default_value='false'), DeclareLaunchArgument('depth_qos', default_value='default'), + DeclareLaunchArgument('depth_qos_history', default_value='default'), + DeclareLaunchArgument('depth_qos_depth', default_value='-1'), DeclareLaunchArgument('depth_camera_info_qos', default_value='default'), DeclareLaunchArgument('ir_width', default_value='640'), DeclareLaunchArgument('ir_height', default_value='480'), @@ -56,6 +60,8 @@ def generate_launch_description(): DeclareLaunchArgument('enable_ir', default_value='false'), DeclareLaunchArgument('ir_flip', default_value='false'), DeclareLaunchArgument('ir_qos', default_value='default'), + DeclareLaunchArgument('ir_qos_history', default_value='default'), + DeclareLaunchArgument('ir_qos_depth', default_value='-1'), DeclareLaunchArgument('ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_ir_auto_exposure', default_value='true'), DeclareLaunchArgument('ir_exposure', default_value='-1'), diff --git a/orbbec_camera/launch/astra2.launch.py b/orbbec_camera/launch/astra2.launch.py index d17f738d..7a97a4e7 100644 --- a/orbbec_camera/launch/astra2.launch.py +++ b/orbbec_camera/launch/astra2.launch.py @@ -34,6 +34,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_color", default_value="true"), DeclareLaunchArgument("color_flip", default_value="false"), DeclareLaunchArgument("color_qos", default_value="default"), + DeclareLaunchArgument("color_qos_history", default_value="default"), + DeclareLaunchArgument("color_qos_depth", default_value="-1"), DeclareLaunchArgument("color_camera_info_qos", default_value="default"), DeclareLaunchArgument("enable_color_auto_exposure", default_value="true"), DeclareLaunchArgument("color_ae_max_exposure", default_value="-1"), @@ -49,6 +51,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_depth", default_value="true"), DeclareLaunchArgument("depth_flip", default_value="false"), DeclareLaunchArgument("depth_qos", default_value="default"), + DeclareLaunchArgument("depth_qos_history", default_value="default"), + DeclareLaunchArgument("depth_qos_depth", default_value="-1"), DeclareLaunchArgument("depth_camera_info_qos", default_value="default"), DeclareLaunchArgument("ir_width", default_value="800"), DeclareLaunchArgument("ir_height", default_value="600"), @@ -57,6 +61,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_ir", default_value="true"), DeclareLaunchArgument("ir_flip", default_value="false"), DeclareLaunchArgument("ir_qos", default_value="default"), + DeclareLaunchArgument("ir_qos_history", default_value="default"), + DeclareLaunchArgument("ir_qos_depth", default_value="-1"), DeclareLaunchArgument("ir_camera_info_qos", default_value="default"), DeclareLaunchArgument("enable_ir_auto_exposure", default_value="true"), DeclareLaunchArgument("ir_ae_max_exposure", default_value="-1"), diff --git a/orbbec_camera/launch/dabai_a.launch.py b/orbbec_camera/launch/dabai_a.launch.py index 33f2a11c..4d7b904e 100644 --- a/orbbec_camera/launch/dabai_a.launch.py +++ b/orbbec_camera/launch/dabai_a.launch.py @@ -94,6 +94,8 @@ def generate_launch_description(): DeclareLaunchArgument('color_format', default_value='ANY'), DeclareLaunchArgument('enable_color', default_value='true'), DeclareLaunchArgument('color_qos', default_value='default'), + DeclareLaunchArgument('color_qos_history', default_value='default'), + DeclareLaunchArgument('color_qos_depth', default_value='-1'), DeclareLaunchArgument('color_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_color_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('enable_color_auto_exposure', default_value='true'), @@ -116,6 +118,8 @@ def generate_launch_description(): DeclareLaunchArgument('depth_format', default_value='ANY'), DeclareLaunchArgument('enable_depth', default_value='true'), DeclareLaunchArgument('depth_qos', default_value='default'), + DeclareLaunchArgument('depth_qos_history', default_value='default'), + DeclareLaunchArgument('depth_qos_depth', default_value='-1'), DeclareLaunchArgument('depth_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_depth_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('depth_precision', default_value=''), @@ -126,6 +130,8 @@ def generate_launch_description(): DeclareLaunchArgument('left_ir_format', default_value='ANY'), DeclareLaunchArgument('enable_left_ir', default_value='false'), DeclareLaunchArgument('left_ir_qos', default_value='default'), + DeclareLaunchArgument('left_ir_qos_history', default_value='default'), + DeclareLaunchArgument('left_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('left_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('right_ir_width', default_value='0'), DeclareLaunchArgument('right_ir_height', default_value='0'), @@ -133,6 +139,8 @@ def generate_launch_description(): DeclareLaunchArgument('right_ir_format', default_value='ANY'), DeclareLaunchArgument('enable_right_ir', default_value='false'), DeclareLaunchArgument('right_ir_qos', default_value='default'), + DeclareLaunchArgument('right_ir_qos_history', default_value='default'), + DeclareLaunchArgument('right_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('right_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_ir_auto_exposure', default_value='true'), DeclareLaunchArgument('ir_exposure', default_value='-1'), diff --git a/orbbec_camera/launch/dabai_al.launch.py b/orbbec_camera/launch/dabai_al.launch.py index 1773024c..5640afc6 100644 --- a/orbbec_camera/launch/dabai_al.launch.py +++ b/orbbec_camera/launch/dabai_al.launch.py @@ -94,6 +94,8 @@ def generate_launch_description(): DeclareLaunchArgument('color_format', default_value='ANY'), DeclareLaunchArgument('enable_color', default_value='true'), DeclareLaunchArgument('color_qos', default_value='default'), + DeclareLaunchArgument('color_qos_history', default_value='default'), + DeclareLaunchArgument('color_qos_depth', default_value='-1'), DeclareLaunchArgument('color_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_color_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('enable_color_auto_exposure', default_value='true'), @@ -116,6 +118,8 @@ def generate_launch_description(): DeclareLaunchArgument('depth_format', default_value='ANY'), DeclareLaunchArgument('enable_depth', default_value='true'), DeclareLaunchArgument('depth_qos', default_value='default'), + DeclareLaunchArgument('depth_qos_history', default_value='default'), + DeclareLaunchArgument('depth_qos_depth', default_value='-1'), DeclareLaunchArgument('depth_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_depth_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('depth_precision', default_value=''), @@ -126,6 +130,8 @@ def generate_launch_description(): DeclareLaunchArgument('left_ir_format', default_value='ANY'), DeclareLaunchArgument('enable_left_ir', default_value='false'), DeclareLaunchArgument('left_ir_qos', default_value='default'), + DeclareLaunchArgument('left_ir_qos_history', default_value='default'), + DeclareLaunchArgument('left_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('left_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('right_ir_width', default_value='0'), DeclareLaunchArgument('right_ir_height', default_value='0'), @@ -133,6 +139,8 @@ def generate_launch_description(): DeclareLaunchArgument('right_ir_format', default_value='ANY'), DeclareLaunchArgument('enable_right_ir', default_value='false'), DeclareLaunchArgument('right_ir_qos', default_value='default'), + DeclareLaunchArgument('right_ir_qos_history', default_value='default'), + DeclareLaunchArgument('right_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('right_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_ir_auto_exposure', default_value='true'), DeclareLaunchArgument('ir_exposure', default_value='-1'), diff --git a/orbbec_camera/launch/dabai_dcw2.launch.py b/orbbec_camera/launch/dabai_dcw2.launch.py index 95a1eec0..ddd0c11f 100644 --- a/orbbec_camera/launch/dabai_dcw2.launch.py +++ b/orbbec_camera/launch/dabai_dcw2.launch.py @@ -35,6 +35,8 @@ def generate_launch_description(): DeclareLaunchArgument('enable_color', default_value='true'), DeclareLaunchArgument('flip_color', default_value='false'), DeclareLaunchArgument('color_qos', default_value='default'), + DeclareLaunchArgument('color_qos_history', default_value='default'), + DeclareLaunchArgument('color_qos_depth', default_value='-1'), DeclareLaunchArgument('color_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_color_auto_exposure', default_value='true'), DeclareLaunchArgument('enable_color_auto_exposure_priority', default_value='false'), @@ -56,6 +58,8 @@ def generate_launch_description(): DeclareLaunchArgument('enable_depth', default_value='true'), DeclareLaunchArgument('flip_depth', default_value='false'), DeclareLaunchArgument('depth_qos', default_value='default'), + DeclareLaunchArgument('depth_qos_history', default_value='default'), + DeclareLaunchArgument('depth_qos_depth', default_value='-1'), DeclareLaunchArgument('depth_camera_info_qos', default_value='default'), # /config/depthfilter/Openni_device.json,need config path. DeclareLaunchArgument('depth_filter_config', default_value=''), @@ -66,6 +70,8 @@ def generate_launch_description(): DeclareLaunchArgument('enable_ir', default_value='true'), DeclareLaunchArgument('flip_ir', default_value='false'), DeclareLaunchArgument('ir_qos', default_value='default'), + DeclareLaunchArgument('ir_qos_history', default_value='default'), + DeclareLaunchArgument('ir_qos_depth', default_value='-1'), DeclareLaunchArgument('ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_ir_auto_exposure', default_value='true'), DeclareLaunchArgument('ir_exposure', default_value='-1'), diff --git a/orbbec_camera/launch/dabai_max_pro.launch.py b/orbbec_camera/launch/dabai_max_pro.launch.py index 02757996..1e239305 100644 --- a/orbbec_camera/launch/dabai_max_pro.launch.py +++ b/orbbec_camera/launch/dabai_max_pro.launch.py @@ -38,6 +38,8 @@ def generate_launch_description(): DeclareLaunchArgument('color_mirror', default_value='false'), DeclareLaunchArgument('color_rotation', default_value='-1'), DeclareLaunchArgument('color_qos', default_value='default'), + DeclareLaunchArgument('color_qos_history', default_value='default'), + DeclareLaunchArgument('color_qos_depth', default_value='-1'), DeclareLaunchArgument('color_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_color_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('enable_color_auto_exposure', default_value='true'), @@ -63,6 +65,8 @@ def generate_launch_description(): DeclareLaunchArgument('depth_exposure', default_value='-1'), DeclareLaunchArgument('depth_gain', default_value='-1'), DeclareLaunchArgument('depth_qos', default_value='default'), + DeclareLaunchArgument('depth_qos_history', default_value='default'), + DeclareLaunchArgument('depth_qos_depth', default_value='-1'), DeclareLaunchArgument('depth_camera_info_qos', default_value='default'), # /config/depthfilter/Openni_device.json,need config path. DeclareLaunchArgument('depth_filter_config', default_value=''), @@ -73,6 +77,8 @@ def generate_launch_description(): DeclareLaunchArgument('enable_ir', default_value='true'), DeclareLaunchArgument('ir_flip', default_value='false'), DeclareLaunchArgument('ir_qos', default_value='default'), + DeclareLaunchArgument('ir_qos_history', default_value='default'), + DeclareLaunchArgument('ir_qos_depth', default_value='-1'), DeclareLaunchArgument('ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_ir_auto_exposure', default_value='true'), DeclareLaunchArgument('ir_exposure', default_value='-1'), diff --git a/orbbec_camera/launch/femto.launch.py b/orbbec_camera/launch/femto.launch.py index 6ea3f7aa..2da1beac 100644 --- a/orbbec_camera/launch/femto.launch.py +++ b/orbbec_camera/launch/femto.launch.py @@ -33,6 +33,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_color", default_value="true"), DeclareLaunchArgument("color_flip", default_value="false"), DeclareLaunchArgument("color_qos", default_value="default"), + DeclareLaunchArgument("color_qos_history", default_value="default"), + DeclareLaunchArgument("color_qos_depth", default_value="-1"), DeclareLaunchArgument("color_camera_info_qos", default_value="default"), DeclareLaunchArgument("enable_color_auto_exposure", default_value="true"), DeclareLaunchArgument("color_exposure", default_value="-1"), @@ -48,6 +50,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_depth", default_value="true"), DeclareLaunchArgument("depth_flip", default_value="false"), DeclareLaunchArgument("depth_qos", default_value="default"), + DeclareLaunchArgument("depth_qos_history", default_value="default"), + DeclareLaunchArgument("depth_qos_depth", default_value="-1"), DeclareLaunchArgument("depth_camera_info_qos", default_value="default"), DeclareLaunchArgument("ir_width", default_value="640"), DeclareLaunchArgument("ir_height", default_value="480"), @@ -56,6 +60,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_ir", default_value="true"), DeclareLaunchArgument("ir_flip", default_value="false"), DeclareLaunchArgument("ir_qos", default_value="default"), + DeclareLaunchArgument("ir_qos_history", default_value="default"), + DeclareLaunchArgument("ir_qos_depth", default_value="-1"), DeclareLaunchArgument("ir_camera_info_qos", default_value="default"), DeclareLaunchArgument("enable_ir_auto_exposure", default_value="true"), DeclareLaunchArgument("ir_exposure", default_value="-1"), diff --git a/orbbec_camera/launch/femto_bolt.launch.py b/orbbec_camera/launch/femto_bolt.launch.py index 7283f469..cd3cb0b9 100644 --- a/orbbec_camera/launch/femto_bolt.launch.py +++ b/orbbec_camera/launch/femto_bolt.launch.py @@ -34,6 +34,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_color", default_value="true"), DeclareLaunchArgument("color_flip", default_value="false"), DeclareLaunchArgument("color_qos", default_value="default"), + DeclareLaunchArgument("color_qos_history", default_value="default"), + DeclareLaunchArgument("color_qos_depth", default_value="-1"), DeclareLaunchArgument("color_camera_info_qos", default_value="default"), DeclareLaunchArgument("enable_color_auto_exposure", default_value="true"), DeclareLaunchArgument("color_ae_max_exposure", default_value="-1"), @@ -49,6 +51,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_depth", default_value="true"), DeclareLaunchArgument("depth_flip", default_value="false"), DeclareLaunchArgument("depth_qos", default_value="default"), + DeclareLaunchArgument("depth_qos_history", default_value="default"), + DeclareLaunchArgument("depth_qos_depth", default_value="-1"), DeclareLaunchArgument("depth_camera_info_qos", default_value="default"), DeclareLaunchArgument("ir_width", default_value="640"), DeclareLaunchArgument("ir_height", default_value="576"), @@ -57,6 +61,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_ir", default_value="true"), DeclareLaunchArgument("ir_flip", default_value="false"), DeclareLaunchArgument("ir_qos", default_value="default"), + DeclareLaunchArgument("ir_qos_history", default_value="default"), + DeclareLaunchArgument("ir_qos_depth", default_value="-1"), DeclareLaunchArgument("ir_camera_info_qos", default_value="default"), DeclareLaunchArgument("enable_ir_auto_exposure", default_value="true"), DeclareLaunchArgument("ir_ae_max_exposure", default_value="-1"), diff --git a/orbbec_camera/launch/femto_mega.launch.py b/orbbec_camera/launch/femto_mega.launch.py index 040e0696..7a643aa3 100644 --- a/orbbec_camera/launch/femto_mega.launch.py +++ b/orbbec_camera/launch/femto_mega.launch.py @@ -34,6 +34,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_color", default_value="true"), DeclareLaunchArgument("color_flip", default_value="false"), DeclareLaunchArgument("color_qos", default_value="default"), + DeclareLaunchArgument("color_qos_history", default_value="default"), + DeclareLaunchArgument("color_qos_depth", default_value="-1"), DeclareLaunchArgument("color_camera_info_qos", default_value="default"), DeclareLaunchArgument("enable_color_auto_exposure", default_value="true"), DeclareLaunchArgument("color_ae_max_exposure", default_value="-1"), @@ -49,6 +51,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_depth", default_value="true"), DeclareLaunchArgument("depth_flip", default_value="false"), DeclareLaunchArgument("depth_qos", default_value="default"), + DeclareLaunchArgument("depth_qos_history", default_value="default"), + DeclareLaunchArgument("depth_qos_depth", default_value="-1"), DeclareLaunchArgument("depth_camera_info_qos", default_value="default"), DeclareLaunchArgument("ir_width", default_value="640"), DeclareLaunchArgument("ir_height", default_value="576"), @@ -57,6 +61,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_ir", default_value="true"), DeclareLaunchArgument("ir_flip", default_value="false"), DeclareLaunchArgument("ir_qos", default_value="default"), + DeclareLaunchArgument("ir_qos_history", default_value="default"), + DeclareLaunchArgument("ir_qos_depth", default_value="-1"), DeclareLaunchArgument("ir_camera_info_qos", default_value="default"), DeclareLaunchArgument("enable_ir_auto_exposure", default_value="true"), DeclareLaunchArgument("ir_ae_max_exposure", default_value="-1"), diff --git a/orbbec_camera/launch/gemini2.launch.py b/orbbec_camera/launch/gemini2.launch.py index d0beb879..a64dd3f8 100644 --- a/orbbec_camera/launch/gemini2.launch.py +++ b/orbbec_camera/launch/gemini2.launch.py @@ -34,6 +34,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_color", default_value="true"), DeclareLaunchArgument("color_flip", default_value="false"), DeclareLaunchArgument("color_qos", default_value="default"), + DeclareLaunchArgument("color_qos_history", default_value="default"), + DeclareLaunchArgument("color_qos_depth", default_value="-1"), DeclareLaunchArgument("color_camera_info_qos", default_value="default"), DeclareLaunchArgument("enable_color_auto_exposure", default_value="true"), DeclareLaunchArgument("color_ae_max_exposure", default_value="-1"), @@ -57,6 +59,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_depth", default_value="true"), DeclareLaunchArgument("depth_flip", default_value="false"), DeclareLaunchArgument("depth_qos", default_value="default"), + DeclareLaunchArgument("depth_qos_history", default_value="default"), + DeclareLaunchArgument("depth_qos_depth", default_value="-1"), DeclareLaunchArgument("depth_camera_info_qos", default_value="default"), DeclareLaunchArgument("depth_ae_roi_left", default_value="-1"), DeclareLaunchArgument("depth_ae_roi_right", default_value="-1"), @@ -69,6 +73,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_ir", default_value="true"), DeclareLaunchArgument("ir_flip", default_value="false"), DeclareLaunchArgument("ir_qos", default_value="default"), + DeclareLaunchArgument("ir_qos_history", default_value="default"), + DeclareLaunchArgument("ir_qos_depth", default_value="-1"), DeclareLaunchArgument("ir_camera_info_qos", default_value="default"), DeclareLaunchArgument("enable_ir_auto_exposure", default_value="true"), DeclareLaunchArgument("ir_ae_max_exposure", default_value="-1"), diff --git a/orbbec_camera/launch/gemini210.launch.py b/orbbec_camera/launch/gemini210.launch.py index e5da7d5f..a48c9773 100644 --- a/orbbec_camera/launch/gemini210.launch.py +++ b/orbbec_camera/launch/gemini210.launch.py @@ -34,6 +34,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_color", default_value="true"), DeclareLaunchArgument("color_flip", default_value="false"), DeclareLaunchArgument("color_qos", default_value="default"), + DeclareLaunchArgument("color_qos_history", default_value="default"), + DeclareLaunchArgument("color_qos_depth", default_value="-1"), DeclareLaunchArgument("color_camera_info_qos", default_value="default"), DeclareLaunchArgument("enable_color_auto_exposure", default_value="true"), DeclareLaunchArgument("color_ae_max_exposure", default_value="-1"), @@ -55,6 +57,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_depth", default_value="true"), DeclareLaunchArgument("depth_flip", default_value="false"), DeclareLaunchArgument("depth_qos", default_value="default"), + DeclareLaunchArgument("depth_qos_history", default_value="default"), + DeclareLaunchArgument("depth_qos_depth", default_value="-1"), DeclareLaunchArgument("depth_camera_info_qos", default_value="default"), DeclareLaunchArgument("depth_ae_roi_left", default_value="-1"), DeclareLaunchArgument("depth_ae_roi_right", default_value="-1"), @@ -67,6 +71,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_ir", default_value="true"), DeclareLaunchArgument("ir_flip", default_value="false"), DeclareLaunchArgument("ir_qos", default_value="default"), + DeclareLaunchArgument("ir_qos_history", default_value="default"), + DeclareLaunchArgument("ir_qos_depth", default_value="-1"), DeclareLaunchArgument("ir_camera_info_qos", default_value="default"), DeclareLaunchArgument("enable_ir_auto_exposure", default_value="true"), DeclareLaunchArgument("ir_ae_max_exposure", default_value="-1"), diff --git a/orbbec_camera/launch/gemini2L.launch.py b/orbbec_camera/launch/gemini2L.launch.py index 81405065..bfec3b99 100644 --- a/orbbec_camera/launch/gemini2L.launch.py +++ b/orbbec_camera/launch/gemini2L.launch.py @@ -96,6 +96,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_color", default_value="true"), DeclareLaunchArgument("color_flip", default_value="false"), DeclareLaunchArgument("color_qos", default_value="default"), + DeclareLaunchArgument("color_qos_history", default_value="default"), + DeclareLaunchArgument("color_qos_depth", default_value="-1"), DeclareLaunchArgument("color_camera_info_qos", default_value="default"), DeclareLaunchArgument("enable_color_auto_exposure", default_value="true"), DeclareLaunchArgument("color_ae_max_exposure", default_value="-1"), @@ -115,6 +117,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_depth", default_value="true"), DeclareLaunchArgument("depth_flip", default_value="false"), DeclareLaunchArgument("depth_qos", default_value="default"), + DeclareLaunchArgument("depth_qos_history", default_value="default"), + DeclareLaunchArgument("depth_qos_depth", default_value="-1"), DeclareLaunchArgument("depth_camera_info_qos", default_value="default"), DeclareLaunchArgument("ir_width", default_value="640"), DeclareLaunchArgument("ir_height", default_value="400"), @@ -123,6 +127,8 @@ def generate_launch_description(): DeclareLaunchArgument("enable_ir", default_value="true"), DeclareLaunchArgument("ir_flip", default_value="false"), DeclareLaunchArgument("ir_qos", default_value="default"), + DeclareLaunchArgument("ir_qos_history", default_value="default"), + DeclareLaunchArgument("ir_qos_depth", default_value="-1"), DeclareLaunchArgument("ir_camera_info_qos", default_value="default"), DeclareLaunchArgument("enable_ir_auto_exposure", default_value="true"), DeclareLaunchArgument("ir_ae_max_exposure", default_value="-1"), diff --git a/orbbec_camera/launch/gemini345.launch.py b/orbbec_camera/launch/gemini345.launch.py index fd1e3167..29efb1ad 100644 --- a/orbbec_camera/launch/gemini345.launch.py +++ b/orbbec_camera/launch/gemini345.launch.py @@ -93,6 +93,8 @@ def generate_launch_description(): DeclareLaunchArgument('color_format', default_value='ANY'), DeclareLaunchArgument('enable_color', default_value='true'), DeclareLaunchArgument('color_qos', default_value='default'), + DeclareLaunchArgument('color_qos_history', default_value='default'), + DeclareLaunchArgument('color_qos_depth', default_value='-1'), DeclareLaunchArgument('color_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_color_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('enable_color_auto_exposure', default_value='true'), @@ -115,6 +117,8 @@ def generate_launch_description(): DeclareLaunchArgument('depth_format', default_value='ANY'), DeclareLaunchArgument('enable_depth', default_value='true'), DeclareLaunchArgument('depth_qos', default_value='default'), + DeclareLaunchArgument('depth_qos_history', default_value='default'), + DeclareLaunchArgument('depth_qos_depth', default_value='-1'), DeclareLaunchArgument('depth_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_depth_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('depth_precision', default_value=''), @@ -125,6 +129,8 @@ def generate_launch_description(): DeclareLaunchArgument('left_ir_format', default_value='ANY'), DeclareLaunchArgument('enable_left_ir', default_value='false'), DeclareLaunchArgument('left_ir_qos', default_value='default'), + DeclareLaunchArgument('left_ir_qos_history', default_value='default'), + DeclareLaunchArgument('left_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('left_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('right_ir_width', default_value='0'), DeclareLaunchArgument('right_ir_height', default_value='0'), @@ -132,6 +138,8 @@ def generate_launch_description(): DeclareLaunchArgument('right_ir_format', default_value='ANY'), DeclareLaunchArgument('enable_right_ir', default_value='false'), DeclareLaunchArgument('right_ir_qos', default_value='default'), + DeclareLaunchArgument('right_ir_qos_history', default_value='default'), + DeclareLaunchArgument('right_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('right_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_ir_auto_exposure', default_value='true'), DeclareLaunchArgument('ir_exposure', default_value='-1'), diff --git a/orbbec_camera/launch/gemini345_lg.launch.py b/orbbec_camera/launch/gemini345_lg.launch.py index 87e46fdd..a5ec7a15 100644 --- a/orbbec_camera/launch/gemini345_lg.launch.py +++ b/orbbec_camera/launch/gemini345_lg.launch.py @@ -94,6 +94,8 @@ def generate_launch_description(): DeclareLaunchArgument('color_format', default_value='ANY'), DeclareLaunchArgument('enable_color', default_value='true'), DeclareLaunchArgument('color_qos', default_value='default'), + DeclareLaunchArgument('color_qos_history', default_value='default'), + DeclareLaunchArgument('color_qos_depth', default_value='-1'), DeclareLaunchArgument('color_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_color_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('enable_color_auto_exposure', default_value='true'), @@ -116,6 +118,8 @@ def generate_launch_description(): DeclareLaunchArgument('depth_format', default_value='ANY'), DeclareLaunchArgument('enable_depth', default_value='true'), DeclareLaunchArgument('depth_qos', default_value='default'), + DeclareLaunchArgument('depth_qos_history', default_value='default'), + DeclareLaunchArgument('depth_qos_depth', default_value='-1'), DeclareLaunchArgument('depth_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_depth_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('depth_precision', default_value=''), @@ -126,6 +130,8 @@ def generate_launch_description(): DeclareLaunchArgument('left_ir_format', default_value='ANY'), DeclareLaunchArgument('enable_left_ir', default_value='false'), DeclareLaunchArgument('left_ir_qos', default_value='default'), + DeclareLaunchArgument('left_ir_qos_history', default_value='default'), + DeclareLaunchArgument('left_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('left_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('right_ir_width', default_value='0'), DeclareLaunchArgument('right_ir_height', default_value='0'), @@ -133,6 +139,8 @@ def generate_launch_description(): DeclareLaunchArgument('right_ir_format', default_value='ANY'), DeclareLaunchArgument('enable_right_ir', default_value='false'), DeclareLaunchArgument('right_ir_qos', default_value='default'), + DeclareLaunchArgument('right_ir_qos_history', default_value='default'), + DeclareLaunchArgument('right_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('right_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_ir_auto_exposure', default_value='true'), DeclareLaunchArgument('ir_exposure', default_value='-1'), diff --git a/orbbec_camera/launch/gemini435_le.launch.py b/orbbec_camera/launch/gemini435_le.launch.py index 726472be..2eca0b27 100644 --- a/orbbec_camera/launch/gemini435_le.launch.py +++ b/orbbec_camera/launch/gemini435_le.launch.py @@ -94,6 +94,8 @@ def generate_launch_description(): DeclareLaunchArgument('color_format', default_value='ANY'), DeclareLaunchArgument('enable_color', default_value='true'), DeclareLaunchArgument('color_qos', default_value='default'), + DeclareLaunchArgument('color_qos_history', default_value='default'), + DeclareLaunchArgument('color_qos_depth', default_value='-1'), DeclareLaunchArgument('color_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_color_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('color_rotation', default_value='-1'),#color rotation degree : 0, 90, 180, 270 @@ -126,6 +128,8 @@ def generate_launch_description(): DeclareLaunchArgument('depth_format', default_value='ANY'), DeclareLaunchArgument('enable_depth', default_value='true'), DeclareLaunchArgument('depth_qos', default_value='default'), + DeclareLaunchArgument('depth_qos_history', default_value='default'), + DeclareLaunchArgument('depth_qos_depth', default_value='-1'), DeclareLaunchArgument('depth_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_depth_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('depth_precision', default_value=''), @@ -143,6 +147,8 @@ def generate_launch_description(): DeclareLaunchArgument('left_ir_format', default_value='ANY'), DeclareLaunchArgument('enable_left_ir', default_value='false'), DeclareLaunchArgument('left_ir_qos', default_value='default'), + DeclareLaunchArgument('left_ir_qos_history', default_value='default'), + DeclareLaunchArgument('left_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('left_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('left_ir_rotation', default_value='-1'),#left_ir rotation degree : 0, 90, 180, 270 DeclareLaunchArgument('left_ir_flip', default_value='false'), @@ -153,6 +159,8 @@ def generate_launch_description(): DeclareLaunchArgument('right_ir_format', default_value='ANY'), DeclareLaunchArgument('enable_right_ir', default_value='false'), DeclareLaunchArgument('right_ir_qos', default_value='default'), + DeclareLaunchArgument('right_ir_qos_history', default_value='default'), + DeclareLaunchArgument('right_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('right_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('right_ir_rotation', default_value='-1'),#right_ir rotation degree : 0, 90, 180, 270 DeclareLaunchArgument('right_ir_flip', default_value='false'), diff --git a/orbbec_camera/launch/gemini_301_series.launch.py b/orbbec_camera/launch/gemini_301_series.launch.py index 4339900b..23e57da5 100644 --- a/orbbec_camera/launch/gemini_301_series.launch.py +++ b/orbbec_camera/launch/gemini_301_series.launch.py @@ -119,6 +119,8 @@ def generate_launch_description(): DeclareLaunchArgument('color_format', default_value='YUYV'), DeclareLaunchArgument('enable_color', default_value='true'), DeclareLaunchArgument('color_qos', default_value='default'), + DeclareLaunchArgument('color_qos_history', default_value='default'), + DeclareLaunchArgument('color_qos_depth', default_value='-1'), DeclareLaunchArgument('color_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_color_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('color_rotation', default_value='-1'),#color rotation degree : 0, 90, 180, 270 @@ -155,6 +157,8 @@ def generate_launch_description(): DeclareLaunchArgument('depth_format', default_value='Y16'), DeclareLaunchArgument('enable_depth', default_value='true'), DeclareLaunchArgument('depth_qos', default_value='default'), + DeclareLaunchArgument('depth_qos_history', default_value='default'), + DeclareLaunchArgument('depth_qos_depth', default_value='-1'), DeclareLaunchArgument('depth_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_depth_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('depth_precision', default_value=''), @@ -173,6 +177,8 @@ def generate_launch_description(): DeclareLaunchArgument('left_ir_format', default_value='Y8'), DeclareLaunchArgument('enable_left_ir', default_value='false'), DeclareLaunchArgument('left_ir_qos', default_value='default'), + DeclareLaunchArgument('left_ir_qos_history', default_value='default'), + DeclareLaunchArgument('left_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('left_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('left_ir_rotation', default_value='-1'),#left_ir rotation degree : 0, 90, 180, 270 DeclareLaunchArgument('left_ir_flip', default_value='false'), @@ -186,6 +192,8 @@ def generate_launch_description(): DeclareLaunchArgument('right_ir_format', default_value='Y8'), DeclareLaunchArgument('enable_right_ir', default_value='false'), DeclareLaunchArgument('right_ir_qos', default_value='default'), + DeclareLaunchArgument('right_ir_qos_history', default_value='default'), + DeclareLaunchArgument('right_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('right_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('right_ir_rotation', default_value='-1'),#right_ir rotation degree : 0, 90, 180, 270 DeclareLaunchArgument('right_ir_flip', default_value='false'), diff --git a/orbbec_camera/launch/gemini_330_series.launch.py b/orbbec_camera/launch/gemini_330_series.launch.py index a8860183..bcce78e2 100644 --- a/orbbec_camera/launch/gemini_330_series.launch.py +++ b/orbbec_camera/launch/gemini_330_series.launch.py @@ -108,6 +108,8 @@ def generate_launch_description(): DeclareLaunchArgument('color_format', default_value='ANY'), DeclareLaunchArgument('enable_color', default_value='true'), DeclareLaunchArgument('color_qos', default_value='default'), + DeclareLaunchArgument('color_qos_history', default_value='default'), + DeclareLaunchArgument('color_qos_depth', default_value='-1'), DeclareLaunchArgument('color_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_color_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('color_rotation', default_value='-1'),#color rotation degree : 0, 90, 180, 270 @@ -144,6 +146,8 @@ def generate_launch_description(): DeclareLaunchArgument('depth_format', default_value='ANY'), DeclareLaunchArgument('enable_depth', default_value='true'), DeclareLaunchArgument('depth_qos', default_value='default'), + DeclareLaunchArgument('depth_qos_history', default_value='default'), + DeclareLaunchArgument('depth_qos_depth', default_value='-1'), DeclareLaunchArgument('depth_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_depth_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('depth_precision', default_value=''), @@ -161,6 +165,8 @@ def generate_launch_description(): DeclareLaunchArgument('left_ir_format', default_value='ANY'), DeclareLaunchArgument('enable_left_ir', default_value='false'), DeclareLaunchArgument('left_ir_qos', default_value='default'), + DeclareLaunchArgument('left_ir_qos_history', default_value='default'), + DeclareLaunchArgument('left_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('left_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('left_ir_rotation', default_value='-1'),#left_ir rotation degree : 0, 90, 180, 270 DeclareLaunchArgument('left_ir_flip', default_value='false'), @@ -173,6 +179,8 @@ def generate_launch_description(): DeclareLaunchArgument('right_ir_format', default_value='ANY'), DeclareLaunchArgument('enable_right_ir', default_value='false'), DeclareLaunchArgument('right_ir_qos', default_value='default'), + DeclareLaunchArgument('right_ir_qos_history', default_value='default'), + DeclareLaunchArgument('right_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('right_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('right_ir_rotation', default_value='-1'),#right_ir rotation degree : 0, 90, 180, 270 DeclareLaunchArgument('right_ir_flip', default_value='false'), diff --git a/orbbec_camera/launch/gemini_330_series_low_cpu.launch.py b/orbbec_camera/launch/gemini_330_series_low_cpu.launch.py index 36be361e..7089840e 100644 --- a/orbbec_camera/launch/gemini_330_series_low_cpu.launch.py +++ b/orbbec_camera/launch/gemini_330_series_low_cpu.launch.py @@ -96,6 +96,8 @@ def generate_launch_description(): DeclareLaunchArgument('color_format', default_value='ANY'), DeclareLaunchArgument('enable_color', default_value='true'), DeclareLaunchArgument('color_qos', default_value='default'), + DeclareLaunchArgument('color_qos_history', default_value='default'), + DeclareLaunchArgument('color_qos_depth', default_value='-1'), DeclareLaunchArgument('color_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_color_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('color_rotation', default_value='-1'),#color rotation degree : 0, 90, 180, 270 @@ -132,6 +134,8 @@ def generate_launch_description(): DeclareLaunchArgument('depth_format', default_value='ANY'), DeclareLaunchArgument('enable_depth', default_value='true'), DeclareLaunchArgument('depth_qos', default_value='default'), + DeclareLaunchArgument('depth_qos_history', default_value='default'), + DeclareLaunchArgument('depth_qos_depth', default_value='-1'), DeclareLaunchArgument('depth_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_depth_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('depth_precision', default_value=''), @@ -149,6 +153,8 @@ def generate_launch_description(): DeclareLaunchArgument('left_ir_format', default_value='ANY'), DeclareLaunchArgument('enable_left_ir', default_value='false'), DeclareLaunchArgument('left_ir_qos', default_value='default'), + DeclareLaunchArgument('left_ir_qos_history', default_value='default'), + DeclareLaunchArgument('left_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('left_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('left_ir_rotation', default_value='-1'),#left_ir rotation degree : 0, 90, 180, 270 DeclareLaunchArgument('left_ir_flip', default_value='false'), @@ -161,6 +167,8 @@ def generate_launch_description(): DeclareLaunchArgument('right_ir_format', default_value='ANY'), DeclareLaunchArgument('enable_right_ir', default_value='false'), DeclareLaunchArgument('right_ir_qos', default_value='default'), + DeclareLaunchArgument('right_ir_qos_history', default_value='default'), + DeclareLaunchArgument('right_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('right_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('right_ir_rotation', default_value='-1'),#right_ir rotation degree : 0, 90, 180, 270 DeclareLaunchArgument('right_ir_flip', default_value='false'), diff --git a/orbbec_camera/launch/gemini_330_series_sdk_json.launch.py b/orbbec_camera/launch/gemini_330_series_sdk_json.launch.py index a41be6b1..7a8e862e 100644 --- a/orbbec_camera/launch/gemini_330_series_sdk_json.launch.py +++ b/orbbec_camera/launch/gemini_330_series_sdk_json.launch.py @@ -83,15 +83,31 @@ def generate_launch_description(): DeclareLaunchArgument('export_config_json_file_path', default_value=''), DeclareLaunchArgument('color_qos', default_value='default'), + + DeclareLaunchArgument('color_qos_history', default_value='default'), + + DeclareLaunchArgument('color_qos_depth', default_value='-1'), DeclareLaunchArgument('color_camera_info_qos', default_value='default'), DeclareLaunchArgument('depth_qos', default_value='default'), + + DeclareLaunchArgument('depth_qos_history', default_value='default'), + + DeclareLaunchArgument('depth_qos_depth', default_value='-1'), DeclareLaunchArgument('depth_camera_info_qos', default_value='default'), DeclareLaunchArgument('left_ir_qos', default_value='default'), + + DeclareLaunchArgument('left_ir_qos_history', default_value='default'), + + DeclareLaunchArgument('left_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('left_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('right_ir_qos', default_value='default'), + + DeclareLaunchArgument('right_ir_qos_history', default_value='default'), + + DeclareLaunchArgument('right_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('right_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_sync_output_accel_gyro', default_value='false'), diff --git a/orbbec_camera/launch/gemini_intra_process_demo_launch.py b/orbbec_camera/launch/gemini_intra_process_demo_launch.py index 21cc4ae2..43ec8282 100644 --- a/orbbec_camera/launch/gemini_intra_process_demo_launch.py +++ b/orbbec_camera/launch/gemini_intra_process_demo_launch.py @@ -70,6 +70,8 @@ def generate_launch_description(): DeclareLaunchArgument('color_format', default_value='ANY'), DeclareLaunchArgument('enable_color', default_value='true'), DeclareLaunchArgument('color_qos', default_value='default'), + DeclareLaunchArgument('color_qos_history', default_value='default'), + DeclareLaunchArgument('color_qos_depth', default_value='-1'), DeclareLaunchArgument('color_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_color_auto_exposure', default_value='true'), DeclareLaunchArgument('color_exposure', default_value='-1'), @@ -82,6 +84,8 @@ def generate_launch_description(): DeclareLaunchArgument('depth_format', default_value='ANY'), DeclareLaunchArgument('enable_depth', default_value='true'), DeclareLaunchArgument('depth_qos', default_value='default'), + DeclareLaunchArgument('depth_qos_history', default_value='default'), + DeclareLaunchArgument('depth_qos_depth', default_value='-1'), DeclareLaunchArgument('depth_camera_info_qos', default_value='default'), DeclareLaunchArgument('left_ir_width', default_value='0'), DeclareLaunchArgument('left_ir_height', default_value='0'), @@ -89,6 +93,8 @@ def generate_launch_description(): DeclareLaunchArgument('left_ir_format', default_value='ANY'), DeclareLaunchArgument('enable_left_ir', default_value='false'), DeclareLaunchArgument('left_ir_qos', default_value='default'), + DeclareLaunchArgument('left_ir_qos_history', default_value='default'), + DeclareLaunchArgument('left_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('left_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('right_ir_width', default_value='0'), DeclareLaunchArgument('right_ir_height', default_value='0'), @@ -96,6 +102,8 @@ def generate_launch_description(): DeclareLaunchArgument('right_ir_format', default_value='ANY'), DeclareLaunchArgument('enable_right_ir', default_value='false'), DeclareLaunchArgument('right_ir_qos', default_value='default'), + DeclareLaunchArgument('right_ir_qos_history', default_value='default'), + DeclareLaunchArgument('right_ir_qos_depth', default_value='-1'), DeclareLaunchArgument('right_ir_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_ir_auto_exposure', default_value='true'), DeclareLaunchArgument('ir_exposure', default_value='-1'), diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index 1aa56019..925726f5 100755 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -16,6 +16,7 @@ #include "orbbec_camera/ob_camera_node.h" #include +#include #include #include #include @@ -4415,6 +4416,20 @@ void OBCameraNode::getParameters() { updateImageConfig(stream_index); param_name = stream_name_[stream_index] + "_qos"; setAndGetNodeParameter(image_qos_[stream_index], param_name, "default"); + param_name = stream_name_[stream_index] + "_qos_history"; + setAndGetNodeParameter(image_qos_history_[stream_index], param_name, "default"); + std::transform(image_qos_history_[stream_index].begin(), image_qos_history_[stream_index].end(), + image_qos_history_[stream_index].begin(), ::toupper); + if (image_qos_history_[stream_index] != "DEFAULT" && + image_qos_history_[stream_index] != "KEEP_LAST" && + image_qos_history_[stream_index] != "KEEP_ALL") { + throw std::invalid_argument(param_name + " must be DEFAULT, KEEP_LAST, or KEEP_ALL"); + } + param_name = stream_name_[stream_index] + "_qos_depth"; + setAndGetNodeParameter(image_qos_depth_[stream_index], param_name, -1); + if (image_qos_depth_[stream_index] == 0 || image_qos_depth_[stream_index] < -1) { + throw std::invalid_argument(param_name + " must be -1 or greater than zero"); + } param_name = stream_name_[stream_index] + "_camera_info_qos"; setAndGetNodeParameter(camera_info_qos_[stream_index], param_name, "default"); param_name = "enable_" + stream_name_[stream_index] + "_undistortion"; @@ -5267,10 +5282,7 @@ void OBCameraNode::setupConfidencePublishers() { if (confidence_image_publisher_) { return; } - auto image_qos_profile = getRMWQosProfileFromString(image_qos_[DEPTH]); - if (use_intra_process_) { - image_qos_profile = rmw_qos_profile_default; - } + const auto image_qos_profile = getImageQosProfile(DEPTH); confidence_image_publisher_ = node_->create_publisher( "confidence/image_raw", rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(image_qos_profile), image_qos_profile)); @@ -5359,11 +5371,7 @@ void OBCameraNode::setupImagePublisher(const stream_index_pair &stream_index) { } const std::string topic = stream_name_[stream_index] + "/image_raw"; - auto image_qos_profile = getRMWQosProfileFromString(image_qos_[stream_index]); - if (use_intra_process_) { - image_qos_profile = rmw_qos_profile_default; - } - + const auto image_qos_profile = getImageQosProfile(stream_index); const bool is_mjpg_color_stream = (stream_index == COLOR || stream_index == COLOR_LEFT || stream_index == COLOR_RIGHT) && format_[stream_index] == OB_FORMAT_MJPG; @@ -5374,6 +5382,14 @@ void OBCameraNode::setupImagePublisher(const stream_index_pair &stream_index) { image_publishers_[stream_index] = std::make_shared(*node_, topic, image_qos_profile); } + std::string history = rmw_qos_history_policy_to_str(image_qos_profile.history); + if (image_qos_profile.history == RMW_QOS_POLICY_HISTORY_KEEP_LAST) { + history += "(" + std::to_string(image_qos_profile.depth) + ")"; + } + RCLCPP_INFO_STREAM( + logger_, topic << " QoS: " << rmw_qos_reliability_policy_to_str(image_qos_profile.reliability) + << ", " << rmw_qos_durability_policy_to_str(image_qos_profile.durability) + << ", " << history); if (is_mjpg_color_stream) { compressed_image_publishers_[stream_index] = @@ -5385,6 +5401,24 @@ void OBCameraNode::setupImagePublisher(const stream_index_pair &stream_index) { } } +rmw_qos_profile_t OBCameraNode::getImageQosProfile(const stream_index_pair &stream_index) const { + auto image_qos_profile = getRMWQosProfileFromString(image_qos_.at(stream_index)); + if (use_intra_process_) { + image_qos_profile = rmw_qos_profile_default; + } + const auto &history = image_qos_history_.at(stream_index); + if (history == "KEEP_LAST") { + image_qos_profile.history = RMW_QOS_POLICY_HISTORY_KEEP_LAST; + } else if (history == "KEEP_ALL") { + image_qos_profile.history = RMW_QOS_POLICY_HISTORY_KEEP_ALL; + } + const auto depth = image_qos_depth_.at(stream_index); + if (depth > 0) { + image_qos_profile.depth = static_cast(depth); + } + return image_qos_profile; +} + void OBCameraNode::setupPublishers() { using PointCloud2 = sensor_msgs::msg::PointCloud2; using CameraInfo = sensor_msgs::msg::CameraInfo; @@ -5529,10 +5563,7 @@ void OBCameraNode::syncSoftwareAlignment() { RCLCPP_INFO_STREAM(logger_, "set align mode to " << align_mode_); } if (!depth_unaligned_publisher_) { - auto depth_image_qos_profile = getRMWQosProfileFromString(image_qos_[DEPTH]); - if (use_intra_process_) { - depth_image_qos_profile = rmw_qos_profile_default; - } + const auto depth_image_qos_profile = getImageQosProfile(DEPTH); if (use_intra_process_) { depth_unaligned_publisher_ = std::make_shared( *node_, "depth/image_unaligned", depth_image_qos_profile); From c141430c62e22d2b28cf564d211a56b3c2837c21 Mon Sep 17 00:00:00 2001 From: slz Date: Wed, 19 Aug 2026 10:27:58 +0800 Subject: [PATCH 38/48] feat: bound and diagnose color frame queues --- .../include/orbbec_camera/ob_camera_node.h | 44 ++++- orbbec_camera/launch/astra.launch.py | 1 + orbbec_camera/launch/astra2.launch.py | 1 + orbbec_camera/launch/dabai_a.launch.py | 1 + orbbec_camera/launch/dabai_al.launch.py | 1 + orbbec_camera/launch/dabai_dcw2.launch.py | 1 + orbbec_camera/launch/dabai_max_pro.launch.py | 1 + orbbec_camera/launch/femto.launch.py | 1 + orbbec_camera/launch/femto_bolt.launch.py | 1 + orbbec_camera/launch/femto_mega.launch.py | 1 + orbbec_camera/launch/gemini2.launch.py | 1 + orbbec_camera/launch/gemini210.launch.py | 1 + orbbec_camera/launch/gemini2L.launch.py | 1 + orbbec_camera/launch/gemini345.launch.py | 1 + orbbec_camera/launch/gemini345_lg.launch.py | 1 + orbbec_camera/launch/gemini435_le.launch.py | 1 + .../launch/gemini_301_series.launch.py | 3 + .../launch/gemini_330_series.launch.py | 1 + .../gemini_330_series_low_cpu.launch.py | 1 + .../gemini_330_series_sdk_json.launch.py | 2 + .../gemini_intra_process_demo_launch.py | 1 + orbbec_camera/src/ob_camera_node.cpp | 172 ++++++++++++++---- orbbec_camera/src/ros_service.cpp | 47 +++++ 23 files changed, 244 insertions(+), 42 deletions(-) diff --git a/orbbec_camera/include/orbbec_camera/ob_camera_node.h b/orbbec_camera/include/orbbec_camera/ob_camera_node.h index ec59c93a..d80a6f18 100644 --- a/orbbec_camera/include/orbbec_camera/ob_camera_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_camera_node.h @@ -18,9 +18,12 @@ #include +#include #include +#include #include #include +#include #include #include #include @@ -334,6 +337,9 @@ class OBCameraNode { void setupCameraCtrlServices(); + void getColorQueueStatsCallback(const std::shared_ptr& request, + std::shared_ptr& response); + void stopStreams(); void stopIMU(); @@ -772,6 +778,7 @@ class OBCameraNode { rclcpp::Service::SharedPtr set_sync_io_voltage_level_srv_; rclcpp::Service::SharedPtr get_streams_enable_srv_; rclcpp::Service::SharedPtr set_streams_enable_srv_; + rclcpp::Service::SharedPtr get_color_queue_stats_srv_; rclcpp::Service::SharedPtr set_image_registration_mode_srv_; rclcpp::Service::SharedPtr set_stream_profile_srv_; rclcpp::Service::SharedPtr get_user_calib_params_srv_; @@ -915,21 +922,52 @@ class OBCameraNode { bool is_right_color_frame_decoded_ = false; bool is_color_frame_decoded_ = false; std::recursive_mutex device_lock_; + struct QueuedColorFrame { + std::shared_ptr frame_set; + std::chrono::steady_clock::time_point enqueue_time; + }; + struct ColorQueueStats { + size_t max_queue_size = 0; + uint64_t overflow_count = 0; + double max_queue_wait_ms = 0.0; + }; + struct ColorQueueStatsSnapshot { + int capacity_frames = 0; + size_t queue_size = 0; + size_t max_queue_size = 0; + uint64_t overflow_count = 0; + double oldest_queue_wait_ms = 0.0; + double max_queue_wait_ms = 0.0; + }; + using ColorFrameQueue = std::queue; + void enqueueColorFrame(ColorFrameQueue& queue, std::mutex& mutex, + std::condition_variable& condition_variable, ColorQueueStats& stats, + int capacity_frames, const std::shared_ptr& frame_set, + const char* queue_name); + ColorQueueStatsSnapshot getColorQueueStats(ColorFrameQueue& queue, std::mutex& mutex, + ColorQueueStats& stats, int capacity_frames, + bool reset); // For color - std::queue> color_frame_queue_; + ColorFrameQueue color_frame_queue_; + ColorQueueStats color_frame_queue_stats_; + int color_frame_queue_max_frames_ = 10; std::shared_ptr colorFrameThread_ = nullptr; std::atomic_bool stop_color_frame_threads_{false}; std::mutex color_frame_queue_lock_; std::condition_variable color_frame_queue_cv_; // For left color - std::queue> left_color_frame_queue_; + ColorFrameQueue left_color_frame_queue_; + ColorQueueStats left_color_frame_queue_stats_; + int left_color_frame_queue_max_frames_ = 10; std::shared_ptr leftColorFrameThread_ = nullptr; std::mutex left_color_frame_queue_lock_; std::condition_variable left_color_frame_queue_cv_; // For right color - std::queue> right_color_frame_queue_; + ColorFrameQueue right_color_frame_queue_; + ColorQueueStats right_color_frame_queue_stats_; + int right_color_frame_queue_max_frames_ = 10; std::shared_ptr rightColorFrameThread_ = nullptr; std::mutex right_color_frame_queue_lock_; std::condition_variable right_color_frame_queue_cv_; diff --git a/orbbec_camera/launch/astra.launch.py b/orbbec_camera/launch/astra.launch.py index 3c1e838b..8921c357 100644 --- a/orbbec_camera/launch/astra.launch.py +++ b/orbbec_camera/launch/astra.launch.py @@ -28,6 +28,7 @@ def generate_launch_description(): DeclareLaunchArgument('cloud_frame_id', default_value=''), DeclareLaunchArgument('point_cloud_qos', default_value='default'), DeclareLaunchArgument('connection_delay', default_value='100'), + DeclareLaunchArgument('color_frame_queue_max_frames', default_value='10'), DeclareLaunchArgument('color_width', default_value='640'), DeclareLaunchArgument('color_height', default_value='480'), DeclareLaunchArgument('color_fps', default_value='10'), diff --git a/orbbec_camera/launch/astra2.launch.py b/orbbec_camera/launch/astra2.launch.py index 7a97a4e7..8dc5e316 100644 --- a/orbbec_camera/launch/astra2.launch.py +++ b/orbbec_camera/launch/astra2.launch.py @@ -27,6 +27,7 @@ def generate_launch_description(): DeclareLaunchArgument("cloud_frame_id", default_value=""), DeclareLaunchArgument("point_cloud_qos", default_value="default"), DeclareLaunchArgument("connection_delay", default_value="100"), + DeclareLaunchArgument("color_frame_queue_max_frames", default_value="10"), DeclareLaunchArgument("color_width", default_value="1280"), DeclareLaunchArgument("color_height", default_value="720"), DeclareLaunchArgument("color_fps", default_value="30"), diff --git a/orbbec_camera/launch/dabai_a.launch.py b/orbbec_camera/launch/dabai_a.launch.py index 4d7b904e..2151043d 100644 --- a/orbbec_camera/launch/dabai_a.launch.py +++ b/orbbec_camera/launch/dabai_a.launch.py @@ -88,6 +88,7 @@ def generate_launch_description(): DeclareLaunchArgument('enable_colored_point_cloud', default_value='false'), DeclareLaunchArgument('cloud_frame_id', default_value=''), DeclareLaunchArgument('connection_delay', default_value='10'), + DeclareLaunchArgument('color_frame_queue_max_frames', default_value='10'), DeclareLaunchArgument('color_width', default_value='0'), DeclareLaunchArgument('color_height', default_value='0'), DeclareLaunchArgument('color_fps', default_value='0'), diff --git a/orbbec_camera/launch/dabai_al.launch.py b/orbbec_camera/launch/dabai_al.launch.py index 5640afc6..42f708b1 100644 --- a/orbbec_camera/launch/dabai_al.launch.py +++ b/orbbec_camera/launch/dabai_al.launch.py @@ -88,6 +88,7 @@ def generate_launch_description(): DeclareLaunchArgument('enable_colored_point_cloud', default_value='false'), DeclareLaunchArgument('cloud_frame_id', default_value=''), DeclareLaunchArgument('connection_delay', default_value='10'), + DeclareLaunchArgument('color_frame_queue_max_frames', default_value='10'), DeclareLaunchArgument('color_width', default_value='0'), DeclareLaunchArgument('color_height', default_value='0'), DeclareLaunchArgument('color_fps', default_value='0'), diff --git a/orbbec_camera/launch/dabai_dcw2.launch.py b/orbbec_camera/launch/dabai_dcw2.launch.py index ddd0c11f..2bdf6716 100644 --- a/orbbec_camera/launch/dabai_dcw2.launch.py +++ b/orbbec_camera/launch/dabai_dcw2.launch.py @@ -28,6 +28,7 @@ def generate_launch_description(): DeclareLaunchArgument('cloud_frame_id', default_value=''), DeclareLaunchArgument('point_cloud_qos', default_value='default'), DeclareLaunchArgument('connection_delay', default_value='100'), + DeclareLaunchArgument('color_frame_queue_max_frames', default_value='10'), DeclareLaunchArgument('color_width', default_value='640'), DeclareLaunchArgument('color_height', default_value='480'), DeclareLaunchArgument('color_fps', default_value='15'), diff --git a/orbbec_camera/launch/dabai_max_pro.launch.py b/orbbec_camera/launch/dabai_max_pro.launch.py index 1e239305..7abbbe84 100644 --- a/orbbec_camera/launch/dabai_max_pro.launch.py +++ b/orbbec_camera/launch/dabai_max_pro.launch.py @@ -29,6 +29,7 @@ def generate_launch_description(): DeclareLaunchArgument('point_cloud_qos', default_value='default'), DeclareLaunchArgument('connection_delay', default_value='100'), DeclareLaunchArgument('diagnostic_period', default_value='0.0'), + DeclareLaunchArgument('color_frame_queue_max_frames', default_value='10'), DeclareLaunchArgument('color_width', default_value='640'), DeclareLaunchArgument('color_height', default_value='480'), DeclareLaunchArgument('color_fps', default_value='25'), diff --git a/orbbec_camera/launch/femto.launch.py b/orbbec_camera/launch/femto.launch.py index 2da1beac..096de049 100644 --- a/orbbec_camera/launch/femto.launch.py +++ b/orbbec_camera/launch/femto.launch.py @@ -26,6 +26,7 @@ def generate_launch_description(): DeclareLaunchArgument("enable_colored_point_cloud", default_value="false"), DeclareLaunchArgument("point_cloud_qos", default_value="default"), DeclareLaunchArgument("connection_delay", default_value="100"), + DeclareLaunchArgument("color_frame_queue_max_frames", default_value="10"), DeclareLaunchArgument("color_width", default_value="640"), DeclareLaunchArgument("color_height", default_value="480"), DeclareLaunchArgument("color_fps", default_value="30"), diff --git a/orbbec_camera/launch/femto_bolt.launch.py b/orbbec_camera/launch/femto_bolt.launch.py index cd3cb0b9..ad857ee6 100644 --- a/orbbec_camera/launch/femto_bolt.launch.py +++ b/orbbec_camera/launch/femto_bolt.launch.py @@ -27,6 +27,7 @@ def generate_launch_description(): DeclareLaunchArgument("enable_colored_point_cloud", default_value="false"), DeclareLaunchArgument("point_cloud_qos", default_value="default"), DeclareLaunchArgument("connection_delay", default_value="100"), + DeclareLaunchArgument("color_frame_queue_max_frames", default_value="10"), DeclareLaunchArgument("color_width", default_value="1280"), DeclareLaunchArgument("color_height", default_value="720"), DeclareLaunchArgument("color_fps", default_value="30"), diff --git a/orbbec_camera/launch/femto_mega.launch.py b/orbbec_camera/launch/femto_mega.launch.py index 7a643aa3..b882d16b 100644 --- a/orbbec_camera/launch/femto_mega.launch.py +++ b/orbbec_camera/launch/femto_mega.launch.py @@ -27,6 +27,7 @@ def generate_launch_description(): DeclareLaunchArgument("enable_colored_point_cloud", default_value="false"), DeclareLaunchArgument("point_cloud_qos", default_value="default"), DeclareLaunchArgument("connection_delay", default_value="100"), + DeclareLaunchArgument("color_frame_queue_max_frames", default_value="10"), DeclareLaunchArgument("color_width", default_value="1280"), DeclareLaunchArgument("color_height", default_value="720"), DeclareLaunchArgument("color_fps", default_value="30"), diff --git a/orbbec_camera/launch/gemini2.launch.py b/orbbec_camera/launch/gemini2.launch.py index a64dd3f8..21c5f8e3 100644 --- a/orbbec_camera/launch/gemini2.launch.py +++ b/orbbec_camera/launch/gemini2.launch.py @@ -27,6 +27,7 @@ def generate_launch_description(): DeclareLaunchArgument("enable_colored_point_cloud", default_value="false"), DeclareLaunchArgument("point_cloud_qos", default_value="default"), DeclareLaunchArgument("connection_delay", default_value="100"), + DeclareLaunchArgument("color_frame_queue_max_frames", default_value="10"), DeclareLaunchArgument("color_width", default_value="0"), DeclareLaunchArgument("color_height", default_value="0"), DeclareLaunchArgument("color_fps", default_value="0"), diff --git a/orbbec_camera/launch/gemini210.launch.py b/orbbec_camera/launch/gemini210.launch.py index a48c9773..23bda161 100644 --- a/orbbec_camera/launch/gemini210.launch.py +++ b/orbbec_camera/launch/gemini210.launch.py @@ -27,6 +27,7 @@ def generate_launch_description(): DeclareLaunchArgument("enable_colored_point_cloud", default_value="false"), DeclareLaunchArgument("point_cloud_qos", default_value="default"), DeclareLaunchArgument("connection_delay", default_value="100"), + DeclareLaunchArgument("color_frame_queue_max_frames", default_value="10"), DeclareLaunchArgument("color_width", default_value="0"), DeclareLaunchArgument("color_height", default_value="0"), DeclareLaunchArgument("color_fps", default_value="0"), diff --git a/orbbec_camera/launch/gemini2L.launch.py b/orbbec_camera/launch/gemini2L.launch.py index bfec3b99..8dec1b3b 100644 --- a/orbbec_camera/launch/gemini2L.launch.py +++ b/orbbec_camera/launch/gemini2L.launch.py @@ -89,6 +89,7 @@ def generate_launch_description(): DeclareLaunchArgument("enable_colored_point_cloud", default_value="false"), DeclareLaunchArgument("point_cloud_qos", default_value="default"), DeclareLaunchArgument("connection_delay", default_value="100"), + DeclareLaunchArgument("color_frame_queue_max_frames", default_value="10"), DeclareLaunchArgument("color_width", default_value="1280"), DeclareLaunchArgument("color_height", default_value="800"), DeclareLaunchArgument("color_fps", default_value="30"), diff --git a/orbbec_camera/launch/gemini345.launch.py b/orbbec_camera/launch/gemini345.launch.py index 29efb1ad..d59befc0 100644 --- a/orbbec_camera/launch/gemini345.launch.py +++ b/orbbec_camera/launch/gemini345.launch.py @@ -87,6 +87,7 @@ def generate_launch_description(): DeclareLaunchArgument('enable_colored_point_cloud', default_value='false'), DeclareLaunchArgument('cloud_frame_id', default_value=''), DeclareLaunchArgument('connection_delay', default_value='10'), + DeclareLaunchArgument('color_frame_queue_max_frames', default_value='10'), DeclareLaunchArgument('color_width', default_value='0'), DeclareLaunchArgument('color_height', default_value='0'), DeclareLaunchArgument('color_fps', default_value='0'), diff --git a/orbbec_camera/launch/gemini345_lg.launch.py b/orbbec_camera/launch/gemini345_lg.launch.py index a5ec7a15..947c416f 100644 --- a/orbbec_camera/launch/gemini345_lg.launch.py +++ b/orbbec_camera/launch/gemini345_lg.launch.py @@ -88,6 +88,7 @@ def generate_launch_description(): DeclareLaunchArgument('enable_colored_point_cloud', default_value='false'), DeclareLaunchArgument('cloud_frame_id', default_value=''), DeclareLaunchArgument('connection_delay', default_value='10'), + DeclareLaunchArgument('color_frame_queue_max_frames', default_value='10'), DeclareLaunchArgument('color_width', default_value='0'), DeclareLaunchArgument('color_height', default_value='0'), DeclareLaunchArgument('color_fps', default_value='0'), diff --git a/orbbec_camera/launch/gemini435_le.launch.py b/orbbec_camera/launch/gemini435_le.launch.py index 2eca0b27..d2ad1764 100644 --- a/orbbec_camera/launch/gemini435_le.launch.py +++ b/orbbec_camera/launch/gemini435_le.launch.py @@ -88,6 +88,7 @@ def generate_launch_description(): DeclareLaunchArgument('enable_colored_point_cloud', default_value='false'), DeclareLaunchArgument('cloud_frame_id', default_value=''), DeclareLaunchArgument('connection_delay', default_value='10'), + DeclareLaunchArgument('color_frame_queue_max_frames', default_value='10'), DeclareLaunchArgument('color_width', default_value='0'), DeclareLaunchArgument('color_height', default_value='0'), DeclareLaunchArgument('color_fps', default_value='0'), diff --git a/orbbec_camera/launch/gemini_301_series.launch.py b/orbbec_camera/launch/gemini_301_series.launch.py index 23e57da5..751f87cb 100644 --- a/orbbec_camera/launch/gemini_301_series.launch.py +++ b/orbbec_camera/launch/gemini_301_series.launch.py @@ -111,6 +111,9 @@ def generate_launch_description(): DeclareLaunchArgument('enable_colored_point_cloud', default_value='false'), DeclareLaunchArgument('cloud_frame_id', default_value=''), DeclareLaunchArgument('connection_delay', default_value='10'), + DeclareLaunchArgument('color_frame_queue_max_frames', default_value='10'), + DeclareLaunchArgument('left_color_frame_queue_max_frames', default_value='10'), + DeclareLaunchArgument('right_color_frame_queue_max_frames', default_value='10'), DeclareLaunchArgument('ae_reference_stream', default_value='depth'), # depth or color DeclareLaunchArgument('ae_strategy', default_value='motion'), # default or motion DeclareLaunchArgument('color_width', default_value='848'), diff --git a/orbbec_camera/launch/gemini_330_series.launch.py b/orbbec_camera/launch/gemini_330_series.launch.py index bcce78e2..edbdfb75 100644 --- a/orbbec_camera/launch/gemini_330_series.launch.py +++ b/orbbec_camera/launch/gemini_330_series.launch.py @@ -102,6 +102,7 @@ def generate_launch_description(): DeclareLaunchArgument('enable_colored_point_cloud', default_value='false'), DeclareLaunchArgument('cloud_frame_id', default_value=''), DeclareLaunchArgument('connection_delay', default_value='10'), + DeclareLaunchArgument('color_frame_queue_max_frames', default_value='10'), DeclareLaunchArgument('color_width', default_value='0'), DeclareLaunchArgument('color_height', default_value='0'), DeclareLaunchArgument('color_fps', default_value='0'), diff --git a/orbbec_camera/launch/gemini_330_series_low_cpu.launch.py b/orbbec_camera/launch/gemini_330_series_low_cpu.launch.py index 7089840e..922d9974 100644 --- a/orbbec_camera/launch/gemini_330_series_low_cpu.launch.py +++ b/orbbec_camera/launch/gemini_330_series_low_cpu.launch.py @@ -90,6 +90,7 @@ def generate_launch_description(): DeclareLaunchArgument('enable_colored_point_cloud', default_value='false'), DeclareLaunchArgument('cloud_frame_id', default_value=''), DeclareLaunchArgument('connection_delay', default_value='10'), + DeclareLaunchArgument('color_frame_queue_max_frames', default_value='10'), DeclareLaunchArgument('color_width', default_value='0'), DeclareLaunchArgument('color_height', default_value='0'), DeclareLaunchArgument('color_fps', default_value='0'), diff --git a/orbbec_camera/launch/gemini_330_series_sdk_json.launch.py b/orbbec_camera/launch/gemini_330_series_sdk_json.launch.py index 7a8e862e..b3e65f3d 100644 --- a/orbbec_camera/launch/gemini_330_series_sdk_json.launch.py +++ b/orbbec_camera/launch/gemini_330_series_sdk_json.launch.py @@ -82,6 +82,8 @@ def generate_launch_description(): DeclareLaunchArgument('load_config_json_file_path', default_value=''), DeclareLaunchArgument('export_config_json_file_path', default_value=''), + DeclareLaunchArgument('color_frame_queue_max_frames', default_value='10'), + DeclareLaunchArgument('color_qos', default_value='default'), DeclareLaunchArgument('color_qos_history', default_value='default'), diff --git a/orbbec_camera/launch/gemini_intra_process_demo_launch.py b/orbbec_camera/launch/gemini_intra_process_demo_launch.py index 43ec8282..1ecf1b7f 100644 --- a/orbbec_camera/launch/gemini_intra_process_demo_launch.py +++ b/orbbec_camera/launch/gemini_intra_process_demo_launch.py @@ -64,6 +64,7 @@ def generate_launch_description(): DeclareLaunchArgument('enable_colored_point_cloud', default_value='true'), DeclareLaunchArgument('cloud_frame_id', default_value=''), DeclareLaunchArgument('connection_delay', default_value='10'), + DeclareLaunchArgument('color_frame_queue_max_frames', default_value='10'), DeclareLaunchArgument('color_width', default_value='0'), DeclareLaunchArgument('color_height', default_value='0'), DeclareLaunchArgument('color_fps', default_value='0'), diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index 925726f5..f0c67931 100755 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -3811,17 +3811,17 @@ bool OBCameraNode::applyStreamProfiles(const std::vector & void OBCameraNode::clearColorFrameQueues() { { std::lock_guard lock(color_frame_queue_lock_); - std::queue> empty; + ColorFrameQueue empty; std::swap(color_frame_queue_, empty); } { std::lock_guard lock(left_color_frame_queue_lock_); - std::queue> empty; + ColorFrameQueue empty; std::swap(left_color_frame_queue_, empty); } { std::lock_guard lock(right_color_frame_queue_lock_); - std::queue> empty; + ColorFrameQueue empty; std::swap(right_color_frame_queue_, empty); } is_color_frame_decoded_ = false; @@ -3829,6 +3829,56 @@ void OBCameraNode::clearColorFrameQueues() { is_right_color_frame_decoded_ = false; } +void OBCameraNode::enqueueColorFrame(ColorFrameQueue &queue, std::mutex &mutex, + std::condition_variable &condition_variable, + ColorQueueStats &stats, int capacity_frames, + const std::shared_ptr &frame_set, + const char *queue_name) { + uint64_t overflow_count = 0; + { + std::lock_guard lock(mutex); + const auto now = std::chrono::steady_clock::now(); + if (queue.size() >= static_cast(capacity_frames)) { + const auto oldest_age = + std::chrono::duration(now - queue.front().enqueue_time).count(); + stats.max_queue_wait_ms = std::max(stats.max_queue_wait_ms, oldest_age); + queue.pop(); + overflow_count = ++stats.overflow_count; + } + queue.push(QueuedColorFrame{frame_set, now}); + stats.max_queue_size = std::max(stats.max_queue_size, queue.size()); + } + condition_variable.notify_one(); + if (overflow_count == 1 || (overflow_count > 0 && overflow_count % 100 == 0)) { + RCLCPP_WARN_STREAM( + logger_, "Color frame queue overflow: queue=" << queue_name << " count=" << overflow_count + << " capacity_frames=" << capacity_frames); + } +} + +OBCameraNode::ColorQueueStatsSnapshot OBCameraNode::getColorQueueStats(ColorFrameQueue &queue, + std::mutex &mutex, + ColorQueueStats &stats, + int capacity_frames, + bool reset) { + std::lock_guard lock(mutex); + const auto oldest_queue_wait_ms = + queue.empty() ? 0.0 + : std::chrono::duration(std::chrono::steady_clock::now() - + queue.front().enqueue_time) + .count(); + stats.max_queue_wait_ms = std::max(stats.max_queue_wait_ms, oldest_queue_wait_ms); + const ColorQueueStatsSnapshot snapshot{capacity_frames, queue.size(), + stats.max_queue_size, stats.overflow_count, + oldest_queue_wait_ms, stats.max_queue_wait_ms}; + if (reset) { + stats.max_queue_size = queue.size(); + stats.overflow_count = 0; + stats.max_queue_wait_ms = oldest_queue_wait_ms; + } + return snapshot; +} + void OBCameraNode::stopColorFrameThreads() { if (!colorFrameThread_ && !leftColorFrameThread_ && !rightColorFrameThread_) { return; @@ -4383,6 +4433,20 @@ void OBCameraNode::setupDefaultImageFormat() { void OBCameraNode::getParameters() { setAndGetNodeParameter(camera_name_, "camera_name", "camera"); + setAndGetNodeParameter(color_frame_queue_max_frames_, "color_frame_queue_max_frames", 10); + setAndGetNodeParameter(left_color_frame_queue_max_frames_, + "left_color_frame_queue_max_frames", 10); + setAndGetNodeParameter(right_color_frame_queue_max_frames_, + "right_color_frame_queue_max_frames", 10); + const auto validate_queue_capacity = [](const char *name, int capacity) { + if (capacity < 1) { + throw std::invalid_argument(std::string(name) + " must be greater than zero"); + } + }; + validate_queue_capacity("color_frame_queue_max_frames", color_frame_queue_max_frames_); + validate_queue_capacity("left_color_frame_queue_max_frames", left_color_frame_queue_max_frames_); + validate_queue_capacity("right_color_frame_queue_max_frames", + right_color_frame_queue_max_frames_); camera_link_frame_id_ = camera_name_ + "_link"; for (auto stream_index : IMAGE_STREAMS) { std::string param_name = stream_name_[stream_index] + "_width"; @@ -6302,22 +6366,22 @@ void OBCameraNode::onNewFrameSetCallback(std::shared_ptr frame_set } if (enable_stream_[COLOR] && color_frame) { - std::unique_lock lock(color_frame_queue_lock_); - color_frame_queue_.push(frame_set); - color_frame_queue_cv_.notify_all(); + enqueueColorFrame(color_frame_queue_, color_frame_queue_lock_, color_frame_queue_cv_, + color_frame_queue_stats_, color_frame_queue_max_frames_, frame_set, + "color"); } else { publishPointCloud(frame_set); } if (enable_stream_[COLOR_LEFT] && left_color_frame) { - std::unique_lock lock(left_color_frame_queue_lock_); - left_color_frame_queue_.push(frame_set); - left_color_frame_queue_cv_.notify_all(); + enqueueColorFrame(left_color_frame_queue_, left_color_frame_queue_lock_, + left_color_frame_queue_cv_, left_color_frame_queue_stats_, + left_color_frame_queue_max_frames_, frame_set, "left_color"); } if (enable_stream_[COLOR_RIGHT] && right_color_frame) { - std::unique_lock lock(right_color_frame_queue_lock_); - right_color_frame_queue_.push(frame_set); - right_color_frame_queue_cv_.notify_all(); + enqueueColorFrame(right_color_frame_queue_, right_color_frame_queue_lock_, + right_color_frame_queue_cv_, right_color_frame_queue_stats_, + right_color_frame_queue_max_frames_, frame_set, "right_color"); } for (const auto &stream_index : IMAGE_STREAMS) { @@ -6369,20 +6433,30 @@ void OBCameraNode::logFrameInfoOnce(const stream_index_pair &stream_index, void OBCameraNode::onNewColorFrameCallback() { while (enable_stream_[COLOR] && rclcpp::ok() && is_running_.load() && !stop_color_frame_threads_.load()) { - std::unique_lock lock(color_frame_queue_lock_); - color_frame_queue_cv_.wait(lock, [this]() { - return !color_frame_queue_.empty() || !(is_running_.load()) || - stop_color_frame_threads_.load(); - }); + std::shared_ptr frameSet; + { + std::unique_lock lock(color_frame_queue_lock_); + color_frame_queue_cv_.wait(lock, [this]() { + return !color_frame_queue_.empty() || !(is_running_.load()) || + stop_color_frame_threads_.load(); + }); - if (!rclcpp::ok() || !is_running_.load() || stop_color_frame_threads_.load()) { - break; + if (!rclcpp::ok() || !is_running_.load() || stop_color_frame_threads_.load()) { + break; + } + const auto queued = color_frame_queue_.front(); + color_frame_queue_.pop(); + frameSet = queued.frame_set; + color_frame_queue_stats_.max_queue_wait_ms = + std::max(color_frame_queue_stats_.max_queue_wait_ms, + std::chrono::duration(std::chrono::steady_clock::now() - + queued.enqueue_time) + .count()); } - std::shared_ptr frameSet = color_frame_queue_.front(); + is_color_frame_decoded_ = decodeColorFrameToBuffer(frameSet->colorFrame(), rgb_buffer_); onNewFrameCallback(frameSet->colorFrame(), COLOR); publishPointCloud(frameSet); - color_frame_queue_.pop(); } RCLCPP_DEBUG_STREAM(logger_, "Color frame thread exited"); @@ -6391,20 +6465,30 @@ void OBCameraNode::onNewColorFrameCallback() { void OBCameraNode::onNewLeftColorFrameCallback() { while (enable_stream_[COLOR_LEFT] && rclcpp::ok() && is_running_.load() && !stop_color_frame_threads_.load()) { - std::unique_lock lock(left_color_frame_queue_lock_); - left_color_frame_queue_cv_.wait(lock, [this]() { - return !left_color_frame_queue_.empty() || !(is_running_.load()) || - stop_color_frame_threads_.load(); - }); + std::shared_ptr frameSet; + { + std::unique_lock lock(left_color_frame_queue_lock_); + left_color_frame_queue_cv_.wait(lock, [this]() { + return !left_color_frame_queue_.empty() || !(is_running_.load()) || + stop_color_frame_threads_.load(); + }); - if (!rclcpp::ok() || !is_running_.load() || stop_color_frame_threads_.load()) { - break; + if (!rclcpp::ok() || !is_running_.load() || stop_color_frame_threads_.load()) { + break; + } + const auto queued = left_color_frame_queue_.front(); + left_color_frame_queue_.pop(); + frameSet = queued.frame_set; + left_color_frame_queue_stats_.max_queue_wait_ms = + std::max(left_color_frame_queue_stats_.max_queue_wait_ms, + std::chrono::duration(std::chrono::steady_clock::now() - + queued.enqueue_time) + .count()); } - std::shared_ptr frameSet = left_color_frame_queue_.front(); + is_left_color_frame_decoded_ = decodeColorFrameToBuffer(frameSet->getFrame(OB_FRAME_COLOR_LEFT), rgb_buffer_left_); onNewFrameCallback(frameSet->getFrame(OB_FRAME_COLOR_LEFT), COLOR_LEFT); - left_color_frame_queue_.pop(); } RCLCPP_DEBUG_STREAM(logger_, "Left color frame thread exited"); } @@ -6412,20 +6496,30 @@ void OBCameraNode::onNewLeftColorFrameCallback() { void OBCameraNode::onNewRightColorFrameCallback() { while (enable_stream_[COLOR_RIGHT] && rclcpp::ok() && is_running_.load() && !stop_color_frame_threads_.load()) { - std::unique_lock lock(right_color_frame_queue_lock_); - right_color_frame_queue_cv_.wait(lock, [this]() { - return !right_color_frame_queue_.empty() || !(is_running_.load()) || - stop_color_frame_threads_.load(); - }); + std::shared_ptr frameSet; + { + std::unique_lock lock(right_color_frame_queue_lock_); + right_color_frame_queue_cv_.wait(lock, [this]() { + return !right_color_frame_queue_.empty() || !(is_running_.load()) || + stop_color_frame_threads_.load(); + }); - if (!rclcpp::ok() || !is_running_.load() || stop_color_frame_threads_.load()) { - break; + if (!rclcpp::ok() || !is_running_.load() || stop_color_frame_threads_.load()) { + break; + } + const auto queued = right_color_frame_queue_.front(); + right_color_frame_queue_.pop(); + frameSet = queued.frame_set; + right_color_frame_queue_stats_.max_queue_wait_ms = + std::max(right_color_frame_queue_stats_.max_queue_wait_ms, + std::chrono::duration(std::chrono::steady_clock::now() - + queued.enqueue_time) + .count()); } - std::shared_ptr frameSet = right_color_frame_queue_.front(); + is_right_color_frame_decoded_ = decodeColorFrameToBuffer(frameSet->getFrame(OB_FRAME_COLOR_RIGHT), rgb_buffer_right_); onNewFrameCallback(frameSet->getFrame(OB_FRAME_COLOR_RIGHT), COLOR_RIGHT); - right_color_frame_queue_.pop(); } RCLCPP_DEBUG_STREAM(logger_, "Right color frame thread exited"); } diff --git a/orbbec_camera/src/ros_service.cpp b/orbbec_camera/src/ros_service.cpp index 8c4be54b..5a8a3fbf 100644 --- a/orbbec_camera/src/ros_service.cpp +++ b/orbbec_camera/src/ros_service.cpp @@ -121,6 +121,11 @@ std::string OBSyncModeToString(const OBMultiDeviceSyncMode& mode) { void OBCameraNode::setupCameraCtrlServices() { using std_srvs::srv::SetBool; + get_color_queue_stats_srv_ = node_->create_service( + "get_color_queue_stats", [this](const std::shared_ptr request, + std::shared_ptr response) { + getColorQueueStatsCallback(request, response); + }); for (auto stream_index : IMAGE_STREAMS) { if (!enable_stream_[stream_index]) { continue; @@ -458,6 +463,48 @@ void OBCameraNode::setupCameraCtrlServices() { } } +void OBCameraNode::getColorQueueStatsCallback( + const std::shared_ptr& request, + std::shared_ptr& response) { + try { + const auto to_json = [](const ColorQueueStatsSnapshot& stats) { + return nlohmann::json{ + {"capacity_frames", stats.capacity_frames}, + {"queue_size", stats.queue_size}, + {"max_queue_size", stats.max_queue_size}, + {"overflow_count", stats.overflow_count}, + {"oldest_queue_wait_ms", stats.oldest_queue_wait_ms}, + {"max_queue_wait_ms", stats.max_queue_wait_ms}, + }; + }; + nlohmann::json queues; + queues["color"] = to_json(getColorQueueStats(color_frame_queue_, color_frame_queue_lock_, + color_frame_queue_stats_, + color_frame_queue_max_frames_, request->data)); + queues["left_color"] = to_json(getColorQueueStats( + left_color_frame_queue_, left_color_frame_queue_lock_, left_color_frame_queue_stats_, + left_color_frame_queue_max_frames_, request->data)); + queues["right_color"] = to_json(getColorQueueStats( + right_color_frame_queue_, right_color_frame_queue_lock_, right_color_frame_queue_stats_, + right_color_frame_queue_max_frames_, request->data)); + const uint64_t overflow_count = queues["color"]["overflow_count"].get() + + queues["left_color"]["overflow_count"].get() + + queues["right_color"]["overflow_count"].get(); + response->success = true; + response->message = + nlohmann::json{ + {"namespace", node_->get_namespace()}, + {"overflow_count", overflow_count}, + {"statistics_reset", request->data}, + {"queues", queues}, + } + .dump(); + } catch (const std::exception& error) { + response->success = false; + response->message = error.what(); + } +} + void OBCameraNode::getPointCloudDecimationCallback( const std::shared_ptr& request, std::shared_ptr& response) { From 7e3adade6559976ade537e76227ecf28e78b00b4 Mon Sep 17 00:00:00 2001 From: ob-yalian Date: Wed, 19 Aug 2026 11:15:08 +0800 Subject: [PATCH 39/48] feat: update image saving functionality and metadata handling in camera node --- README.MD | 11 -- README_CN.MD | 11 -- .../include/orbbec_camera/ob_camera_node.h | 7 +- orbbec_camera/src/ob_camera_node.cpp | 124 +++++++++++++----- 4 files changed, 94 insertions(+), 59 deletions(-) diff --git a/README.MD b/README.MD index 73afb4ab..0eef390a 100644 --- a/README.MD +++ b/README.MD @@ -334,8 +334,6 @@ Launch camera node source ~/ros2_ws/install/setup.bash ros2 run orbbec_camera list_devices_node # Check if the camera is connected ros2 launch orbbec_camera gemini_330_series.launch.py # Or other launch file, see below table -# Optional: publish OrbbecViewer-style colorized depth on /camera/depth/image_raw -ros2 launch orbbec_camera gemini_330_series.launch.py depth_colorizer_mode:=jet ``` - On terminal 2 @@ -369,15 +367,6 @@ ros2 service call /camera/get_sdk_version orbbec_camera_msgs/srv/GetString '{}' For more usage details, please refer to the official [OrbbecSDK ROS2 documentation](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/4_application_guide/application_guide.html) -`depth_colorizer_mode` is a string render mode: - -- `none`: disable colorization and publish the raw `16UC1` depth image; -- `jet`: use the OrbbecViewer-style dynamic histogram, gamma, and Jet mapping; -- `jet_inv`: use the OrbbecViewer-style inverse Jet mapping; -- `gray`: use the OrbbecViewer-style grayscale mapping; - -The `jet` and `jet_inv` modes publish `rgb8`; `gray` publishes `mono8` on `depth/image_raw`. - ## Supported Devices Currently, the following devices are supported by the OrbbecSDK ROS2 Wrapper v2-main branch. More devices support will be added in the near future. If you can not find your device in the table below, try the [main](https://github.com/orbbec/OrbbecSDK_ROS2/tree/main) branch. diff --git a/README_CN.MD b/README_CN.MD index 962be62f..0ae10dea 100644 --- a/README_CN.MD +++ b/README_CN.MD @@ -333,8 +333,6 @@ sudo bash install_udev_rules.sh source ~/ros2_ws/install/setup.bash ros2 run orbbec_camera list_devices_node #检查相机是否已连接 ros2 launch orbbec_camera gemini_330_series.launch.py # 或其他启动文件,见下表 -# 可选:使用 OrbbecViewer 风格发布伪彩色深度图到 /camera/depth/image_raw -ros2 launch orbbec_camera gemini_330_series.launch.py depth_colorizer_mode:=jet ``` - 终端 2 @@ -368,15 +366,6 @@ ros2 service call /camera/get_sdk_version orbbec_camera_msgs/srv/GetString '{}' 更多使用详情,请参考官方 [OrbbecSDK ROS2 文档](https://orbbec.github.io/OrbbecSDK_ROS2/zh/source/camera_devices/4_application_guide/application_guide.html) -`depth_colorizer_mode` 是字符串渲染模式: - -- `none`:关闭彩色化,`depth/image_raw` 发布原始 `16UC1` 深度图; -- `jet`:使用 OrbbecViewer 的动态直方图、伽马和 Jet 映射; -- `jet_inv`:使用 OrbbecViewer 风格的反向 Jet 映射; -- `gray`:使用 OrbbecViewer 风格的灰度映射; - -`jet` 和 `jet_inv` 模式发布 `rgb8`,`gray` 模式发布 `mono8` 到 `depth/image_raw`。 - ## 支持的设备 目前 v2-main 分支支持以下设备。更多设备支持将陆续增加。如果没有找到您的设备,请尝试 [main](https://github.com/orbbec/OrbbecSDK_ROS2/tree/main) 分支。 diff --git a/orbbec_camera/include/orbbec_camera/ob_camera_node.h b/orbbec_camera/include/orbbec_camera/ob_camera_node.h index ba0bccf2..0e1b7610 100644 --- a/orbbec_camera/include/orbbec_camera/ob_camera_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_camera_node.h @@ -592,14 +592,17 @@ class OBCameraNode { void publishMetadata(const std::shared_ptr& frame, const stream_index_pair& stream_index, const std_msgs::msg::Header& header); + std::string createFrameMetadataJson(const std::shared_ptr& frame) const; + void onNewColorFrameCallback(); void onNewLeftColorFrameCallback(); void onNewRightColorFrameCallback(); - void saveImageToFile(const stream_index_pair& stream_index, const cv::Mat& image, - const sensor_msgs::msg::Image& image_msg); + void saveImageToFile(const stream_index_pair& stream_index, const cv::Mat& raw_image, + const cv::Mat& image_to_save, const sensor_msgs::msg::Image& image_msg, + const std::shared_ptr& frame); void onNewIMUFrameSyncOutputCallback(const std::shared_ptr& accelframe, const std::shared_ptr& gryoframe); diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index 951dadd3..3faa6eae 100755 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -6884,6 +6884,7 @@ void OBCameraNode::onNewFrameCallback(const std::shared_ptr &frame, camera_info_publishers_[stream_index]->publish(camera_info); publishMetadata(frame, stream_index, camera_info.header); + cv::Mat raw_image = image; cv::Mat image_to_publish = image; std::string image_encoding = encoding_[stream_index]; uint32_t image_step = width * unit_step_size_[stream_index]; @@ -6891,7 +6892,7 @@ void OBCameraNode::onNewFrameCallback(const std::shared_ptr &frame, auto depth_scale = video_frame->as()->getValueScale(); image = image * depth_scale; image_to_publish = image; - if (colorizer_mode_ != "none" && has_raw_image_subscriber) { + if (colorizer_mode_ != "none" && (has_raw_image_subscriber || save_images_[stream_index])) { auto colorized_image = colorizeDepthImage(image); if (!colorized_image.empty()) { image_to_publish = std::move(colorized_image); @@ -6914,7 +6915,7 @@ void OBCameraNode::onNewFrameCallback(const std::shared_ptr &frame, image_msg->is_bigendian = false; image_msg->step = image_step; image_msg->header.frame_id = frame_id; - saveImageToFile(stream_index, image, *image_msg); + saveImageToFile(stream_index, raw_image, image_to_publish, *image_msg, frame); if (!has_raw_image_subscriber) { record_image_publish_skipped(); return; @@ -6968,8 +6969,15 @@ void OBCameraNode::publishMetadata(const std::shared_ptr &frame, } orbbec_camera_msgs::msg::Metadata metadata_msg; metadata_msg.header = header; - nlohmann::json json_data; + metadata_msg.json_data = createFrameMetadataJson(frame); + metadata_publisher->publish(metadata_msg); +} +std::string OBCameraNode::createFrameMetadataJson(const std::shared_ptr &frame) const { + nlohmann::json json_data; + if (frame == nullptr) { + return json_data.dump(2); + } for (int i = 0; i < OB_FRAME_METADATA_TYPE_COUNT; i++) { auto meta_data_type = static_cast(i); std::string field_name = metaDataTypeToString(meta_data_type); @@ -6979,12 +6987,13 @@ void OBCameraNode::publishMetadata(const std::shared_ptr &frame, int64_t value = frame->getMetadataValue(meta_data_type); json_data[field_name] = value; } - metadata_msg.json_data = json_data.dump(2); - metadata_publisher->publish(metadata_msg); + return json_data.dump(2); } -void OBCameraNode::saveImageToFile(const stream_index_pair &stream_index, const cv::Mat &image, - const sensor_msgs::msg::Image &image_msg) { +void OBCameraNode::saveImageToFile(const stream_index_pair &stream_index, const cv::Mat &raw_image, + const cv::Mat &image_to_save, + const sensor_msgs::msg::Image &image_msg, + const std::shared_ptr &frame) { if (save_images_[stream_index]) { auto now = std::chrono::system_clock::now(); auto in_time_t = std::chrono::system_clock::to_time_t(now); @@ -6994,42 +7003,87 @@ void OBCameraNode::saveImageToFile(const stream_index_pair &stream_index, const std::stringstream ss; ss << std::put_time(std::localtime(&in_time_t), "%Y%m%d_%H%M%S"); ss << "_" << std::setw(6) << std::setfill('0') << us.count(); - auto current_path = std::filesystem::current_path().string(); + const auto output_directory = std::filesystem::current_path() / "image"; auto fps = fps_[stream_index]; - int index = save_images_count_[stream_index]; - std::string file_suffix = stream_index == COLOR ? ".png" : ".raw"; - std::string filename = current_path + "/image/" + stream_name_[stream_index] + "_" + - std::to_string(image_msg.width) + "x" + - std::to_string(image_msg.height) + "_" + std::to_string(fps) + "hz_" + - ss.str() + "_" + std::to_string(index) + file_suffix; - if (!std::filesystem::exists(current_path + "/image")) { - std::filesystem::create_directory(current_path + "/image"); + const int index = save_images_count_[stream_index]; + const std::string file_name = stream_name_[stream_index] + "_" + + std::to_string(image_msg.width) + "x" + + std::to_string(image_msg.height) + "_" + std::to_string(fps) + + "hz_" + ss.str() + "_" + std::to_string(index); + if (!std::filesystem::exists(output_directory)) { + std::filesystem::create_directories(output_directory); } - RCLCPP_INFO_STREAM(logger_, "Saving image to " << filename); - if (stream_index.first == OB_STREAM_COLOR) { - auto image_to_save = - cv_bridge::toCvCopy(image_msg, sensor_msgs::image_encodings::BGR8)->image; - cv::imwrite(filename, image_to_save); - } else if (stream_index.first == OB_STREAM_IR || stream_index.first == OB_STREAM_IR_LEFT || - stream_index.first == OB_STREAM_IR_RIGHT || stream_index.first == OB_STREAM_DEPTH) { - std::ofstream ofs(filename, std::ios::out | std::ios::binary); - if (!ofs.is_open()) { - RCLCPP_ERROR_STREAM(logger_, "Failed to open file: " << filename); - return; + const auto file_stem = (output_directory / file_name).string(); + const auto raw_filename = file_stem + ".raw"; + const auto png_filename = file_stem + ".png"; + const auto metadata_filename = file_stem + ".json"; + RCLCPP_INFO_STREAM(logger_, "Saving frame files to " << file_stem << " (.raw, .png, .json)"); + + const auto *frame_data = frame ? frame->getData() : nullptr; + const auto frame_data_size = frame ? frame->getDataSize() : 0; + std::ofstream ofs(raw_filename, std::ios::out | std::ios::binary); + if (!ofs.is_open()) { + RCLCPP_ERROR_STREAM(logger_, "Failed to open raw file: " << raw_filename); + } else if (frame_data != nullptr && frame_data_size > 0) { + ofs.write(reinterpret_cast(frame_data), + static_cast(frame_data_size)); + if (!ofs.good()) { + RCLCPP_ERROR_STREAM(logger_, "Failed to write raw file: " << raw_filename); } - if (image.isContinuous()) { - ofs.write(reinterpret_cast(image.data), image.total() * image.elemSize()); + } else if (!raw_image.empty()) { + if (raw_image.isContinuous()) { + ofs.write(reinterpret_cast(raw_image.data), + static_cast(raw_image.total() * raw_image.elemSize())); } else { - int rows = image.rows; - int cols = image.cols * image.channels(); - for (int r = 0; r < rows; ++r) { - ofs.write(reinterpret_cast(image.ptr(r)), cols); + const auto row_size = static_cast(raw_image.cols * raw_image.elemSize()); + for (int row = 0; row < raw_image.rows; ++row) { + ofs.write(reinterpret_cast(raw_image.ptr(row)), row_size); } } - ofs.close(); + if (!ofs.good()) { + RCLCPP_ERROR_STREAM(logger_, "Failed to write raw file: " << raw_filename); + } } else { - RCLCPP_ERROR_STREAM(logger_, "Unsupported stream type: " << stream_index.first); + RCLCPP_ERROR_STREAM(logger_, "Failed to save raw image: frame data and image are empty"); } + if (ofs.is_open()) { + ofs.close(); + } + + cv::Mat png_image = image_to_save.empty() ? raw_image : image_to_save; + if (png_image.empty()) { + RCLCPP_ERROR_STREAM(logger_, "Failed to save PNG image: image is empty"); + } else { + cv::Mat converted_png_image; + if (image_msg.encoding == sensor_msgs::image_encodings::RGB8 && png_image.channels() == 3) { + cv::cvtColor(png_image, converted_png_image, cv::COLOR_RGB2BGR); + png_image = converted_png_image; + } else if (image_msg.encoding == sensor_msgs::image_encodings::RGBA8 && + png_image.channels() == 4) { + cv::cvtColor(png_image, converted_png_image, cv::COLOR_RGBA2BGRA); + png_image = converted_png_image; + } + try { + if (!cv::imwrite(png_filename, png_image)) { + RCLCPP_ERROR_STREAM(logger_, "Failed to write PNG file: " << png_filename); + } + } catch (const cv::Exception &exception) { + RCLCPP_ERROR_STREAM( + logger_, "Failed to write PNG file " << png_filename << ": " << exception.what()); + } + } + + std::ofstream metadata_ofs(metadata_filename); + if (!metadata_ofs.is_open()) { + RCLCPP_ERROR_STREAM(logger_, "Failed to open metadata file: " << metadata_filename); + } else { + metadata_ofs << createFrameMetadataJson(frame) << '\n'; + if (!metadata_ofs.good()) { + RCLCPP_ERROR_STREAM(logger_, "Failed to write metadata file: " << metadata_filename); + } + metadata_ofs.close(); + } + if (++save_images_count_[stream_index] >= max_save_images_count_) { save_images_[stream_index] = false; } From 901259f129cea47a9bf83adf46e8c35b569a5165 Mon Sep 17 00:00:00 2001 From: ob-yalian Date: Wed, 19 Aug 2026 13:41:15 +0800 Subject: [PATCH 40/48] fix: support additional sample rate aliases for IMU configuration --- orbbec_camera/src/utils.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/orbbec_camera/src/utils.cpp b/orbbec_camera/src/utils.cpp index 4f4aef43..15fdd288 100644 --- a/orbbec_camera/src/utils.cpp +++ b/orbbec_camera/src/utils.cpp @@ -718,17 +718,17 @@ OB_SAMPLE_RATE sampleRateFromString(std::string &sample_rate) { return OB_SAMPLE_RATE_200_HZ; } else if (sample_rate == "500hz") { return OB_SAMPLE_RATE_500_HZ; - } else if (sample_rate == "1khz") { + } else if (sample_rate == "1khz" || sample_rate == "1000hz") { return OB_SAMPLE_RATE_1_KHZ; - } else if (sample_rate == "2khz") { + } else if (sample_rate == "2khz" || sample_rate == "2000hz") { return OB_SAMPLE_RATE_2_KHZ; - } else if (sample_rate == "4khz") { + } else if (sample_rate == "4khz" || sample_rate == "4000hz") { return OB_SAMPLE_RATE_4_KHZ; - } else if (sample_rate == "8khz") { + } else if (sample_rate == "8khz" || sample_rate == "8000hz") { return OB_SAMPLE_RATE_8_KHZ; - } else if (sample_rate == "16khz") { + } else if (sample_rate == "16khz" || sample_rate == "16000hz") { return OB_SAMPLE_RATE_16_KHZ; - } else if (sample_rate == "32khz") { + } else if (sample_rate == "32khz" || sample_rate == "32000hz") { return OB_SAMPLE_RATE_32_KHZ; } else { RCLCPP_ERROR_STREAM(rclcpp::get_logger("utils"), "Unknown OB_SAMPLE_RATE: " << sample_rate); From db4df46c0370837951a57766ebbd2005e6ae1179 Mon Sep 17 00:00:00 2001 From: slz Date: Wed, 19 Aug 2026 16:35:13 +0800 Subject: [PATCH 41/48] fix: report only enabled color queue statistics --- orbbec_camera/src/ros_service.cpp | 38 +++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/orbbec_camera/src/ros_service.cpp b/orbbec_camera/src/ros_service.cpp index 5a8a3fbf..01af1b51 100644 --- a/orbbec_camera/src/ros_service.cpp +++ b/orbbec_camera/src/ros_service.cpp @@ -477,19 +477,30 @@ void OBCameraNode::getColorQueueStatsCallback( {"max_queue_wait_ms", stats.max_queue_wait_ms}, }; }; + nlohmann::json queues; - queues["color"] = to_json(getColorQueueStats(color_frame_queue_, color_frame_queue_lock_, - color_frame_queue_stats_, - color_frame_queue_max_frames_, request->data)); - queues["left_color"] = to_json(getColorQueueStats( - left_color_frame_queue_, left_color_frame_queue_lock_, left_color_frame_queue_stats_, - left_color_frame_queue_max_frames_, request->data)); - queues["right_color"] = to_json(getColorQueueStats( - right_color_frame_queue_, right_color_frame_queue_lock_, right_color_frame_queue_stats_, - right_color_frame_queue_max_frames_, request->data)); - const uint64_t overflow_count = queues["color"]["overflow_count"].get() + - queues["left_color"]["overflow_count"].get() + - queues["right_color"]["overflow_count"].get(); + uint64_t overflow_count = 0; + if (enable_stream_[COLOR]) { + const auto stats = + getColorQueueStats(color_frame_queue_, color_frame_queue_lock_, color_frame_queue_stats_, + color_frame_queue_max_frames_, request->data); + queues["color"] = to_json(stats); + overflow_count += stats.overflow_count; + } + if (enable_stream_[COLOR_LEFT]) { + const auto stats = getColorQueueStats(left_color_frame_queue_, left_color_frame_queue_lock_, + left_color_frame_queue_stats_, + left_color_frame_queue_max_frames_, request->data); + queues["left_color"] = to_json(stats); + overflow_count += stats.overflow_count; + } + if (enable_stream_[COLOR_RIGHT]) { + const auto stats = getColorQueueStats(right_color_frame_queue_, right_color_frame_queue_lock_, + right_color_frame_queue_stats_, + right_color_frame_queue_max_frames_, request->data); + queues["right_color"] = to_json(stats); + overflow_count += stats.overflow_count; + } response->success = true; response->message = nlohmann::json{ @@ -499,6 +510,9 @@ void OBCameraNode::getColorQueueStatsCallback( {"queues", queues}, } .dump(); + if (queues.empty()) { + RCLCPP_WARN(logger_, "No enabled color streams; color queue statistics are empty"); + } } catch (const std::exception& error) { response->success = false; response->message = error.what(); From 758fe03520340254cf8e809352551f455c2e9113 Mon Sep 17 00:00:00 2001 From: ob-yalian Date: Wed, 19 Aug 2026 16:40:21 +0800 Subject: [PATCH 42/48] feat: enhance user navigation in documentation with structured guides and examples --- README.MD | 32 ++++++++++---- README_CN.MD | 72 ++++++++++---------------------- orbbec_camera/examples/README.MD | 23 ++++++---- 3 files changed, 60 insertions(+), 67 deletions(-) diff --git a/README.MD b/README.MD index 0eef390a..89b10d57 100644 --- a/README.MD +++ b/README.MD @@ -53,6 +53,27 @@ The **OrbbecSDK ROS2 Wrapper** provides seamless integration of Orbbec cameras w - For legacy **OpenNI** devices: use the **main** branch - For users in China: use the [Gitee repository](https://gitee.com/orbbecdeveloper/OrbbecSDK_ROS2) +## Start Here + +Detailed usage, parameters, and troubleshooting are maintained on the official +[OrbbecSDK ROS2 documentation site](https://orbbec.github.io/OrbbecSDK_ROS2/en/index.html). +Use the links below to go directly to the guide for your task. + +| I want to... | Go to... | +| --- | --- | +| Install the wrapper and configure device permissions | [Installation](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/2_installation/installation.html) | +| Launch a camera and view images in RViz2 | [ROS Package QuickStarts](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/3_quickstarts/quickstart.html) | +| Check device support, firmware, and the correct launch file | [Supported hardware](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/1_overview/introduction.html) | +| Configure launch parameters, topics, services, TF, or point clouds | [Application Guide](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/4_application_guide/application_guide.html) | +| Find maintenance, diagnostic, benchmark, or multi-camera tools | [Tool Index](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/6_benchmark/tools.html) | +| Use network cameras, GMSL, multi-camera, or advanced modes | [Advanced Guide](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/5_advanced_guide/advanced_guide.html) | +| Diagnose a failure or collect logs for support | [Frequently Asked Questions](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/8_FAQ/FAQ.html) | +| Migrate an existing project from main (v1.x) | [Migration Guide](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/7_developer_guide/migration_guide.html) | +| Use an Orbbec LiDAR | [LiDAR documentation](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/lidar_devices/index.html) | + +Source files for practical launch examples are listed in the +[Examples index](./orbbec_camera/examples/). + ## branch selection Here is the device support list of main branch (v1.x) and v2-main branch (v2.x): @@ -490,17 +511,10 @@ For optimal performance, we strongly recommend updating to the latest firmware v All launch files are essentially similar, with the primary difference being the default values of the parameters set for different models within the same series. Differences in USB standards, such as USB 2.0 versus USB 3.0, may require adjustments to these parameters. If you encounter a startup failure, please carefully review the specification manual. Pay special attention to the resolution settings in the launch file, as well as other parameters, to ensure compatibility and optimal performance. -## Tutorial - -please refer to the official [OrbbecSDK ROS2 documentation](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/5_advanced_guide/advanced_guide.html) - -## Examples - -To explore practical examples and gain insight into how to use the camera in ROS, please navigate to the [Examples](./orbbec_camera/examples/) section for more information. - -## Other useful links +## Related Links - [OrbbecSDK ROS2 documentation](https://orbbec.github.io/OrbbecSDK_ROS2/en/index.html) +- [Examples index](./orbbec_camera/examples/) - [OrbbecSDK_v2](https://github.com/orbbec/OrbbecSDK_v2/releases) - [Gemini 330 depth presets](https://www.orbbec.com/docs/g330-use-depth-presets/) diff --git a/README_CN.MD b/README_CN.MD index 0ae10dea..17639ac4 100644 --- a/README_CN.MD +++ b/README_CN.MD @@ -5,46 +5,6 @@

OrbbecSDK ROS2 Wrapper v2

- -

- English | 中文 -

- - - - - ROS Foxy - - - ROS Humble - - - ROS Jazzy - - - ROS Lyrical - - - ROS Rolling (experimental) - - Ubuntu 20.04 - Ubuntu 22.04 - Ubuntu 24.04 - Ubuntu 26.04 - - -
- - branch v2-main - - - license Apache-2.0 - - - Gitee mirror - - - ## 简介 OrbbecSDK ROS2 Wrapper 提供 Orbbec 相机与 ROS 2 环境的无缝集成,支持 **ROS2 Foxy、Humble、Jazzy 和 Lyrical** 发行版,并提供对 **Rolling** 的实验性支持。 @@ -53,6 +13,26 @@ OrbbecSDK ROS2 Wrapper 提供 Orbbec 相机与 ROS 2 环境的无缝集成,支 - 对于旧的 **OpenNI** 设备(v2-main 不支持),请使用 **main** 分支。 - 如果您在中国使用,建议使用 [gitee 仓库](https://gitee.com/orbbecdeveloper/OrbbecSDK_ROS2)。 +## 从这里开始 + +完整的使用方法、参数说明和故障排查统一维护在官方 +[OrbbecSDK ROS2 文档站](https://orbbec.github.io/OrbbecSDK_ROS2/zh/index.html)。 +请根据您的目标直接进入对应指南。 + +| 我想要…… | 请查看…… | +| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- | +| 安装驱动并配置设备权限 | [安装指南](https://orbbec.github.io/OrbbecSDK_ROS2/zh/source/camera_devices/2_installation/installation.html) | +| 启动相机并在 RViz2 中查看图像 | [ROS 包快速入门](https://orbbec.github.io/OrbbecSDK_ROS2/zh/source/camera_devices/3_quickstarts/quickstart.html) | +| 确认设备支持、固件版本和启动文件 | [支持的硬件](https://orbbec.github.io/OrbbecSDK_ROS2/zh/source/camera_devices/1_overview/introduction.html) | +| 配置启动参数、话题、服务、TF 或点云 | [应用指南](https://orbbec.github.io/OrbbecSDK_ROS2/zh/source/camera_devices/4_application_guide/application_guide.html) | +| 查找维护、诊断、性能测试或多相机工具 | [工具索引](https://orbbec.github.io/OrbbecSDK_ROS2/zh/source/camera_devices/6_benchmark/tools.html) | +| 使用网络相机、GMSL、多相机或高级模式 | [高级指南](https://orbbec.github.io/OrbbecSDK_ROS2/zh/source/camera_devices/5_advanced_guide/advanced_guide.html) | +| 排查故障或收集技术支持所需日志 | [常见问题](https://orbbec.github.io/OrbbecSDK_ROS2/zh/source/camera_devices/8_FAQ/FAQ.html) | +| 将现有项目从 main (v1.x) 迁移 | [迁移指南](https://orbbec.github.io/OrbbecSDK_ROS2/zh/source/camera_devices/7_developer_guide/migration_guide.html) | +| 使用 Orbbec LiDAR | [LiDAR 文档](https://orbbec.github.io/OrbbecSDK_ROS2/zh/source/lidar_devices/index.html) | + +实用启动示例的源文件可在[示例索引](./orbbec_camera/examples/)中查找。 + ## 分支选择 以下是 main 分支 (v1.x) 和 v2-main 分支 (v2.x) 的设备支持列表: @@ -301,6 +281,7 @@ git checkout v2-main cd ~/ros2_ws colcon build --event-handlers console_direct+ --cmake-args -DCMAKE_BUILD_TYPE=Release ``` + ## 注册脚本(必需) 为了让 Orbbec 相机在 Linux 上被正确识别,请安装 udev 规则。 @@ -488,17 +469,10 @@ ros2 service call /camera/get_sdk_version orbbec_camera_msgs/srv/GetString '{}' 所有启动文件基本相似,主要区别在于针对不同型号的默认参数设置。不同的 USB 标准(如 USB 2.0 和 USB 3.0)可能需要调整这些参数。如果遇到启动失败,请仔细查看规格说明书,特别是启动文件中的分辨率设置以及其他参数,以确保兼容性和最佳性能。 -## 教程 - -请参考官方 [OrbbecSDK ROS2 文档](https://orbbec.github.io/OrbbecSDK_ROS2/zh/source/camera_devices/5_advanced_guide/advanced_guide.html) - -## 示例 - -要查看更多实践示例并了解如何在 ROS 中使用相机,请参阅 [Examples](./orbbec_camera/examples/) 部分。 - -## 其他有用链接 +## 相关链接 - [OrbbecSDK ROS2 文档](https://orbbec.github.io/OrbbecSDK_ROS2/zh/index.html) +- [示例索引](./orbbec_camera/examples/) - [OrbbecSDK_v2](https://github.com/orbbec/OrbbecSDK_v2/releases) - [Gemini 330 深度预设](https://www.orbbec.com/docs/g330-use-depth-presets/) diff --git a/orbbec_camera/examples/README.MD b/orbbec_camera/examples/README.MD index 51cd7ffd..536d3d45 100644 --- a/orbbec_camera/examples/README.MD +++ b/orbbec_camera/examples/README.MD @@ -1,12 +1,17 @@ -# Sample launch for OrbbecSDK_ROS2 +# OrbbecSDK ROS2 Examples -These simple examples demonstrate how to easily use the camera with OrbbecSDK_ROS2 +This directory contains practical launch and tool examples. Full usage, +configuration, and troubleshooting are maintained on the official documentation +site so that instructions have a single source of truth. -## List of Examples: +For command-line maintenance and diagnostic utilities, see the official +[Tool Index](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/6_benchmark/tools.html). -| Name | Description | Experience Level | Document | -| :---------------------------------------------------------------------------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | ----------------------------------------------------------------------------- | -| [Net_camera](./net_camera) | How to use Net camera in OrbbecSDK_ROS2(Only Femto Mega nad Gemini 335Le) | ⭐️ | [Net_camera](https://orbbec.github.io/OrbbecSDK_ROS2/source/5_advanced_guide/configuration/net_camera.html) | -| [Gmsl_camera](./gmsl_camera) | How to use GMSL cameras (Gemini 335Lg, 338Lg, 345Lg, and 305g). | ⭐️ | [Gmsl_camera](https://orbbec.github.io/OrbbecSDK_ROS2/source/5_advanced_guide/multi_camera/gmsl_camera.html) | -| [Benchmark](./benchmark) | The goal of this tool is to benchmark the performance of various OrbbecSDK_ROS2 camera configurations. | ⭐️⭐️ | [Benchmark](https://orbbec.github.io/OrbbecSDK_ROS2/source/5_advanced_guide/performance/benchmark.html) | -| [Multi_camera_synced_verification_tool](./multi_camera_synced_verification_tool) | How to verify the synchronization accuracy of multi-camera synchronization. | ⭐️⭐️⭐️ | [Multi_camera_synced_verification_tool](https://orbbec.github.io/OrbbecSDK_ROS2/source/5_advanced_guide/multi_camera/multi_camera_synced_verification_tool.html) | +## Example Index + +| Source | Purpose | Experience Level | Official Guide | +| :---: | --- | :---: | --- | +| [Net camera](./net_camera) | Launch supported Orbbec network cameras. | ⭐️ | [Network camera guide](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/5_advanced_guide/configuration/net_camera.html) | +| [GMSL camera](./gmsl_camera) | Launch single, multiple, or synchronized GMSL cameras. | ⭐️ | [GMSL camera guide](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/5_advanced_guide/multi_camera/gmsl_camera.html) | +| [Benchmark](./benchmark) | Benchmark the performance of different camera configurations. | ⭐️⭐️ | [Performance benchmark tools](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/6_benchmark/benchmark_tools.html) | +| [Multi-camera synchronization verification](./multi_camera_synced_verification_tool) | Verify synchronization accuracy across multiple cameras. | ⭐️⭐️⭐️ | [Synchronization verification guide](https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/5_advanced_guide/multi_camera/multi_camera_synced_verification_tool.html) | From 89f7cf6da969297854a250377c81e50f9aac3cc1 Mon Sep 17 00:00:00 2001 From: ob-yalian Date: Wed, 19 Aug 2026 17:10:31 +0800 Subject: [PATCH 43/48] feat: enhance error handling and documentation links in benchmark tools --- .../scripts/common_benchmark_node.py | 27 +++++++- .../scripts/service_benchmark_node.py | 28 ++++++++- orbbec_camera/tools/firmware_update_tool.cpp | 8 ++- orbbec_camera/tools/ip_config_tool.cpp | 61 +++++++++---------- orbbec_camera/tools/list_camera_profile.cpp | 10 ++- orbbec_camera/tools/list_devices_node.cpp | 13 +++- 6 files changed, 105 insertions(+), 42 deletions(-) diff --git a/orbbec_camera/scripts/common_benchmark_node.py b/orbbec_camera/scripts/common_benchmark_node.py index 97f4e169..a012d5a6 100644 --- a/orbbec_camera/scripts/common_benchmark_node.py +++ b/orbbec_camera/scripts/common_benchmark_node.py @@ -12,6 +12,7 @@ usage: """ import argparse +import sys import rclpy from rclpy.node import Node import psutil @@ -21,11 +22,24 @@ import os from collections import defaultdict from orbbec_camera_msgs.msg import DeviceStatus from sensor_msgs.msg import Image -import sys from tabulate import tabulate CAMERA_NODE_NAMES = ["component_container", "orbbec_camera_node", "nodelet"] +DOCUMENTATION_URL = ( + "https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/" + "6_benchmark/benchmark_tools.html" +) + + +class DocumentationArgumentParser(argparse.ArgumentParser): + def error(self, message): + self.print_usage(sys.stderr) + self.exit( + 2, + f"{self.prog}: error: {message}\n" + f"For usage and troubleshooting, see: {DOCUMENTATION_URL}\n", + ) # ----------------tool functions---------------- def parse_duration(s): @@ -471,7 +485,10 @@ class CameraMonitorNode(Node): def main(argv=None): - parser = argparse.ArgumentParser() + parser = DocumentationArgumentParser( + epilog=f"Documentation: {DOCUMENTATION_URL}", + formatter_class=argparse.RawDescriptionHelpFormatter, + ) parser.add_argument("--run_time", type=str, default="10s", help="Total run time for monitoring, e.g., 10s, 5m, 1h.") parser.add_argument("--csv_file", type=str, default="camera_monitor_log.csv") parser.add_argument("--ideal_fps", type=float, default=0.0, help="Optional ideal frame rate to use for drop detection (overrides reported avg).") @@ -494,4 +511,8 @@ def main(argv=None): node.destroy_node() if __name__ == "__main__": - main() + try: + main() + except Exception: + print(f"For usage and troubleshooting, see: {DOCUMENTATION_URL}", file=sys.stderr) + raise diff --git a/orbbec_camera/scripts/service_benchmark_node.py b/orbbec_camera/scripts/service_benchmark_node.py index 3aaed950..e79dd93e 100644 --- a/orbbec_camera/scripts/service_benchmark_node.py +++ b/orbbec_camera/scripts/service_benchmark_node.py @@ -23,6 +23,23 @@ from statistics import mean from tabulate import tabulate import importlib import csv +import sys + + +DOCUMENTATION_URL = ( + "https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/" + "6_benchmark/benchmark_tools.html" +) + + +class DocumentationArgumentParser(argparse.ArgumentParser): + def error(self, message): + self.print_usage(sys.stderr) + self.exit( + 2, + f"{self.prog}: error: {message}\n" + f"For usage and troubleshooting, see: {DOCUMENTATION_URL}\n", + ) class ServiceBenchmark: @@ -180,7 +197,10 @@ class BenchmarkRunner: def main(): - parser = argparse.ArgumentParser() + parser = DocumentationArgumentParser( + epilog=f"Documentation: {DOCUMENTATION_URL}", + formatter_class=argparse.RawDescriptionHelpFormatter, + ) parser.add_argument("--service", help="Service name") parser.add_argument("--count", type=int, default=10, help="Number of calls") parser.add_argument("--yaml_file", help="YAML config file for batch testing") @@ -207,4 +227,8 @@ def main(): if __name__ == "__main__": - main() + try: + main() + except Exception: + print(f"For usage and troubleshooting, see: {DOCUMENTATION_URL}", file=sys.stderr) + raise diff --git a/orbbec_camera/tools/firmware_update_tool.cpp b/orbbec_camera/tools/firmware_update_tool.cpp index 01943fe5..3fdb97b5 100644 --- a/orbbec_camera/tools/firmware_update_tool.cpp +++ b/orbbec_camera/tools/firmware_update_tool.cpp @@ -33,6 +33,9 @@ #include "orbbec_camera/utils.h" namespace { +constexpr char kDocumentationUrl[] = + "https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/6_benchmark/" + "firmware_update_tool.html"; constexpr int kProgressLogBucketPercent = 25; constexpr int kFirmwareLogDrainDelaySec = 5; @@ -131,7 +134,9 @@ void printUsage() { << " 2) If multiple devices are connected, specify target by serial/usb/ip to avoid wrong " "updates.\n" << " 3) Repeating --serial_number or passing comma-separated values enables sequential " - "batch update.\n"; + "batch update.\n\n" + << "Documentation:\n" + << " " << kDocumentationUrl << "\n"; } bool parseArgs(int argc, char **argv, CliArgs &args, std::string &error) { @@ -862,6 +867,7 @@ int main(int argc, char **argv) { RCLCPP_ERROR(logger, "Unknown error"); } + RCLCPP_ERROR(logger, "For usage and troubleshooting, see: %s", kDocumentationUrl); rclcpp::shutdown(); return 1; } diff --git a/orbbec_camera/tools/ip_config_tool.cpp b/orbbec_camera/tools/ip_config_tool.cpp index 2a1fef60..6f36ecde 100644 --- a/orbbec_camera/tools/ip_config_tool.cpp +++ b/orbbec_camera/tools/ip_config_tool.cpp @@ -14,6 +14,9 @@ using namespace ob; namespace { constexpr int kFirmwareLogDrainDelaySec = 5; +constexpr char kDocumentationUrl[] = + "https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/6_benchmark/" + "network_config_tools.html"; void waitForFirmwareLogDrain(const rclcpp::Logger &logger) { RCLCPP_INFO(logger, "Waiting %d seconds to keep firmware log alive...", @@ -25,6 +28,12 @@ bool isSdkLogEnabled(const std::string &log_level) { return orbbec_camera::obLogSeverityFromString(log_level) != OBLogSeverity::OB_LOG_SEVERITY_OFF; } +int reportFailure(const rclcpp::Logger &logger) { + RCLCPP_ERROR(logger, "For usage and troubleshooting, see: %s", kDocumentationUrl); + rclcpp::shutdown(); + return 1; +} + } // namespace struct CliArgs { @@ -177,7 +186,9 @@ void printHelp() { << " Debug: ros2 run orbbec_camera ip_config_tool -- \\\n" << " set_ip --current_ip 192.168.1.10 --enable_dhcp true " "--enable_persistent_ip false \\\n" - << " --sdk_log_level debug\n"; + << " --sdk_log_level debug\n\n" + << "Documentation:\n" + << " " << kDocumentationUrl << "\n"; } bool parseArgs(int argc, char **argv, CliArgs &args, std::string &error) { @@ -461,18 +472,15 @@ int main(int argc, char **argv) { uint8_t gateway[4] = {0}; if (args.persistent_ip && !parseIpString(args.new_ip, address)) { RCLCPP_ERROR(logger, "Invalid new_ip format: %s", args.new_ip.c_str()); - rclcpp::shutdown(); - return 1; + return reportFailure(logger); } if (args.persistent_ip && !parseIpString(args.mask, mask)) { RCLCPP_ERROR(logger, "Invalid mask format: %s", args.mask.c_str()); - rclcpp::shutdown(); - return 1; + return reportFailure(logger); } if (args.persistent_ip && !parseIpString(args.gateway, gateway)) { RCLCPP_ERROR(logger, "Invalid gateway format: %s", args.gateway.c_str()); - rclcpp::shutdown(); - return 1; + return reportFailure(logger); } OBNetIpConfigV2 ip_config_v2{}; @@ -521,8 +529,7 @@ int main(int argc, char **argv) { "Legacy IP config (1041) supports mutually exclusive DHCP and persistent " "IP only. Use --enable_dhcp true --enable_persistent_ip false or " "--enable_dhcp false --enable_persistent_ip true."); - rclcpp::shutdown(); - return 1; + return reportFailure(logger); } ip_config.dhcp = args.dhcp ? 1 : 0; uint8_t address[4] = {0}; @@ -530,18 +537,15 @@ int main(int argc, char **argv) { uint8_t gateway[4] = {0}; if (args.persistent_ip && !parseIpString(args.new_ip, address)) { RCLCPP_ERROR(logger, "Invalid new_ip format: %s", args.new_ip.c_str()); - rclcpp::shutdown(); - return 1; + return reportFailure(logger); } if (args.persistent_ip && !parseIpString(args.mask, mask)) { RCLCPP_ERROR(logger, "Invalid mask format: %s", args.mask.c_str()); - rclcpp::shutdown(); - return 1; + return reportFailure(logger); } if (args.persistent_ip && !parseIpString(args.gateway, gateway)) { RCLCPP_ERROR(logger, "Invalid gateway format: %s", args.gateway.c_str()); - rclcpp::shutdown(); - return 1; + return reportFailure(logger); } if (args.persistent_ip) { std::memcpy(ip_config.address, address, sizeof(address)); @@ -579,18 +583,15 @@ int main(int argc, char **argv) { if (!args.dhcp) { if (!parseIpString(args.new_ip, ip_config.address)) { RCLCPP_ERROR(logger, "Invalid new_ip format: %s", args.new_ip.c_str()); - rclcpp::shutdown(); - return 1; + return reportFailure(logger); } if (!parseIpString(args.mask, ip_config.mask)) { RCLCPP_ERROR(logger, "Invalid mask format: %s", args.mask.c_str()); - rclcpp::shutdown(); - return 1; + return reportFailure(logger); } if (!parseIpString(args.gateway, ip_config.gateway)) { RCLCPP_ERROR(logger, "Invalid gateway format: %s", args.gateway.c_str()); - rclcpp::shutdown(); - return 1; + return reportFailure(logger); } } @@ -607,8 +608,7 @@ int main(int argc, char **argv) { } } else { RCLCPP_ERROR(logger, "Force-ip failed (SDK returned false)."); - rclcpp::shutdown(); - return 1; + return reportFailure(logger); } } @@ -621,16 +621,14 @@ int main(int argc, char **argv) { if (!device->isPropertySupported(OB_PROP_DHCP_ASSIGN_IP_TIMEOUT_INT, OB_PERMISSION_WRITE)) { RCLCPP_ERROR(logger, "Current device or firmware does not support DHCP assign IP timeout"); - rclcpp::shutdown(); - return 1; + return reportFailure(logger); } auto range = device->getIntPropertyRange(OB_PROP_DHCP_ASSIGN_IP_TIMEOUT_INT); if (args.dhcp_assign_ip_timeout < range.min || args.dhcp_assign_ip_timeout > range.max) { RCLCPP_ERROR(logger, "Timeout %d is out of range [%d, %d]", args.dhcp_assign_ip_timeout, range.min, range.max); - rclcpp::shutdown(); - return 1; + return reportFailure(logger); } device->setIntProperty(OB_PROP_DHCP_ASSIGN_IP_TIMEOUT_INT, args.dhcp_assign_ip_timeout); @@ -645,16 +643,13 @@ int main(int argc, char **argv) { } catch (ob::Error &e) { RCLCPP_ERROR(logger, "ip_config_tool: %s", orbbec_camera::formatObErrorWithStatus(e).c_str()); - rclcpp::shutdown(); - return 1; + return reportFailure(logger); } catch (const std::exception &e) { RCLCPP_ERROR(logger, "ip_config_tool: %s", e.what()); - rclcpp::shutdown(); - return 1; + return reportFailure(logger); } catch (...) { RCLCPP_ERROR(logger, "ip_config_tool: unknown error"); - rclcpp::shutdown(); - return 1; + return reportFailure(logger); } rclcpp::shutdown(); diff --git a/orbbec_camera/tools/list_camera_profile.cpp b/orbbec_camera/tools/list_camera_profile.cpp index 364e8825..78c03a6f 100644 --- a/orbbec_camera/tools/list_camera_profile.cpp +++ b/orbbec_camera/tools/list_camera_profile.cpp @@ -15,6 +15,9 @@ using namespace orbbec_camera; namespace { constexpr int kFirmwareLogDrainDelaySec = 5; +constexpr char kDocumentationUrl[] = + "https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/6_benchmark/" + "device_query_tools.html"; struct CliArgs { bool help = false; @@ -33,7 +36,9 @@ void printUsage() { "(default: off).\n" << " -h, --help Show this help message.\n" << "Examples:\n" - << " ros2 run orbbec_camera list_camera_profile_mode_node -- --sdk_log_level debug\n"; + << " ros2 run orbbec_camera list_camera_profile_mode_node -- --sdk_log_level debug\n\n" + << "Documentation:\n" + << " " << kDocumentationUrl << "\n"; } bool parseArgs(int argc, char** argv, CliArgs& args, std::string& error) { @@ -116,7 +121,8 @@ std::shared_ptr initializeDevice(const std::string& serial_number) { auto context = std::make_shared(); auto device_list = context->queryDeviceList(); if (!device_list || device_list->getCount() == 0) { - std::cout << "No device found" << std::endl; + std::cout << "No device found\nFor usage and troubleshooting, see: " << kDocumentationUrl + << std::endl; return nullptr; } diff --git a/orbbec_camera/tools/list_devices_node.cpp b/orbbec_camera/tools/list_devices_node.cpp index aeca24a3..6cdfcb36 100644 --- a/orbbec_camera/tools/list_devices_node.cpp +++ b/orbbec_camera/tools/list_devices_node.cpp @@ -29,6 +29,9 @@ namespace { constexpr int kFirmwareLogDrainDelaySec = 5; +constexpr char kDocumentationUrl[] = + "https://orbbec.github.io/OrbbecSDK_ROS2/en/source/camera_devices/6_benchmark/" + "device_query_tools.html"; struct CliArgs { bool help = false; @@ -42,7 +45,9 @@ void printUsage() { << " --sdk_log_level LEVEL SDK file log level: debug/info/warn/error/fatal/off " "(default: off).\n\n" << "Examples:\n" - << " ros2 run orbbec_camera list_devices_node -- --sdk_log_level debug\n"; + << " ros2 run orbbec_camera list_devices_node -- --sdk_log_level debug\n\n" + << "Documentation:\n" + << " " << kDocumentationUrl << "\n"; } bool parseArgs(int argc, char **argv, CliArgs &args, std::string &error) { @@ -339,10 +344,16 @@ int main(int argc, char **argv) { } catch (ob::Error &e) { RCLCPP_ERROR_STREAM(rclcpp::get_logger("list_device_node"), orbbec_camera::formatObErrorWithStatus(e)); + RCLCPP_ERROR_STREAM(rclcpp::get_logger("list_device_node"), + "For usage and troubleshooting, see: " << kDocumentationUrl); } catch (const std::exception &e) { RCLCPP_ERROR_STREAM(rclcpp::get_logger("list_device_node"), e.what()); + RCLCPP_ERROR_STREAM(rclcpp::get_logger("list_device_node"), + "For usage and troubleshooting, see: " << kDocumentationUrl); } catch (...) { RCLCPP_ERROR_STREAM(rclcpp::get_logger("list_device_node"), "unknown error"); + RCLCPP_ERROR_STREAM(rclcpp::get_logger("list_device_node"), + "For usage and troubleshooting, see: " << kDocumentationUrl); } return 0; } From e80760c934611917b7e081a8ba0e210b4e1a3600 Mon Sep 17 00:00:00 2001 From: slz Date: Wed, 19 Aug 2026 17:54:49 +0800 Subject: [PATCH 44/48] fix: harden color queue stats and dual-color qos --- .../launch/gemini_301_series.launch.py | 4 +++ orbbec_camera/src/ob_camera_node.cpp | 14 ++++---- orbbec_camera/src/ros_service.cpp | 33 +++++++++++-------- 3 files changed, 31 insertions(+), 20 deletions(-) mode change 100755 => 100644 orbbec_camera/src/ob_camera_node.cpp diff --git a/orbbec_camera/launch/gemini_301_series.launch.py b/orbbec_camera/launch/gemini_301_series.launch.py index 751f87cb..59ded397 100644 --- a/orbbec_camera/launch/gemini_301_series.launch.py +++ b/orbbec_camera/launch/gemini_301_series.launch.py @@ -124,6 +124,10 @@ def generate_launch_description(): DeclareLaunchArgument('color_qos', default_value='default'), DeclareLaunchArgument('color_qos_history', default_value='default'), DeclareLaunchArgument('color_qos_depth', default_value='-1'), + DeclareLaunchArgument('left_color_qos_history', default_value='default'), + DeclareLaunchArgument('left_color_qos_depth', default_value='-1'), + DeclareLaunchArgument('right_color_qos_history', default_value='default'), + DeclareLaunchArgument('right_color_qos_depth', default_value='-1'), DeclareLaunchArgument('color_camera_info_qos', default_value='default'), DeclareLaunchArgument('enable_color_auto_exposure_priority', default_value='false'), DeclareLaunchArgument('color_rotation', default_value='-1'),#color rotation degree : 0, 90, 180, 270 diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp old mode 100755 new mode 100644 index f0c67931..410000a2 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -16,7 +16,6 @@ #include "orbbec_camera/ob_camera_node.h" #include -#include #include #include #include @@ -453,7 +452,8 @@ void OBCameraNode::publishDepthFiltersStatus() { depth_filters_snapshot = depth_filter_list_; } - auto find_depth_filter = [&depth_filters_snapshot](const std::string &filter_name) -> std::shared_ptr { + auto find_depth_filter = + [&depth_filters_snapshot](const std::string &filter_name) -> std::shared_ptr { const auto normalized_name = normalizeDepthFilterName(filter_name); auto it = std::find_if(depth_filters_snapshot.begin(), depth_filters_snapshot.end(), [&normalized_name](const auto &filter) { @@ -5446,14 +5446,14 @@ void OBCameraNode::setupImagePublisher(const stream_index_pair &stream_index) { image_publishers_[stream_index] = std::make_shared(*node_, topic, image_qos_profile); } - std::string history = rmw_qos_history_policy_to_str(image_qos_profile.history); + std::string depth; if (image_qos_profile.history == RMW_QOS_POLICY_HISTORY_KEEP_LAST) { - history += "(" + std::to_string(image_qos_profile.depth) + ")"; + depth = ", depth=" + std::to_string(image_qos_profile.depth); } RCLCPP_INFO_STREAM( - logger_, topic << " QoS: " << rmw_qos_reliability_policy_to_str(image_qos_profile.reliability) - << ", " << rmw_qos_durability_policy_to_str(image_qos_profile.durability) - << ", " << history); + logger_, topic << " QoS: reliability=" << magic_enum::enum_name(image_qos_profile.reliability) + << ", durability=" << magic_enum::enum_name(image_qos_profile.durability) + << ", history=" << magic_enum::enum_name(image_qos_profile.history) << depth); if (is_mjpg_color_stream) { compressed_image_publishers_[stream_index] = diff --git a/orbbec_camera/src/ros_service.cpp b/orbbec_camera/src/ros_service.cpp index 01af1b51..0a73d234 100644 --- a/orbbec_camera/src/ros_service.cpp +++ b/orbbec_camera/src/ros_service.cpp @@ -480,33 +480,40 @@ void OBCameraNode::getColorQueueStatsCallback( nlohmann::json queues; uint64_t overflow_count = 0; - if (enable_stream_[COLOR]) { + const bool reset = request->data; + if (enable_stream_[COLOR] || reset) { const auto stats = getColorQueueStats(color_frame_queue_, color_frame_queue_lock_, color_frame_queue_stats_, - color_frame_queue_max_frames_, request->data); - queues["color"] = to_json(stats); - overflow_count += stats.overflow_count; + color_frame_queue_max_frames_, reset); + if (enable_stream_[COLOR]) { + queues["color"] = to_json(stats); + overflow_count += stats.overflow_count; + } } - if (enable_stream_[COLOR_LEFT]) { + if (enable_stream_[COLOR_LEFT] || reset) { const auto stats = getColorQueueStats(left_color_frame_queue_, left_color_frame_queue_lock_, left_color_frame_queue_stats_, - left_color_frame_queue_max_frames_, request->data); - queues["left_color"] = to_json(stats); - overflow_count += stats.overflow_count; + left_color_frame_queue_max_frames_, reset); + if (enable_stream_[COLOR_LEFT]) { + queues["left_color"] = to_json(stats); + overflow_count += stats.overflow_count; + } } - if (enable_stream_[COLOR_RIGHT]) { + if (enable_stream_[COLOR_RIGHT] || reset) { const auto stats = getColorQueueStats(right_color_frame_queue_, right_color_frame_queue_lock_, right_color_frame_queue_stats_, - right_color_frame_queue_max_frames_, request->data); - queues["right_color"] = to_json(stats); - overflow_count += stats.overflow_count; + right_color_frame_queue_max_frames_, reset); + if (enable_stream_[COLOR_RIGHT]) { + queues["right_color"] = to_json(stats); + overflow_count += stats.overflow_count; + } } response->success = true; response->message = nlohmann::json{ {"namespace", node_->get_namespace()}, {"overflow_count", overflow_count}, - {"statistics_reset", request->data}, + {"statistics_reset", reset}, {"queues", queues}, } .dump(); From 54d29f15d815d8cf6434929a92d7b437ad11cf38 Mon Sep 17 00:00:00 2001 From: ob-yalian Date: Wed, 19 Aug 2026 18:05:27 +0800 Subject: [PATCH 45/48] feat: enhance colorizeDepthImage function to accept colorizer mode parameter --- .../include/orbbec_camera/ob_camera_node.h | 2 +- orbbec_camera/src/ob_camera_node.cpp | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/orbbec_camera/include/orbbec_camera/ob_camera_node.h b/orbbec_camera/include/orbbec_camera/ob_camera_node.h index 0e1b7610..8ad62006 100644 --- a/orbbec_camera/include/orbbec_camera/ob_camera_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_camera_node.h @@ -558,7 +558,7 @@ class OBCameraNode { void publishRawDepthImage(const std::shared_ptr& depth_frame); - cv::Mat colorizeDepthImage(const cv::Mat& depth_image); + cv::Mat colorizeDepthImage(const cv::Mat& depth_image, const std::string& colorizer_mode); std::shared_ptr processDepthFrameFilter(std::shared_ptr& frame); diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index 3faa6eae..5fba339f 100755 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -5616,12 +5616,13 @@ void OBCameraNode::publishRawDepthImage(const std::shared_ptr &depth_ depth_unaligned_publisher_->publish(std::move(image_msg)); } -cv::Mat OBCameraNode::colorizeDepthImage(const cv::Mat &depth_image) { +cv::Mat OBCameraNode::colorizeDepthImage(const cv::Mat &depth_image, + const std::string &colorizer_mode) { if (depth_image.empty() || depth_image.channels() != 1) { return {}; } - if (colorizer_mode_ == "none") { + if (colorizer_mode == "none") { return {}; } @@ -5682,10 +5683,10 @@ cv::Mat OBCameraNode::colorizeDepthImage(const cv::Mat &depth_image) { cv::compare(depth_image, cv::Scalar(0), invalid_depth_mask, cv::CMP_EQ); depth_8u.setTo(cv::Scalar::all(0), invalid_depth_mask); - if (colorizer_mode_ == "gray") { + if (colorizer_mode == "gray") { return depth_8u; } - if (colorizer_mode_ == "jet_inv") { + if (colorizer_mode == "jet_inv") { depth_8u = 255 - depth_8u; depth_8u.setTo(cv::Scalar::all(0), invalid_depth_mask); } @@ -6893,7 +6894,7 @@ void OBCameraNode::onNewFrameCallback(const std::shared_ptr &frame, image = image * depth_scale; image_to_publish = image; if (colorizer_mode_ != "none" && (has_raw_image_subscriber || save_images_[stream_index])) { - auto colorized_image = colorizeDepthImage(image); + auto colorized_image = colorizeDepthImage(image, colorizer_mode_); if (!colorized_image.empty()) { image_to_publish = std::move(colorized_image); image_encoding = colorizer_mode_ == "gray" ? sensor_msgs::image_encodings::MONO8 @@ -7051,6 +7052,13 @@ void OBCameraNode::saveImageToFile(const stream_index_pair &stream_index, const } cv::Mat png_image = image_to_save.empty() ? raw_image : image_to_save; + if (stream_index == DEPTH && colorizer_mode_ == "none") { + // Keep the ROS topic raw in none mode, but save a viewable depth preview. + auto depth_preview = colorizeDepthImage(png_image, "gray"); + if (!depth_preview.empty()) { + png_image = std::move(depth_preview); + } + } if (png_image.empty()) { RCLCPP_ERROR_STREAM(logger_, "Failed to save PNG image: image is empty"); } else { From 760634fdab6c9f0c2aac90392eb437a8e6562ba8 Mon Sep 17 00:00:00 2001 From: slz Date: Thu, 20 Aug 2026 14:54:02 +0800 Subject: [PATCH 46/48] refactor: simplify image qos logging --- orbbec_camera/include/orbbec_camera/utils.h | 2 ++ orbbec_camera/src/ob_camera_node.cpp | 10 ++------- orbbec_camera/src/ros_service.cpp | 2 +- orbbec_camera/src/utils.cpp | 24 +++++++++++++++++++++ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/orbbec_camera/include/orbbec_camera/utils.h b/orbbec_camera/include/orbbec_camera/utils.h index 1f6e6c89..b74ef056 100644 --- a/orbbec_camera/include/orbbec_camera/utils.h +++ b/orbbec_camera/include/orbbec_camera/utils.h @@ -188,6 +188,8 @@ std::string ObDeviceTypeToString(const OBDeviceType& type); rmw_qos_profile_t getRMWQosProfileFromString(const std::string& str_qos); +std::string getRMWQosProfileDescription(const rmw_qos_profile_t& qos_profile); + bool isOpenNIDevice(int pid); OB_DEPTH_PRECISION_LEVEL depthPrecisionLevelFromString( diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index 410000a2..97c0dc20 100644 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -5446,14 +5446,8 @@ void OBCameraNode::setupImagePublisher(const stream_index_pair &stream_index) { image_publishers_[stream_index] = std::make_shared(*node_, topic, image_qos_profile); } - std::string depth; - if (image_qos_profile.history == RMW_QOS_POLICY_HISTORY_KEEP_LAST) { - depth = ", depth=" + std::to_string(image_qos_profile.depth); - } - RCLCPP_INFO_STREAM( - logger_, topic << " QoS: reliability=" << magic_enum::enum_name(image_qos_profile.reliability) - << ", durability=" << magic_enum::enum_name(image_qos_profile.durability) - << ", history=" << magic_enum::enum_name(image_qos_profile.history) << depth); + RCLCPP_INFO_STREAM(logger_, + topic << " QoS: " << getRMWQosProfileDescription(image_qos_profile)); if (is_mjpg_color_stream) { compressed_image_publishers_[stream_index] = diff --git a/orbbec_camera/src/ros_service.cpp b/orbbec_camera/src/ros_service.cpp index 0a73d234..0b95972f 100644 --- a/orbbec_camera/src/ros_service.cpp +++ b/orbbec_camera/src/ros_service.cpp @@ -478,7 +478,7 @@ void OBCameraNode::getColorQueueStatsCallback( }; }; - nlohmann::json queues; + nlohmann::json queues = nlohmann::json::object(); uint64_t overflow_count = 0; const bool reset = request->data; if (enable_stream_[COLOR] || reset) { diff --git a/orbbec_camera/src/utils.cpp b/orbbec_camera/src/utils.cpp index 4f4aef43..819c1f84 100644 --- a/orbbec_camera/src/utils.cpp +++ b/orbbec_camera/src/utils.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "orbbec_camera/utils.h" #include #include "orbbec_camera/constants.h" @@ -566,6 +567,29 @@ rmw_qos_profile_t getRMWQosProfileFromString(const std::string &str_qos) { } } +std::string getRMWQosProfileDescription(const rmw_qos_profile_t &qos_profile) { + const auto short_qos_name = [](auto policy) { + auto name = magic_enum::enum_name(policy); + constexpr size_t prefix_size = sizeof("RMW_QOS_POLICY_") - 1; + if (name.size() <= prefix_size) { + return name; + } + name.remove_prefix(prefix_size); + const auto separator = name.find('_'); + if (separator < name.size()) { + name.remove_prefix(separator + 1); + } + return name; + }; + + std::string history(short_qos_name(qos_profile.history)); + if (qos_profile.history == RMW_QOS_POLICY_HISTORY_KEEP_LAST) { + history += "(" + std::to_string(qos_profile.depth) + ")"; + } + return std::string(short_qos_name(qos_profile.reliability)) + "/" + + std::string(short_qos_name(qos_profile.durability)) + "/" + history; +} + bool isOpenNIDevice(int pid) { static const std::vector OPENNI_DEVICE_PIDS = { 0x0300, 0x0301, 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0407, 0x0601, 0x060b, 0x060e, From e8bd3687ae5572f8e44e515592b1db8d2fcfc5ef Mon Sep 17 00:00:00 2001 From: slz Date: Thu, 20 Aug 2026 16:35:33 +0800 Subject: [PATCH 47/48] feat: add delay before stopping streams --- orbbec_camera/src/ob_camera_node.cpp | 2 ++ orbbec_camera/src/ros_service.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index b4874abe..8e474fe5 100755 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -3746,6 +3746,8 @@ bool OBCameraNode::applyStreamProfiles(const std::vector & const bool interleave_frame_enable = interleave_frame_enable_; if (restart_pipeline) { stopStreams(); + RCLCPP_DEBUG_STREAM(logger_, "Wait 1 second for streams to stop before applying profiles"); + std::this_thread::sleep_for(std::chrono::seconds(1)); interleave_frame_enable_ = interleave_frame_enable; } stopColorFrameThreads(); diff --git a/orbbec_camera/src/ros_service.cpp b/orbbec_camera/src/ros_service.cpp index 8c4be54b..73508de6 100644 --- a/orbbec_camera/src/ros_service.cpp +++ b/orbbec_camera/src/ros_service.cpp @@ -1941,6 +1941,8 @@ bool OBCameraNode::toggleSensor(const stream_index_pair& stream_index, bool enab std::lock_guard lock(device_lock_); try { pipeline_->stop(); + RCLCPP_DEBUG_STREAM(logger_, "Wait 1 second for streams to stop before toggling sensor"); + std::this_thread::sleep_for(std::chrono::seconds(1)); enable_stream_[stream_index] = enabled; setupProfiles(); startStreams(); From ada0122f9876c134d5b1bbde16e308fc71b04ae3 Mon Sep 17 00:00:00 2001 From: ob-yalian Date: Thu, 20 Aug 2026 17:12:20 +0800 Subject: [PATCH 48/48] feat: implement thread-safe image saving with mutex and update save logic --- .../include/orbbec_camera/ob_camera_node.h | 1 + orbbec_camera/src/ob_camera_node.cpp | 26 ++++++++++++++----- orbbec_camera/src/ros_service.cpp | 3 ++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/orbbec_camera/include/orbbec_camera/ob_camera_node.h b/orbbec_camera/include/orbbec_camera/ob_camera_node.h index 8ad62006..4685b321 100644 --- a/orbbec_camera/include/orbbec_camera/ob_camera_node.h +++ b/orbbec_camera/include/orbbec_camera/ob_camera_node.h @@ -809,6 +809,7 @@ class OBCameraNode { std::unique_ptr d2c_viewer_ = nullptr; std::map save_images_; std::map save_images_count_; + std::mutex save_images_mutex_; int max_save_images_count_ = 10; std::atomic_bool save_point_cloud_{false}; std::atomic_bool save_colored_point_cloud_{false}; diff --git a/orbbec_camera/src/ob_camera_node.cpp b/orbbec_camera/src/ob_camera_node.cpp index 5fba339f..241a5e6c 100755 --- a/orbbec_camera/src/ob_camera_node.cpp +++ b/orbbec_camera/src/ob_camera_node.cpp @@ -6995,18 +6995,34 @@ void OBCameraNode::saveImageToFile(const stream_index_pair &stream_index, const const cv::Mat &image_to_save, const sensor_msgs::msg::Image &image_msg, const std::shared_ptr &frame) { - if (save_images_[stream_index]) { + if (save_images_[stream_index].load(std::memory_order_acquire)) { + int index = 0; + { + std::lock_guard lock(save_images_mutex_); + if (!save_images_[stream_index].load(std::memory_order_relaxed)) { + return; + } + index = save_images_count_[stream_index]++; + if (save_images_count_[stream_index] >= max_save_images_count_) { + save_images_[stream_index].store(false, std::memory_order_release); + } + } + auto now = std::chrono::system_clock::now(); auto in_time_t = std::chrono::system_clock::to_time_t(now); auto us = std::chrono::duration_cast(now.time_since_epoch()) % 1000000; + std::tm local_time{}; + if (localtime_r(&in_time_t, &local_time) == nullptr) { + RCLCPP_ERROR_STREAM(logger_, "Failed to convert image save timestamp to local time"); + return; + } std::stringstream ss; - ss << std::put_time(std::localtime(&in_time_t), "%Y%m%d_%H%M%S"); + ss << std::put_time(&local_time, "%Y%m%d_%H%M%S"); ss << "_" << std::setw(6) << std::setfill('0') << us.count(); const auto output_directory = std::filesystem::current_path() / "image"; auto fps = fps_[stream_index]; - const int index = save_images_count_[stream_index]; const std::string file_name = stream_name_[stream_index] + "_" + std::to_string(image_msg.width) + "x" + std::to_string(image_msg.height) + "_" + std::to_string(fps) + @@ -7091,10 +7107,6 @@ void OBCameraNode::saveImageToFile(const stream_index_pair &stream_index, const } metadata_ofs.close(); } - - if (++save_images_count_[stream_index] >= max_save_images_count_) { - save_images_[stream_index] = false; - } } } diff --git a/orbbec_camera/src/ros_service.cpp b/orbbec_camera/src/ros_service.cpp index 8c4be54b..fbb68ab7 100644 --- a/orbbec_camera/src/ros_service.cpp +++ b/orbbec_camera/src/ros_service.cpp @@ -1961,10 +1961,11 @@ void OBCameraNode::saveImageCallback(const std::shared_ptr& response) { (void)request; (void)response; + std::lock_guard lock(save_images_mutex_); for (const auto& stream_index : IMAGE_STREAMS) { if (enable_stream_[stream_index]) { - save_images_[stream_index] = true; save_images_count_[stream_index] = 0; + save_images_[stream_index].store(true, std::memory_order_release); } } }