external/slam: Update interface to support multiple cameras

This commit is contained in:
Mateo de Mayo 2023-02-10 16:42:13 -03:00 committed by Jakob Bornecrantz
parent 52cac31d3a
commit 09d7aac89e
2 changed files with 11 additions and 7 deletions

View file

@ -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<std::string> 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);

View file

@ -1357,6 +1357,7 @@ t_slam_create(struct xrt_frame_context *xfctx,
slam_config system_config = {};
system_config.config_file = config_file ? make_shared<string>(config_file) : nullptr;
system_config.cam_count = NUM_CAMS;
system_config.show_ui = config->slam_ui;
t.slam = new slam_tracker{system_config};