From d80a41f34f2fe0c74fcbb40e178c5578d3c92669 Mon Sep 17 00:00:00 2001 From: Mateo de Mayo Date: Wed, 24 Jan 2024 18:09:21 -0300 Subject: [PATCH] external/vit: Update to 1.0.1 and remove unused cpp helper --- .../vit/vit_implementation_helper.hpp | 216 ------------------ src/external/vit_includes/vit/vit_interface.h | 146 +++++------- 2 files changed, 63 insertions(+), 299 deletions(-) delete mode 100644 src/external/vit_includes/vit/vit_implementation_helper.hpp diff --git a/src/external/vit_includes/vit/vit_implementation_helper.hpp b/src/external/vit_includes/vit/vit_implementation_helper.hpp deleted file mode 100644 index 015067f25..000000000 --- a/src/external/vit_includes/vit/vit_implementation_helper.hpp +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright 2023, Collabora, Ltd. -// SPDX-License-Identifier: BSL-1.0 -/*! - * @file - * @brief Visual-Intertial Tracking tracker helper. - * @author Jakob Bornecrantz - * @author Simon Zeni - */ - -#pragma once - -#include "vit_interface.h" - - -namespace vit { - -typedef vit_result_t Result; -typedef vit_image_format_t ImageFormat; -typedef vit_camera_distortion_t CameraDistortion; -typedef vit_tracker_capability_t TrackerCapability; -typedef vit_tracker_pose_capability_t TrackerPoseCapability; -typedef vit_tracker_timing_titles TrackerTimingTitles; -typedef vit_tracker_t Tracker; -typedef vit_config_t Config; -typedef vit_pose_t Pose; -typedef vit_config_t Config; -typedef vit_imu_sample_t ImuSample; -typedef vit_mask_t Mask; -typedef vit_img_sample_t ImgSample; -typedef vit_pose_data_t PoseData; -typedef vit_pose_timing_t PoseTiming; -typedef vit_pose_feature_t PoseFeature; -typedef vit_pose_features_t PoseFeatures; -typedef vit_camera_calibration_t CameraCalibration; -typedef vit_inertial_calibration_t InertialCalibration; -typedef vit_imu_calibration_t ImuCalibration; - -} // namespace vit - -extern "C" { - -struct vit_tracker -{ - virtual ~vit_tracker() = default; - - virtual vit_result_t has_image_format(const vit_image_format_t fmt, bool *out_supported) const = 0; - virtual vit_result_t get_capabilities(vit_tracker_capability_t *out_capabilities) const = 0; - virtual vit_result_t get_pose_capabilities(vit_tracker_pose_capability_t *out_capabilities) const = 0; - virtual vit_result_t set_pose_capabilities(const vit_tracker_pose_capability_t capabilities, bool value) = 0; - virtual vit_result_t start() = 0; - virtual vit_result_t stop() = 0; - virtual vit_result_t reset() = 0; - virtual vit_result_t is_running(bool *out_running) const = 0; - virtual vit_result_t add_imu_calibration(const vit_imu_calibration_t *calibration) = 0; - virtual vit_result_t add_camera_calibration(const vit_camera_calibration_t *calibration) = 0; - virtual vit_result_t push_imu_sample(const vit_imu_sample_t *sample) = 0; - virtual vit_result_t push_img_sample(const vit_img_sample_t *sample) = 0; - virtual vit_result_t pop_pose(vit_pose_t **pose) = 0; - virtual vit_result_t get_timing_titles(vit_tracker_timing_titles *out_titles) const = 0; -}; - -struct vit_pose -{ - virtual ~vit_pose() = default; - - virtual vit_result_t get_data(vit_pose_data *out_data) const = 0; - virtual vit_result_t get_timing(vit_pose_timing *out_timing) const = 0; - virtual vit_result_t get_features(uint32_t camera_index, vit_pose_features_t *out_features) const = 0; -}; - -#ifdef VIT_INTERFACE_IMPLEMENTATION - -vit_result_t -vit_api_get_version(uint32_t *out_major, uint32_t *out_minor, uint32_t *out_patch) -{ - *out_major = VIT_HEADER_VERSION_MAJOR; - *out_minor = VIT_HEADER_VERSION_MINOR; - *out_patch = VIT_HEADER_VERSION_PATCH; - return VIT_SUCCESS; -} - -void -vit_tracker_destroy(vit_tracker_t *tracker) -{ - vit::Tracker *t = static_cast(tracker); - delete t; -} - -vit_result_t -vit_tracker_has_image_format(const vit_tracker_t *tracker, const vit_image_format_t image_format, bool *out_supported) -{ - const vit::Tracker *t = static_cast(tracker); - return t->has_image_format(image_format, out_supported); -} - -vit_result_t -vit_tracker_get_capabilities(const vit_tracker_t *tracker, vit_tracker_capability_t *out_caps) -{ - const vit::Tracker *t = static_cast(tracker); - return t->get_capabilities(out_caps); -} - -vit_result_t -vit_tracker_get_pose_capabilities(const vit_tracker_t *tracker, vit_tracker_pose_capability_t *out_caps) -{ - const vit::Tracker *t = static_cast(tracker); - return t->get_pose_capabilities(out_caps); -} - -vit_result_t -vit_tracker_set_pose_capabilities(vit_tracker_t *tracker, vit_tracker_pose_capability_t caps, bool value) -{ - vit::Tracker *t = static_cast(tracker); - return t->set_pose_capabilities(caps, value); -} - -vit_result_t -vit_tracker_start(vit_tracker_t *tracker) -{ - vit::Tracker *t = static_cast(tracker); - return t->start(); -} - -vit_result_t -vit_tracker_stop(vit_tracker_t *tracker) -{ - vit::Tracker *t = static_cast(tracker); - return t->stop(); -} - -vit_result_t -vit_tracker_reset(vit_tracker_t *tracker) -{ - vit::Tracker *t = static_cast(tracker); - return t->reset(); -} - -vit_result_t -vit_tracker_is_running(const vit_tracker *tracker, bool *out_running) -{ - const vit::Tracker *t = static_cast(tracker); - return t->is_running(out_running); -} - -vit_result_t -vit_tracker_push_imu_sample(vit_tracker *tracker, const vit_imu_sample_t *sample) -{ - vit::Tracker *t = static_cast(tracker); - return t->push_imu_sample(sample); -} - -vit_result_t -vit_tracker_push_img_sample(vit_tracker *tracker, const vit_img_sample_t *sample) -{ - vit::Tracker *t = static_cast(tracker); - return t->push_img_sample(sample); -} - -vit_result_t -vit_tracker_add_imu_calibration(vit_tracker_t *tracker, const vit_imu_calibration_t *calibration) -{ - vit::Tracker *t = static_cast(tracker); - return t->add_imu_calibration(calibration); -} - -vit_result_t -vit_tracker_add_camera_calibration(vit_tracker_t *tracker, const vit_camera_calibration_t *calibration) -{ - vit::Tracker *t = static_cast(tracker); - return t->add_camera_calibration(calibration); -} - -vit_result_t -vit_tracker_pop_pose(vit_tracker_t *tracker, vit_pose_t **out_pose) -{ - vit::Tracker *t = static_cast(tracker); - return t->pop_pose(out_pose); -} - -vit_result_t -vit_tracker_get_timing_titles(const vit_tracker_t *tracker, vit_tracker_timing_titles *out_titles) -{ - const vit::Tracker *t = static_cast(tracker); - return t->get_timing_titles(out_titles); -} - -void -vit_pose_destroy(vit_pose_t *pose) -{ - vit::Pose *p = static_cast(pose); - delete p; -} - -vit_result_t -vit_pose_get_data(const vit_pose_t *pose, vit_pose_data_t *out_data) -{ - const vit::Pose *p = static_cast(pose); - return p->get_data(out_data); -} - -vit_result_t -vit_pose_get_timing(const vit_pose_t *pose, vit_pose_timing_t *out_timing) -{ - const vit::Pose *p = static_cast(pose); - return p->get_timing(out_timing); -} - -vit_result_t -vit_pose_get_features(const vit_pose_t *pose, uint32_t camera_index, vit_pose_features_t *out_features) -{ - const vit::Pose *p = static_cast(pose); - return p->get_features(camera_index, out_features); -} - -#endif -} diff --git a/src/external/vit_includes/vit/vit_interface.h b/src/external/vit_includes/vit/vit_interface.h index 5af15728b..f4777affa 100644 --- a/src/external/vit_includes/vit/vit_interface.h +++ b/src/external/vit_includes/vit/vit_interface.h @@ -1,4 +1,4 @@ -// Copyright 2023, Collabora, Ltd. +// Copyright 2023-2024, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -8,10 +8,10 @@ * @author Jakob Bornecrantz * * This file contains the declaration of the @ref vit_tracker struct. This - * header is intended to appear in both Monado and external SLAM systems. The - * implementation of `vit_interface` is provided by the external system. - * Additional data types are declared for the communication between Monado and - * the system. + * header is intended to appear in both consumers (e.g., Monado) and external + * visual-inertial tracking (VIT) systems (e.g., Basalt). The implementation of + * `vit_interface` is provided by the external system. Additional data types are + * declared for the communication between consumers and the system. */ #pragma once @@ -20,22 +20,22 @@ extern "C" { #endif -#include #include +#include -// For implementation: same as IMPLEMENTATION_VERSION_* -// For user: expected IMPLEMENTATION_VERSION_*. Should be checked in runtime. +//! Compatibility with these values should be checked against @ref vit_api_get_version. #define VIT_HEADER_VERSION_MAJOR 1 //!< API Breakages #define VIT_HEADER_VERSION_MINOR 0 //!< Backwards compatible API changes -#define VIT_HEADER_VERSION_PATCH 0 //!< Backw. comp. .h-implemented changes +#define VIT_HEADER_VERSION_PATCH 1 //!< Backw. comp. .h-implemented changes + +#define VIT_CAMERA_CALIBRATION_DISTORTION_MAX_COUNT 32 /*! * Result type used by the VIT system * * 0 is @ref VIT_SUCCESS, positive values are non fatal results and negative values are errors. */ -typedef enum vit_result -{ +typedef enum vit_result { /*! * Operation suceeded */ @@ -70,8 +70,7 @@ typedef enum vit_result /*! * Image formats. */ -typedef enum vit_image_format -{ +typedef enum vit_image_format { //! 8-bit luminance VIT_IMAGE_FORMAT_L8 = 1, //! 16-bit luminance @@ -83,8 +82,7 @@ typedef enum vit_image_format /*! * Camera calibration types. */ -typedef enum vit_camera_distortion -{ +typedef enum vit_camera_distortion { //! No distortion (pre-disotorted). VIT_CAMERA_DISTORTION_NONE, //! Distortion radial-tangential (OpenCV), 4 parameters. @@ -100,8 +98,7 @@ typedef enum vit_camera_distortion /*! * Capabilities of the tracker. */ -typedef enum vit_tracker_capability -{ +typedef enum vit_tracker_capability { //! Does the tracker support per pose (frame) timing data. VIT_TRACKER_CAPABILITY_CAMERA_CALIBRATION = 1 << 0, //! Does the tracker support per pose (frame) and per camera features. @@ -111,8 +108,7 @@ typedef enum vit_tracker_capability /*! * Capabilities of the poses that this tracker produces. */ -typedef enum vit_tracker_pose_capability -{ +typedef enum vit_tracker_pose_capability { //! Does the tracker support per pose (frame) timing data. VIT_TRACKER_POSE_CAPABILITY_TIMING = 1 << 0, //! Does the tracker support per pose (frame) and per camera features. @@ -134,9 +130,8 @@ typedef struct vit_pose vit_pose_t; /*! * @brief Names of the timestamps returned by `vit_pose_get_timings` */ -typedef struct vit_tracker_timing_titles -{ - uint32_t count; //! Number of titles +typedef struct vit_tracker_timing_titles { + uint32_t count; //! Number of titles const char **titles; //! Names of the measures timestamps } vit_tracker_timing_titles; @@ -174,8 +169,7 @@ typedef struct vit_imu_sample { /*! * Region in image space that this mask covers. */ -typedef struct vit_mask -{ +typedef struct vit_mask { //! In pixels. float x, y, w, h; } vit_mask_t; @@ -253,21 +247,21 @@ typedef struct vit_pose_features { typedef struct vit_camera_calibration { uint32_t camera_index; // 1 cameras, the N frames must be pushed following @ref cam_index order. * The bundle of N frames must have the same timestamps. */ -vit_result_t -vit_tracker_push_img_sample(vit_tracker_t *tracker, const vit_img_sample_t *sample); +vit_result_t vit_tracker_push_img_sample(vit_tracker_t *tracker, const vit_img_sample_t *sample); /*! * @brief Adds an inertial measurement unit calibration to the tracker. The tracker must not be started. @@ -441,8 +429,7 @@ vit_tracker_push_img_sample(vit_tracker_t *tracker, const vit_img_sample_t *samp * @see vit_tracker_get_capabilities * @see vit_tracker_capability_t */ -vit_result_t -vit_tracker_add_imu_calibration(vit_tracker_t *tracker, const vit_imu_calibration_t *calibration); +vit_result_t vit_tracker_add_imu_calibration(vit_tracker_t *tracker, const vit_imu_calibration_t *calibration); /*! * @brief Adds a camera calibration to the tracker. The tracker must not be started. @@ -452,8 +439,7 @@ vit_tracker_add_imu_calibration(vit_tracker_t *tracker, const vit_imu_calibratio * @see vit_tracker_get_capabilities * @see vit_tracker_capability_t */ -vit_result_t -vit_tracker_add_camera_calibration(vit_tracker_t *tracker, const vit_camera_calibration_t *calibration); +vit_result_t vit_tracker_add_camera_calibration(vit_tracker_t *tracker, const vit_camera_calibration_t *calibration); /*! * @brief Get the pose from the front of the tracking queue from the VIT tracker @@ -464,46 +450,40 @@ vit_tracker_add_camera_calibration(vit_tracker_t *tracker, const vit_camera_cali * * @param[out] out_pose Pose returned to the caller, NULL if there is not pose available or on error. */ -vit_result_t -vit_tracker_pop_pose(vit_tracker_t *tracker, vit_pose_t **out_pose); +vit_result_t vit_tracker_pop_pose(vit_tracker_t *tracker, vit_pose_t **out_pose); /*! * @brief Get the titles of the timestamps measured by the pose timings. * * Returns `VIT_ERROR_NOT_SUPPORTED` if the tracker doesn't offer the pose timing capability. */ -vit_result_t -vit_tracker_get_timing_titles(const vit_tracker_t *tracker, vit_tracker_timing_titles *out_titles); +vit_result_t vit_tracker_get_timing_titles(const vit_tracker_t *tracker, vit_tracker_timing_titles *out_titles); /*! * @brief Destroys a pose. All of the data, timing and features associated to it will be invalidated. */ -void -vit_pose_destroy(vit_pose_t *pose); +void vit_pose_destroy(vit_pose_t *pose); /*! * @brief Gets the data form a given `vit_pose_t`. * * The data becomes invalid when the associated pose gets destroyed. */ -vit_result_t -vit_pose_get_data(const vit_pose_t *pose, vit_pose_data_t *out_data); +vit_result_t vit_pose_get_data(const vit_pose_t *pose, vit_pose_data_t *out_data); /*! * @brief Gets the timing form a given `vit_pose_t`. * * The timing data becomes invalid when the associated pose gets destroyed. */ -vit_result_t -vit_pose_get_timing(const vit_pose_t *pose, vit_pose_timing_t *out_timing); +vit_result_t vit_pose_get_timing(const vit_pose_t *pose, vit_pose_timing_t *out_timing); /*! * @brief Gets the features form a given `vit_pose_t`. * * The features data becomes invalid when the associated pose gets destroyed. */ -vit_result_t -vit_pose_get_features(const vit_pose_t *pose, uint32_t camera_index, vit_pose_features_t *out_features); +vit_result_t vit_pose_get_features(const vit_pose_t *pose, uint32_t camera_index, vit_pose_features_t *out_features); #endif