Class keyframe_t

Class Documentation

class keyframe_t

Stores all data associated with a map keyframe.

A keyframe owns camera sensor data, initial and optimized poses, keypoints, descriptors, and an optional global image descriptor used for place recognition.

Public Types

using shared_ptr = std::shared_ptr<keyframe_t>

Shared pointer type for keyframe_t.

using weak_ptr = std::weak_ptr<keyframe_t>

Weak pointer type for keyframe_t.

using SensorData = data_type::SensorData

Alias for sensor data type.

Public Functions

keyframe_t() = default

Construct an empty keyframe instance.

keyframe_t(const SensorData::weak_ptr &cameraData_, const pose_t &initPose_, const point2d_t::vector &allKeypoints_, const descriptor_t::vector &allDescriptors_)

Construct a keyframe from camera data, pose, and feature data.

Parameters:
  • cameraData_ – Camera data associated with the keyframe.

  • initPose_ – Initial pose of the keyframe.

  • allKeypoints_ – All keypoints detected in the keyframe.

  • allDescriptors_ – All descriptors associated with the keyframe.

inline pose_t::weak_ptr get_pose() const

Get optimized camera pose pointer associated with this keyframe.

Returns:

Weak pointer to the optimized camera pose.

inline pose_t get_initial_pose() const

Get initial camera pose associated with this keyframe.

Note

This camera pose is the one that was estimated using pose estimation algorithms, such as PnP or ICP, during localization.

Returns:

Initial pose used when the keyframe was inserted.

inline const point2d_t::vector &get_all_keypoints() const

Get all detected 2D keypoints stored in this keyframe.

Returns:

Const reference to keypoint vector.

inline const descriptor_t::vector &get_all_descriptors() const

Get all local feature descriptors stored in this keyframe.

Returns:

Const reference to descriptor vector.

inline void set_pose(const pose_t &newPose_)

Set optimized camera pose from a pose value.

Parameters:

newPose_ – New pose value.

inline void set_pose(const pose_t::shared_ptr newPose_)

Set optimized camera pose from a shared pose pointer.

Parameters:

newPose_ – New shared pose pointer.

inline void set_image_descriptor(const descriptor_t &descriptor_)

Set the global image descriptor for this keyframe.

Parameters:

descriptor_ – Descriptor to store.

inline const descriptor_t &get_image_descriptor() const

Get the global image descriptor for this keyframe.

Returns:

Const reference to the global image descriptor.

inline const image_t &get_image() const

Get the keyframe color image.

Returns:

Const reference to the color image.

inline const image_t &get_gray_image() const

Get the keyframe grayscale image.

Returns:

Const reference to the grayscale image.

inline const image_t &get_depth_image() const

Get the keyframe depth image.

Returns:

Const reference to the depth image.

inline const intrinsics_t &get_intrinsics() const

Get camera intrinsics associated with this keyframe.

Returns:

Const reference to camera intrinsics.

inline const distortion_t get_distortion() const

Get distortion coefficients associated with this keyframe.

Returns:

Distortion coefficients copied from sensor data.

inline SensorData::weak_ptr get_camera_data() const

Get camera data weak pointer associated with this keyframe.

Returns:

Weak pointer to SensorData associated with this keyframe.

Public Static Functions

static inline shared_ptr make_shared(const keyframe_t &other_)

Create a heap-allocated copy of an existing keyframe.

Parameters:

other_ – Source keyframe to copy.

Returns:

Shared pointer owning the copied keyframe.

static output_t<intrinsics_t> get_intrinsics(const weak_ptr &ptr_)

Retrieve camera intrinsics from a keyframe weak pointer.

Parameters:

ptr_ – Weak pointer to the keyframe.

Returns:

Intrinsics wrapped in output_t, or a fail_t error.

static output_t<image_t> get_color_image(const weak_ptr &ptr_)

Retrieve the color image from a keyframe weak pointer.

Parameters:

ptr_ – Weak pointer to the keyframe.

Returns:

Color image wrapped in output_t, or a fail_t error.

static output_t<descriptor_t::vector> get_descriptors(const weak_ptr &ptr_)

Retrieve all local descriptors from a keyframe weak pointer.

Parameters:

ptr_ – Weak pointer to the keyframe.

Returns:

Descriptor vector wrapped in output_t, or a fail_t error.

static fail_t set_image_descriptor(const weak_ptr &ptr_, const descriptor_t &descriptor_)

Set the global image descriptor for a keyframe weak pointer.

Parameters:
  • ptr_ – Weak pointer to the keyframe.

  • descriptor_ – Descriptor to store in the keyframe.

Returns:

fail_t::NO_FAIL on success, otherwise a fail_t error.

static output_t<descriptor_t> get_image_descriptor(const weak_ptr &ptr_)

Retrieve the global image descriptor from a keyframe.

Parameters:

ptr_ – Weak pointer to the keyframe.

Returns:

Global descriptor wrapped in output_t, or a fail_t error.

static output_t<SensorData::weak_ptr> get_camera_data(const weak_ptr &ptr_)

Retrieve camera sensor data from a keyframe weak pointer.

Parameters:

ptr_ – Weak pointer to the keyframe.

Returns:

SensorData weak pointer wrapped in output_t, or a fail_t error.

static output_t<pose_t::weak_ptr> get_pose(const weak_ptr &ptr_)

Retrieve optimized camera pose pointer from a keyframe.

Parameters:

ptr_ – Weak pointer to the keyframe.

Returns:

pose_t weak pointer wrapped in output_t, or a fail_t error.

static output_t<shared_ptr> to_shared(const weak_ptr &ptr_)

Convert keyframe weak pointer to a shared pointer.

Parameters:

ptr_ – Weak pointer to convert.

Returns:

Shared pointer wrapped in output_t, or a fail_t error.

Private Members

pose_t::shared_ptr _cameraPose

current camera pose in world coordinates

SensorData::shared_ptr _cameraData

camera data

pose_t _initialPose

initial camera pose for this keyframe

point2d_t::vector _allKeypoints

all keypoints in the keyframe

descriptor_t::vector _allDescriptors

all descriptors in the keyframe

descriptor_t _imageDescriptor

Global image descriptor for visual place recognition.