The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

external: introduce visual-inertial tracking interface header

Co-authored-by: Jakob Bornecrantz <jakob@collabora.com>

+733
+5
src/external/CMakeLists.txt
··· 89 89 ) 90 90 target_include_directories(xrt-external-slam SYSTEM INTERFACE ${SLAM_INCLUDE_DIRS}) 91 91 target_link_libraries(xrt-external-slam INTERFACE ${SLAM_LDFLAGS}) 92 + 93 + add_library(xrt-external-vit INTERFACE) 94 + target_include_directories( 95 + xrt-external-vit INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/vit_includes 96 + ) 92 97 endif() 93 98 94 99 # SDL
+216
src/external/vit_includes/vit/vit_implementation_helper.hpp
··· 1 + // Copyright 2023, Collabora, Ltd. 2 + // SPDX-License-Identifier: BSL-1.0 3 + /*! 4 + * @file 5 + * @brief Visual-Intertial Tracking tracker helper. 6 + * @author Jakob Bornecrantz <jakob@collabora.com> 7 + * @author Simon Zeni <simon.zeni@collabora.com> 8 + */ 9 + 10 + #pragma once 11 + 12 + #include "vit_interface.h" 13 + 14 + 15 + namespace vit { 16 + 17 + typedef vit_result_t Result; 18 + typedef vit_image_format_t ImageFormat; 19 + typedef vit_camera_distortion_t CameraDistortion; 20 + typedef vit_tracker_capability_t TrackerCapability; 21 + typedef vit_tracker_pose_capability_t TrackerPoseCapability; 22 + typedef vit_tracker_timing_titles TrackerTimingTitles; 23 + typedef vit_tracker_t Tracker; 24 + typedef vit_config_t Config; 25 + typedef vit_pose_t Pose; 26 + typedef vit_config_t Config; 27 + typedef vit_imu_sample_t ImuSample; 28 + typedef vit_mask_t Mask; 29 + typedef vit_img_sample_t ImgSample; 30 + typedef vit_pose_data_t PoseData; 31 + typedef vit_pose_timing_t PoseTiming; 32 + typedef vit_pose_feature_t PoseFeature; 33 + typedef vit_pose_features_t PoseFeatures; 34 + typedef vit_camera_calibration_t CameraCalibration; 35 + typedef vit_inertial_calibration_t InertialCalibration; 36 + typedef vit_imu_calibration_t ImuCalibration; 37 + 38 + } // namespace vit 39 + 40 + extern "C" { 41 + 42 + struct vit_tracker 43 + { 44 + virtual ~vit_tracker() = default; 45 + 46 + virtual vit_result_t has_image_format(const vit_image_format_t fmt, bool *out_supported) const = 0; 47 + virtual vit_result_t get_capabilities(vit_tracker_capability_t *out_capabilities) const = 0; 48 + virtual vit_result_t get_pose_capabilities(vit_tracker_pose_capability_t *out_capabilities) const = 0; 49 + virtual vit_result_t set_pose_capabilities(const vit_tracker_pose_capability_t capabilities, bool value) = 0; 50 + virtual vit_result_t start() = 0; 51 + virtual vit_result_t stop() = 0; 52 + virtual vit_result_t reset() = 0; 53 + virtual vit_result_t is_running(bool *out_running) const = 0; 54 + virtual vit_result_t add_imu_calibration(const vit_imu_calibration_t *calibration) = 0; 55 + virtual vit_result_t add_camera_calibration(const vit_camera_calibration_t *calibration) = 0; 56 + virtual vit_result_t push_imu_sample(const vit_imu_sample_t *sample) = 0; 57 + virtual vit_result_t push_img_sample(const vit_img_sample_t *sample) = 0; 58 + virtual vit_result_t pop_pose(vit_pose_t **pose) = 0; 59 + virtual vit_result_t get_timing_titles(vit_tracker_timing_titles *out_titles) const = 0; 60 + }; 61 + 62 + struct vit_pose 63 + { 64 + virtual ~vit_pose() = default; 65 + 66 + virtual vit_result_t get_data(vit_pose_data *out_data) const = 0; 67 + virtual vit_result_t get_timing(vit_pose_timing *out_timing) const = 0; 68 + virtual vit_result_t get_features(uint32_t camera_index, vit_pose_features_t *out_features) const = 0; 69 + }; 70 + 71 + #ifdef VIT_INTERFACE_IMPLEMENTATION 72 + 73 + vit_result_t 74 + vit_api_get_version(uint32_t *out_major, uint32_t *out_minor, uint32_t *out_patch) 75 + { 76 + *out_major = VIT_HEADER_VERSION_MAJOR; 77 + *out_minor = VIT_HEADER_VERSION_MINOR; 78 + *out_patch = VIT_HEADER_VERSION_PATCH; 79 + return VIT_SUCCESS; 80 + } 81 + 82 + void 83 + vit_tracker_destroy(vit_tracker_t *tracker) 84 + { 85 + vit::Tracker *t = static_cast<vit::Tracker *>(tracker); 86 + delete t; 87 + } 88 + 89 + vit_result_t 90 + vit_tracker_has_image_format(const vit_tracker_t *tracker, const vit_image_format_t image_format, bool *out_supported) 91 + { 92 + const vit::Tracker *t = static_cast<const vit::Tracker *>(tracker); 93 + return t->has_image_format(image_format, out_supported); 94 + } 95 + 96 + vit_result_t 97 + vit_tracker_get_capabilities(const vit_tracker_t *tracker, vit_tracker_capability_t *out_caps) 98 + { 99 + const vit::Tracker *t = static_cast<const vit::Tracker *>(tracker); 100 + return t->get_capabilities(out_caps); 101 + } 102 + 103 + vit_result_t 104 + vit_tracker_get_pose_capabilities(const vit_tracker_t *tracker, vit_tracker_pose_capability_t *out_caps) 105 + { 106 + const vit::Tracker *t = static_cast<const vit::Tracker *>(tracker); 107 + return t->get_pose_capabilities(out_caps); 108 + } 109 + 110 + vit_result_t 111 + vit_tracker_set_pose_capabilities(vit_tracker_t *tracker, vit_tracker_pose_capability_t caps, bool value) 112 + { 113 + vit::Tracker *t = static_cast<vit::Tracker *>(tracker); 114 + return t->set_pose_capabilities(caps, value); 115 + } 116 + 117 + vit_result_t 118 + vit_tracker_start(vit_tracker_t *tracker) 119 + { 120 + vit::Tracker *t = static_cast<vit::Tracker *>(tracker); 121 + return t->start(); 122 + } 123 + 124 + vit_result_t 125 + vit_tracker_stop(vit_tracker_t *tracker) 126 + { 127 + vit::Tracker *t = static_cast<vit::Tracker *>(tracker); 128 + return t->stop(); 129 + } 130 + 131 + vit_result_t 132 + vit_tracker_reset(vit_tracker_t *tracker) 133 + { 134 + vit::Tracker *t = static_cast<vit::Tracker *>(tracker); 135 + return t->reset(); 136 + } 137 + 138 + vit_result_t 139 + vit_tracker_is_running(const vit_tracker *tracker, bool *out_running) 140 + { 141 + const vit::Tracker *t = static_cast<const vit::Tracker *>(tracker); 142 + return t->is_running(out_running); 143 + } 144 + 145 + vit_result_t 146 + vit_tracker_push_imu_sample(vit_tracker *tracker, const vit_imu_sample_t *sample) 147 + { 148 + vit::Tracker *t = static_cast<vit::Tracker *>(tracker); 149 + return t->push_imu_sample(sample); 150 + } 151 + 152 + vit_result_t 153 + vit_tracker_push_img_sample(vit_tracker *tracker, const vit_img_sample_t *sample) 154 + { 155 + vit::Tracker *t = static_cast<vit::Tracker *>(tracker); 156 + return t->push_img_sample(sample); 157 + } 158 + 159 + vit_result_t 160 + vit_tracker_add_imu_calibration(vit_tracker_t *tracker, const vit_imu_calibration_t *calibration) 161 + { 162 + vit::Tracker *t = static_cast<vit::Tracker *>(tracker); 163 + return t->add_imu_calibration(calibration); 164 + } 165 + 166 + vit_result_t 167 + vit_tracker_add_camera_calibration(vit_tracker_t *tracker, const vit_camera_calibration_t *calibration) 168 + { 169 + vit::Tracker *t = static_cast<vit::Tracker *>(tracker); 170 + return t->add_camera_calibration(calibration); 171 + } 172 + 173 + vit_result_t 174 + vit_tracker_pop_pose(vit_tracker_t *tracker, vit_pose_t **out_pose) 175 + { 176 + vit::Tracker *t = static_cast<vit::Tracker *>(tracker); 177 + return t->pop_pose(out_pose); 178 + } 179 + 180 + vit_result_t 181 + vit_tracker_get_timing_titles(const vit_tracker_t *tracker, vit_tracker_timing_titles *out_titles) 182 + { 183 + const vit::Tracker *t = static_cast<const vit::Tracker *>(tracker); 184 + return t->get_timing_titles(out_titles); 185 + } 186 + 187 + void 188 + vit_pose_destroy(vit_pose_t *pose) 189 + { 190 + vit::Pose *p = static_cast<vit::Pose *>(pose); 191 + delete p; 192 + } 193 + 194 + vit_result_t 195 + vit_pose_get_data(const vit_pose_t *pose, vit_pose_data_t *out_data) 196 + { 197 + const vit::Pose *p = static_cast<const vit::Pose *>(pose); 198 + return p->get_data(out_data); 199 + } 200 + 201 + vit_result_t 202 + vit_pose_get_timing(const vit_pose_t *pose, vit_pose_timing_t *out_timing) 203 + { 204 + const vit::Pose *p = static_cast<const vit::Pose *>(pose); 205 + return p->get_timing(out_timing); 206 + } 207 + 208 + vit_result_t 209 + vit_pose_get_features(const vit_pose_t *pose, uint32_t camera_index, vit_pose_features_t *out_features) 210 + { 211 + const vit::Pose *p = static_cast<const vit::Pose *>(pose); 212 + return p->get_features(camera_index, out_features); 213 + } 214 + 215 + #endif 216 + }
+512
src/external/vit_includes/vit/vit_interface.h
··· 1 + // Copyright 2023, Collabora, Ltd. 2 + // SPDX-License-Identifier: BSL-1.0 3 + /*! 4 + * @file 5 + * @brief Visual-Intertial Tracking interface header. 6 + * @author Mateo de Mayo <mateo.demayo@collabora.com> 7 + * @author Simon Zeni <simon.zeni@collabora.com> 8 + * @author Jakob Bornecrantz <jakob@collabora.com> 9 + * 10 + * This file contains the declaration of the @ref vit_tracker struct. This 11 + * header is intended to appear in both Monado and external SLAM systems. The 12 + * implementation of `vit_interface` is provided by the external system. 13 + * Additional data types are declared for the communication between Monado and 14 + * the system. 15 + */ 16 + 17 + #pragma once 18 + 19 + #if defined(__cplusplus) 20 + extern "C" { 21 + #endif 22 + 23 + #include <stdint.h> 24 + #include <stdbool.h> 25 + 26 + // For implementation: same as IMPLEMENTATION_VERSION_* 27 + // For user: expected IMPLEMENTATION_VERSION_*. Should be checked in runtime. 28 + #define VIT_HEADER_VERSION_MAJOR 1 //!< API Breakages 29 + #define VIT_HEADER_VERSION_MINOR 0 //!< Backwards compatible API changes 30 + #define VIT_HEADER_VERSION_PATCH 0 //!< Backw. comp. .h-implemented changes 31 + 32 + /*! 33 + * Result type used by the VIT system 34 + * 35 + * 0 is @ref VIT_SUCCESS, positive values are non fatal results and negative values are errors. 36 + */ 37 + typedef enum vit_result 38 + { 39 + /*! 40 + * Operation suceeded 41 + */ 42 + VIT_SUCCESS = 0, 43 + 44 + /*! 45 + * The operation is not available on the current version 46 + */ 47 + VIT_ERROR_INVALID_VERSION = -1, 48 + 49 + /*! 50 + * The operation received an invalid value. 51 + */ 52 + VIT_ERROR_INVALID_VALUE = -2, 53 + 54 + /*! 55 + * The operation was not able to allocate memory to pursue the operation. 56 + */ 57 + VIT_ERROR_ALLOCATION_FAILURE = -3, 58 + 59 + /*! 60 + * The operation requires a capability that is not supported. 61 + */ 62 + VIT_ERROR_NOT_SUPPORTED = -4, 63 + 64 + /*! 65 + * The operation requires a capability that is not enabled. 66 + */ 67 + VIT_ERROR_NOT_ENABLED = -5, 68 + } vit_result_t; 69 + 70 + /*! 71 + * Image formats. 72 + */ 73 + typedef enum vit_image_format 74 + { 75 + //! 8-bit luminance 76 + VIT_IMAGE_FORMAT_L8 = 1, 77 + //! 16-bit luminance 78 + VIT_IMAGE_FORMAT_L16 = 2, 79 + //! 24-bit rgb, tightly packed. 80 + VIT_IMAGE_FORMAT_R8G8B8 = 3, 81 + } vit_image_format_t; 82 + 83 + /*! 84 + * Camera calibration types. 85 + */ 86 + typedef enum vit_camera_distortion 87 + { 88 + //! No distortion (pre-disotorted). 89 + VIT_CAMERA_DISTORTION_NONE, 90 + //! Distortion radial-tangential (OpenCV), 4 parameters. 91 + VIT_CAMERA_DISTORTION_RT4, 92 + //! Distortion radial-tangential (OpenCV), 5 parameters. 93 + VIT_CAMERA_DISTORTION_RT5, 94 + //! Distortion radial-tangential (OpenCV), 8 parameters. 95 + VIT_CAMERA_DISTORTION_RT8, 96 + //! Distortion Kannala-Brandt (OpenCV fisheye), 4 parameters. 97 + VIT_CAMERA_DISTORTION_KB4, 98 + } vit_camera_distortion_t; 99 + 100 + /*! 101 + * Capabilities of the tracker. 102 + */ 103 + typedef enum vit_tracker_capability 104 + { 105 + //! Does the tracker support per pose (frame) timing data. 106 + VIT_TRACKER_CAPABILITY_CAMERA_CALIBRATION = 1 << 0, 107 + //! Does the tracker support per pose (frame) and per camera features. 108 + VIT_TRACKER_CAPABILITY_IMU_CALIBRATION = 1 << 1, 109 + } vit_tracker_capability_t; 110 + 111 + /*! 112 + * Capabilities of the poses that this tracker produces. 113 + */ 114 + typedef enum vit_tracker_pose_capability 115 + { 116 + //! Does the tracker support per pose (frame) timing data. 117 + VIT_TRACKER_POSE_CAPABILITY_TIMING = 1 << 0, 118 + //! Does the tracker support per pose (frame) and per camera features. 119 + VIT_TRACKER_POSE_CAPABILITY_FEATURES = 1 << 1, 120 + } vit_tracker_pose_capability_t; 121 + 122 + /*! 123 + * @brief Visual-Inertial Tracking interface, opaque type. 124 + */ 125 + struct vit_tracker; 126 + typedef struct vit_tracker vit_tracker_t; 127 + 128 + /*! 129 + * @brief Pose interface, opaque type. 130 + */ 131 + struct vit_pose; 132 + typedef struct vit_pose vit_pose_t; 133 + 134 + /*! 135 + * @brief Names of the timestamps returned by `vit_pose_get_timings` 136 + */ 137 + typedef struct vit_tracker_timing_titles 138 + { 139 + uint32_t count; //! Number of titles 140 + const char **titles; //! Names of the measures timestamps 141 + } vit_tracker_timing_titles; 142 + 143 + /*! 144 + * @brief Parameters for creating the system pipeline. 145 + */ 146 + typedef struct vit_config { 147 + //! Path to a implementation-specific config file. If null, use defaults. 148 + const char *file; 149 + 150 + //! Number of cameras to use. Required. 151 + uint32_t cam_count; 152 + 153 + //! Number of IMU to use. Required. 154 + uint32_t imu_count; 155 + 156 + //! If supported, whether to open the system's UI. 157 + bool show_ui; 158 + } vit_config_t; 159 + 160 + /*! 161 + * @brief IMU sample type feed into VIT tracker 162 + */ 163 + typedef struct vit_imu_sample { 164 + //! In nanoseconds 165 + int64_t timestamp; 166 + 167 + //! Acceleration in meters per second squared (m/s²) 168 + float ax, ay, az; 169 + 170 + //! Gyro in radians per second (rad/s) 171 + float wx, wy, wz; 172 + } vit_imu_sample_t; 173 + 174 + /*! 175 + * Region in image space that this mask covers. 176 + */ 177 + typedef struct vit_mask 178 + { 179 + //! In pixels. 180 + float x, y, w, h; 181 + } vit_mask_t; 182 + 183 + /*! 184 + * @brief Image sample type feed into VIT tracker 185 + * 186 + * Can easily be converted into an OpenCV Matrix for processing. 187 + */ 188 + typedef struct vit_img_sample { 189 + uint32_t cam_index; 190 + 191 + //! In nanoseconds, must increase monotonically. 192 + int64_t timestamp; 193 + 194 + // !Image data 195 + uint8_t *data; 196 + uint32_t width, height; 197 + uint32_t stride, size; 198 + vit_image_format_t format; 199 + 200 + //! Regions to ignore 201 + uint32_t mask_count; 202 + vit_mask_t *masks; 203 + } vit_img_sample_t; 204 + 205 + /*! 206 + * Data that is always returned from tracker. 207 + */ 208 + typedef struct vit_pose_data { 209 + //! In nanoseconds, must increase monotonically. 210 + int64_t timestamp; 211 + 212 + //! Position vector. 213 + float px, py, pz; 214 + 215 + //! Orientation quaternion. 216 + float ox, oy, oz, ow; 217 + 218 + //! Linear velocity. 219 + float vx, vy, vz; 220 + } vit_pose_data_t; 221 + 222 + /*! 223 + * Result of pose timing request function. 224 + */ 225 + typedef struct vit_pose_timing { 226 + uint32_t count; 227 + const int64_t *timestamps; 228 + } vit_pose_timing_t; 229 + 230 + /*! 231 + * One single feature, element of @ref vit_pose_features result. 232 + */ 233 + typedef struct vit_pose_feature { 234 + int64_t id; 235 + float u, v, depth; 236 + } vit_pose_feature_t; 237 + 238 + /*! 239 + * Result of pose feature request function. 240 + */ 241 + typedef struct vit_pose_features { 242 + uint32_t count; 243 + const struct vit_pose_feature *features; 244 + } vit_pose_features_t; 245 + 246 + /*! 247 + * Container of parameters for a pinhole camera calibration (fx, fy, cx, cy) 248 + * with an optional distortion. 249 + * 250 + *`distortion_model` and its corresponding `distortion` parameters are not 251 + * standardized in this struct to facilitate implementation prototyping. 252 + */ 253 + typedef struct vit_camera_calibration { 254 + uint32_t camera_index; // <! For multi-camera setup. For stereo 0 ~ left, 1 ~ right. 255 + 256 + int width, height; //<! Resolution 257 + double frequency; //<! Frames per second 258 + double fx, fy; //<! Focal point 259 + double cx, cy; //<! Principal point 260 + enum vit_camera_distortion model; 261 + uint32_t distortion_count; 262 + double distortion[32]; //!< Parameters for the distortion model 263 + double transform[16]; //!< Row-major 4x4 camera transform w.r.t. the IMU (i.e., T_imu_cam) 264 + } vit_camera_calibration_t; 265 + 266 + typedef struct vit_inertial_calibration { 267 + // Calibration intrinsics to apply to each raw measurement. 268 + 269 + //! Row major 3x3 linear transformation for raw measurements alignment and scaling. 270 + double transform[9]; 271 + 272 + //! Offset to add to raw measurements; called bias in other contexts. 273 + double offset[3]; 274 + 275 + // Parameters for the random processes that model this IMU. See section "2.1 276 + // Gyro Noise Model" of N. Trawny and S. I. Roumeliotis, "Indirect Kalman 277 + // Filter for 3D Attitude Estimation". Analogous for accelerometers. 278 + // http://mars.cs.umn.edu/tr/reports/Trawny05b.pdf#page=15 279 + 280 + //! IMU internal bias ~ wiener process with steps N(0, σ²); this field is σ; 281 + //! [σ] = U / sqrt(sec³) with U = rad if gyroscope, U = m/s if accelerometer. 282 + double bias_std[3]; 283 + 284 + //! IMU measurement noise ~ N(0, σ²); this field is σ. 285 + //! [σ] = U / sqrt(sec) with U = rad if gyroscope, U = m/s if accelerometer. 286 + double noise_std[3]; 287 + } vit_inertial_calibration_t; 288 + 289 + /*! 290 + * Calibration for one IMU. 291 + */ 292 + typedef struct vit_imu_calibration { 293 + uint32_t imu_index; //!< For multi-imu setup, usually just 0. 294 + 295 + double frequency; //!< Samples per second 296 + struct vit_inertial_calibration accel; 297 + struct vit_inertial_calibration gyro; 298 + } vit_imu_calibration_t; 299 + 300 + 301 + /* 302 + * 303 + * Function prototypes. 304 + * 305 + */ 306 + 307 + typedef vit_result_t (*PFN_vit_api_get_version)(uint32_t *out_major, uint32_t *out_minor, uint32_t *out_patch); 308 + typedef vit_result_t (*PFN_vit_tracker_create)(const vit_config_t *config, vit_tracker_t **out_tracker); 309 + typedef void (*PFN_vit_tracker_destroy)(vit_tracker_t *tracker); 310 + typedef vit_result_t (*PFN_vit_tracker_has_image_format)(const vit_tracker_t *tracker, const vit_image_format_t image_format, bool *out_supported); 311 + typedef vit_result_t (*PFN_vit_tracker_get_capabilities)(const vit_tracker_t *tracker, vit_tracker_capability_t *out_caps); 312 + typedef vit_result_t (*PFN_vit_tracker_get_pose_capabilities)(const vit_tracker_t *tracker, vit_tracker_pose_capability_t *out_caps); 313 + typedef vit_result_t (*PFN_vit_tracker_set_pose_capabilities)(vit_tracker_t *tracker, const vit_tracker_pose_capability_t caps, bool value); 314 + typedef vit_result_t (*PFN_vit_tracker_start)(vit_tracker_t *tracker); 315 + typedef vit_result_t (*PFN_vit_tracker_stop)(vit_tracker_t *tracker); 316 + typedef vit_result_t (*PFN_vit_tracker_reset)(vit_tracker_t *tracker); 317 + typedef vit_result_t (*PFN_vit_tracker_is_running)(const vit_tracker_t *tracker, bool *out_bool); 318 + typedef vit_result_t (*PFN_vit_tracker_push_imu_sample)(vit_tracker_t *tracker, const vit_imu_sample_t *sample); 319 + typedef vit_result_t (*PFN_vit_tracker_push_img_sample)(vit_tracker_t *tracker, const vit_img_sample_t *sample); 320 + typedef vit_result_t (*PFN_vit_tracker_add_imu_calibration)(vit_tracker_t *tracker, const vit_imu_calibration_t *calibration); 321 + typedef vit_result_t (*PFN_vit_tracker_add_camera_calibration)(vit_tracker_t *tracker, const vit_camera_calibration_t *calibration); 322 + typedef vit_result_t (*PFN_vit_tracker_pop_pose)(vit_tracker_t *tracker, vit_pose_t **out_pose); 323 + typedef vit_result_t (*PFN_vit_tracker_get_timing_titles)(const vit_tracker_t *tracker, vit_tracker_timing_titles *out_titles); 324 + typedef void (*PFN_vit_pose_destroy)(vit_pose_t *pose); 325 + typedef vit_result_t (*PFN_vit_pose_get_data)(const vit_pose_t *pose, vit_pose_data_t *out_data); 326 + typedef vit_result_t (*PFN_vit_pose_get_timing)(const vit_pose_t *pose, vit_pose_timing_t *out_timing); 327 + typedef vit_result_t (*PFN_vit_pose_get_features)(const vit_pose_t *pose, uint32_t camera_index, vit_pose_features_t *out_features); 328 + 329 + 330 + /* 331 + * 332 + * Functions. 333 + * 334 + */ 335 + 336 + #ifdef VIT_INTERFACE_IMPLEMENTATION 337 + 338 + /*! 339 + * @brief Returns the API version implemented by the VIT system. 340 + */ 341 + vit_result_t 342 + vit_api_get_version(uint32_t *out_major, uint32_t *out_minor, uint32_t *out_patch); 343 + 344 + /*! 345 + * @brief Creates a new VIT tracker. The caller is responsible of destroying it when done. 346 + */ 347 + vit_result_t 348 + vit_tracker_create(const vit_config_t *config, vit_tracker_t **out_tracker); 349 + 350 + /*! 351 + * @brief Destroys the VIT tracker and free all resources allocated. 352 + */ 353 + void 354 + vit_tracker_destroy(vit_tracker_t *tracker); 355 + 356 + /*! 357 + * @brief Verifies if the tracker supports a given `vit_image_format_t`. 358 + */ 359 + vit_result_t 360 + vit_tracker_has_image_format(const vit_tracker_t *tracker, const vit_image_format_t image_format, bool *out_supported); 361 + 362 + /*! 363 + * @brief Returns a bitfield of capabilities supported by the tracker. 364 + * 365 + * @see vit_tracker_capability_t 366 + */ 367 + 368 + vit_result_t 369 + vit_tracker_get_capabilities(const vit_tracker_t *tracker, vit_tracker_capability_t *out_caps); 370 + 371 + /*! 372 + * @brief Returns a bitfield of pose capabilities supported by the tracker. 373 + * 374 + * @see vit_tracker_pose_capability_t 375 + */ 376 + vit_result_t 377 + vit_tracker_get_pose_capabilities(const vit_tracker_t *tracker, vit_tracker_pose_capability_t *out_caps); 378 + 379 + /*! 380 + * @brief Enables or disables multiple tracker pose capabilities. 381 + * 382 + * @p caps can be a bitfield of `vit_tracker_pose_capability_t`. 383 + * 384 + * @see vit_tracker_pose_capability_t 385 + */ 386 + vit_result_t 387 + vit_tracker_set_pose_capabilities(vit_tracker_t *tracker, const vit_tracker_pose_capability_t caps, bool value); 388 + 389 + /*! 390 + * @brief Starts the VIT tracker. Image and IMU samples can be pushed and pose can be retrieved. 391 + * 392 + * This function must be non blocking. The VIT system implementing it is expected to start its own event loop. 393 + */ 394 + vit_result_t 395 + vit_tracker_start(vit_tracker_t *tracker); 396 + 397 + /*! 398 + * @brief Stops the VIT tracker. The tracker wont accept image and IMU samples, and will not return poses. 399 + */ 400 + vit_result_t 401 + vit_tracker_stop(vit_tracker_t *tracker); 402 + 403 + /*! 404 + * @brief Resets the VIT tracker. The tracker internal state will be set to its original state. 405 + */ 406 + vit_result_t 407 + vit_tracker_reset(vit_tracker_t *tracker); 408 + 409 + /*! 410 + * @brief Verifies if the tracker is running. 411 + */ 412 + vit_result_t 413 + vit_tracker_is_running(const vit_tracker_t *tracker, bool *out_bool); 414 + 415 + /*! 416 + * @brief Push an IMU sample into the tracker. 417 + * 418 + * There must be a single producer thread pushing samples. 419 + * Samples must have monotonically increasing timestamps. 420 + * The implementation must be non-blocking. 421 + * Thus, a separate consumer thread should process the samples. 422 + */ 423 + vit_result_t 424 + vit_tracker_push_imu_sample(vit_tracker_t *tracker, const vit_imu_sample_t *sample); 425 + 426 + /*! 427 + * @brief Push an image sample into the tracker. 428 + * 429 + * Same conditions as @ref push_imu_sample apply. 430 + * When using N>1 cameras, the N frames must be pushed following @ref cam_index order. 431 + * The bundle of N frames must have the same timestamps. 432 + */ 433 + vit_result_t 434 + vit_tracker_push_img_sample(vit_tracker_t *tracker, const vit_img_sample_t *sample); 435 + 436 + /*! 437 + * @brief Adds an inertial measurement unit calibration to the tracker. The tracker must not be started. 438 + * 439 + * Returns `VIT_ERROR_NOT_SUPPORTED` if the tracker doesn't offer the capability. 440 + * 441 + * @see vit_tracker_get_capabilities 442 + * @see vit_tracker_capability_t 443 + */ 444 + vit_result_t 445 + vit_tracker_add_imu_calibration(vit_tracker_t *tracker, const vit_imu_calibration_t *calibration); 446 + 447 + /*! 448 + * @brief Adds a camera calibration to the tracker. The tracker must not be started. 449 + * 450 + * Returns `VIT_ERROR_NOT_SUPPORTED` if the tracker doesn't offer the capability. 451 + * 452 + * @see vit_tracker_get_capabilities 453 + * @see vit_tracker_capability_t 454 + */ 455 + vit_result_t 456 + vit_tracker_add_camera_calibration(vit_tracker_t *tracker, const vit_camera_calibration_t *calibration); 457 + 458 + /*! 459 + * @brief Get the pose from the front of the tracking queue from the VIT tracker 460 + * 461 + * This function must be non-blocking and consumed by a single consummer. 462 + * 463 + * If @p out_pose is NULL the pose will be immediately destroyed. 464 + * 465 + * @param[out] out_pose Pose returned to the caller, NULL if there is not pose available or on error. 466 + */ 467 + vit_result_t 468 + vit_tracker_pop_pose(vit_tracker_t *tracker, vit_pose_t **out_pose); 469 + 470 + /*! 471 + * @brief Get the titles of the timestamps measured by the pose timings. 472 + * 473 + * Returns `VIT_ERROR_NOT_SUPPORTED` if the tracker doesn't offer the pose timing capability. 474 + */ 475 + vit_result_t 476 + vit_tracker_get_timing_titles(const vit_tracker_t *tracker, vit_tracker_timing_titles *out_titles); 477 + 478 + /*! 479 + * @brief Destroys a pose. All of the data, timing and features associated to it will be invalidated. 480 + */ 481 + void 482 + vit_pose_destroy(vit_pose_t *pose); 483 + 484 + /*! 485 + * @brief Gets the data form a given `vit_pose_t`. 486 + * 487 + * The data becomes invalid when the associated pose gets destroyed. 488 + */ 489 + vit_result_t 490 + vit_pose_get_data(const vit_pose_t *pose, vit_pose_data_t *out_data); 491 + 492 + /*! 493 + * @brief Gets the timing form a given `vit_pose_t`. 494 + * 495 + * The timing data becomes invalid when the associated pose gets destroyed. 496 + */ 497 + vit_result_t 498 + vit_pose_get_timing(const vit_pose_t *pose, vit_pose_timing_t *out_timing); 499 + 500 + /*! 501 + * @brief Gets the features form a given `vit_pose_t`. 502 + * 503 + * The features data becomes invalid when the associated pose gets destroyed. 504 + */ 505 + vit_result_t 506 + vit_pose_get_features(const vit_pose_t *pose, uint32_t camera_index, vit_pose_features_t *out_features); 507 + 508 + #endif 509 + 510 + #if defined(__cplusplus) 511 + } 512 + #endif