From 09d7aac89e2b11f9991c86c5fb563c5d0265ce96 Mon Sep 17 00:00:00 2001 From: Mateo de Mayo Date: Fri, 10 Feb 2023 16:42:13 -0300 Subject: [PATCH] external/slam: Update interface to support multiple cameras --- src/external/slam_tracker/slam_tracker.hpp | 17 ++++++++++------- src/xrt/auxiliary/tracking/t_tracker_slam.cpp | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/external/slam_tracker/slam_tracker.hpp b/src/external/slam_tracker/slam_tracker.hpp index 0b58d7c27..10b7951f8 100644 --- a/src/external/slam_tracker/slam_tracker.hpp +++ b/src/external/slam_tracker/slam_tracker.hpp @@ -29,7 +29,7 @@ namespace xrt::auxiliary::tracking::slam { // For implementation: same as IMPLEMENTATION_VERSION_* // For user: expected IMPLEMENTATION_VERSION_*. Should be checked in runtime. -constexpr int HEADER_VERSION_MAJOR = 5; //!< API Breakages +constexpr int HEADER_VERSION_MAJOR = 6; //!< API Breakages constexpr int HEADER_VERSION_MINOR = 0; //!< Backwards compatible API changes constexpr int HEADER_VERSION_PATCH = 0; //!< Backw. comp. .h-implemented changes @@ -81,10 +81,10 @@ struct imu_sample { struct img_sample { std::int64_t timestamp; cv::Mat img; - bool is_left; + int cam_index; img_sample() = default; - img_sample(std::int64_t timestamp, const cv::Mat &img, bool is_left) - : timestamp(timestamp), img(img), is_left(is_left) {} + img_sample(std::int64_t timestamp, const cv::Mat &img, int cam_index) + : timestamp(timestamp), img(img), cam_index(cam_index) {} }; /*! @@ -94,8 +94,11 @@ struct slam_config { //! Path to a implementation-specific config file. If null, use defaults. std::shared_ptr config_file; + //! Number of cameras to use. Required. + int cam_count = -1; + //! If supported, whether to open the system's UI. - bool show_ui; + bool show_ui = false; }; /*! @@ -132,8 +135,8 @@ struct slam_tracker { * @brief Push an image sample into the tracker. * * Same conditions as @ref push_imu_sample apply. - * When using stereo frames, they must be pushed in a left-right order. - * The consecutive left-right pair must have the same timestamps. + * When using N>1 cameras, the N frames must be pushed following cam_id order. + * The bundle of N frames must have the same timestamps. */ void push_frame(const img_sample &sample); diff --git a/src/xrt/auxiliary/tracking/t_tracker_slam.cpp b/src/xrt/auxiliary/tracking/t_tracker_slam.cpp index 43f6fe856..201d24a36 100644 --- a/src/xrt/auxiliary/tracking/t_tracker_slam.cpp +++ b/src/xrt/auxiliary/tracking/t_tracker_slam.cpp @@ -1357,6 +1357,7 @@ t_slam_create(struct xrt_frame_context *xfctx, slam_config system_config = {}; system_config.config_file = config_file ? make_shared(config_file) : nullptr; + system_config.cam_count = NUM_CAMS; system_config.show_ui = config->slam_ui; t.slam = new slam_tracker{system_config};