3#include "../../GraphOptimization/Headers/DLLInfo.h"
4#include "OrbSLAM/Thirdparty/DBoW2/DBoW2/BowVector.h"
5#include "OrbSLAM/Thirdparty/Sophus/sophus/se3.hpp"
6#include "OrbSLAM/Headers/ORBVocabulary.h"
7#include <NDEVR/IntegratedRotation.h>
8#include <NDEVR/RWLock.h>
9#include "Base/Headers/Buffer.hpp"
11#include <opencv2/opencv.hpp>
56 PrimitiveAlignedBuffer<cv::KeyPoint, 32>
keys;
191 ,
ORBVocabulary* voc,
const IMU::Calib& ImuCalib = IMU::Calib());
228 virtual void setPose(
const Sophus::SE3<g_type>& Tcw);
240 void setImuPoseVelocity(
const Eigen::Matrix3<g_type>& Rwb,
const Eigen::Vector3<g_type>& twb,
const Eigen::Vector3<g_type>& Vwb);
380 return mTwc.translation();
385 const Eigen::Matrix<g_type, 3, 1>&
tcw()
const {
386 return mTcw.translation();
393 return mTwc.rotationMatrix();
402 virtual inline Sophus::SE3<g_type>
pose()
const {
546 void undistortKeyPoints();
551 void AssignFeaturesToGrid();
Logic for reading or writing to a binary file including logic for compressing or decompressing the fi...
A specification of upper and lower bounds in N-dimensions.
The equivelent of std::vector but with a bit more control.
Stores a prior constraint on an IMU pose with its information matrix.
A hash-based key-value store, useful for quick associative lookups.
bool isMono() const
Checks whether this frame is monocular (single camera).
Frame()=default
Default constructor.
Sophus::SE3< g_type > sensor_pose
External sensor pose.
uint04 observationCount(uint04 idx) const
Returns the observation count for a map point at the given index.
RWLock & mapPointsLockPtr() const
Returns the read-write lock for map point access.
const Buffer< float > & levelSigma2() const
Returns the sigma squared values per pyramid level.
uint04 trackedMapPoints(uint04 minObs) const
Counts map points with at least the given number of observations.
uint04 undistortedPointCount() const
Returns the number of undistorted keypoints.
const Eigen::Matrix< g_type, 3, 1 > & tcw() const
Returns the camera-to-world translation.
void getFeaturesInArea(Buffer< uint04 > &indices, fltp04 x, fltp04 y, fltp04 r, uint04 min_level=0U, uint04 max_level=Constant< uint04 >::Max, const bool bRight=false) const
Finds features within a circular area in the image.
const Dictionary< uint04, Buffer< uint04 > > & featureIndices() const
Returns the feature index map (word ID to keypoint indices).
Buffer< fltp04 > m_right
Right stereo coordinate per keypoint (negative if monocular).
Eigen::Vector3< g_type > inRefCoordinates(Eigen::Vector3< g_type > pCw) const
Transforms a world-coordinate point into this frame's camera coordinates.
void computeStereoMatches()
Searches stereo matches between left and right keypoints.
Vector< 2, uint04 > discardOutliers()
Discards outlier map point associations.
Buffer< fltp04 > m_depth
Depth per keypoint.
Frame(Frame &&frame) noexcept
Move constructor.
Frame(FrameInfo *frame_info, const cv::Mat &imGray, const cv::Mat &imDepth, fltp08 timeStamp, ORBextractor *extractor, ORBVocabulary *voc, const IMU::Calib &ImuCalib=IMU::Calib())
Constructor for RGB-D cameras.
fltp04 nearFarThreshold() const
Returns the near/far depth threshold.
Frame(const Frame &frame)
Copy constructor.
const cv::KeyPoint & keypoint(uint04 i) const
Returns the keypoint at the given index.
virtual Sophus::SE3< g_type > imuPose() const
Returns the IMU pose as an SE3 transform.
Frame(FrameInfo *frame_info, const cv::Mat &imGray, fltp08 timeStamp, ORBextractor *extractor, ORBVocabulary *voc, const IMU::Calib &ImuCalib=IMU::Calib())
Constructor for monocular cameras.
const Buffer< float > & invLevelSigma2() const
Returns the inverse sigma squared values per pyramid level.
void init(FrameInfo *info, const cv::Mat &imGray, const cv::Mat &imDepth, fltp08 timeStamp, ORBextractor *extractor, ORBVocabulary *voc, const IMU::Calib &ImuCalib=IMU::Calib())
Initializes a frame from RGB-D data.
KeyFrame * mpReferenceKF
Reference keyframe.
uint04 levelCount() const
Returns the number of pyramid levels.
void clearMapPoints()
Clears all map point associations.
void updatePoseMatrices()
Recomputes derived pose matrices from the current camera pose.
fltp08 timestamp() const
Returns the capture timestamp.
Sophus::SE3< g_type > mTrl
Right-to-left camera relative pose.
Eigen::Vector3< g_type > mOwb
IMU position in world coordinates.
virtual Eigen::Vector3< g_type > linearVelocity() const
Returns the linear velocity of the frame.
void eraseMapPointMatch(uint04)
Removes a map point association at the given index.
bool mbHasVelocity
Whether a valid velocity has been set.
PrimitiveAlignedBuffer< cv::KeyPoint, 32 > m_undistorted_points
Undistorted keypoints used by the system.
bool hasCamera(uint01 index) const
Checks whether a camera at the given index is available.
const Buffer< MapPoint * > & mapPoints() const
Returns all map point associations.
void setImuPoseVelocity(const Eigen::Matrix3< g_type > &Rwb, const Eigen::Vector3< g_type > &twb, const Eigen::Vector3< g_type > &Vwb)
Sets IMU pose and velocity, implicitly updating the camera pose.
void clearBoW()
Clears the Bag of Words data.
MapPoint * mapPoint(uint04 idx) const
Returns the map point at the given index.
virtual void setLinearVelocity(const Eigen::Vector3< g_type > &Vw)
Sets the IMU linear velocity.
Sophus::SE3< g_type > mTcw
World-to-camera transform.
const Buffer< MapPoint * > & mapPointMatches()
Returns the map point matches buffer.
Dictionary< uint04, Buffer< uint04 > > m_features_indices
Maps BoW word IDs to keypoint indices.
ORBextractor * m_extractor
ORB feature extractor.
fltp08 m_timestamp
Frame capture timestamp.
const Buffer< float > & invScaleFactors() const
Returns the inverse ORB scale factors per pyramid level.
fltp04 right(uint04 idx) const
Returns the right stereo coordinate at the given keypoint index.
void extractORB(uint01 flag, const cv::Mat &im, uint04 x0, uint04 x1)
Extracts ORB features from the image.
bool mbImuPreintegrated
Whether IMU preintegration is complete.
virtual void setPose(const Sophus::SE3< g_type > &Tcw)
Sets the camera pose (does not modify IMU pose).
Sophus::SE3< g_type > mTlr
Left-to-right camera relative pose.
KeyFrame * mpLastKeyFrame
Previous keyframe.
bool imuIsPreintegrated() const
Checks whether the IMU preintegration is complete.
IMUData imu_data
IMU calibration and bias data.
Buffer< MapPoint * > m_map_points
Map point associations for each keypoint.
ConstraintPoseImu * mpcpi
IMU pose constraint.
const Buffer< bool > & outliers() const
Returns the outlier flags buffer.
Frame & operator=(const Frame &frame) noexcept
Copy assignment operator.
virtual Eigen::Matrix< g_type, 3, 1 > GetImuPosition() const
Returns the IMU position in world coordinates.
virtual Sophus::SE3< g_type > inversePose() const
Returns the inverse camera pose (camera-to-world transform).
void setIntegrated()
Marks the IMU preintegration as complete.
bool isOutlier(uint04 idx) const
Checks whether the map point at the given index is an outlier.
Sophus::SE3< g_type > GetRelativePoseTrl() const
Returns the relative pose from right to left camera.
LogPtr log()
Returns the logger for this frame.
bool HasVelocity() const
Checks whether a valid velocity has been set.
FrameView * m_view[2]
Left [0] and right [1] view data.
virtual Eigen::Matrix3< g_type > GetRotation() const
Returns the camera rotation matrix (camera-to-world).
MapPoint * mapPoint(uint04 idx)
Returns the map point at the given index (non-const).
const PrimitiveAlignedBuffer< cv::KeyPoint, 32 > & undistortedPoints() const
Returns all undistorted keypoints.
Eigen::Vector3< g_type > stereo3DPoint(uint04 idx) const
Returns the triangulated 3D stereo point at the given index.
Sophus::SE3< g_type > mTwc
Camera-to-world transform (inverse of mTcw).
bool HasPose() const
Checks whether a valid pose has been set.
static __attribute__((visibility("default"))) static void Set3DCallback(std std::function< Vector< 3, fltp04 >(Frame *frame, Vector< 3, fltp04 >) s_point_to_3d_callback)
Sets a callback for converting frame points to 3D.
Frame(FrameInfo *frame_info, const cv::Mat &imLeft, const cv::Mat &imRight, fltp08 timeStamp, ORBextractor *extractorLeft, ORBextractor *extractorRight, ORBVocabulary *voc, const IMU::Calib &ImuCalib=IMU::Calib())
Constructor for stereo cameras.
void setOutliers(const Buffer< bool > &map_points)
Sets the outlier flags buffer.
Buffer< Eigen::Vector3< g_type > > m_stereo_3D_points
Triangulated stereo 3D points from fisheye matching.
void setOutlier(uint04 idx, bool outlier)
Sets the outlier flag at the given index.
void setMapPoints(const Buffer< MapPoint * > &map_points)
Sets all map point associations.
Sophus::SE3< g_type > GetRelativePoseTlr() const
Returns the relative pose from left to right camera.
void computeStereoFromRGBD(const cv::Mat &imDepth)
Associates depth-derived right coordinates to keypoints from an RGB-D depthmap.
Buffer< bool > m_outlier
Outlier flag per keypoint.
static cv::BFMatcher BFmatcher
Brute-force matcher for stereo fisheye matching.
const Buffer< float > & scaleFactors() const
Returns the ORB scale factors per pyramid level.
const BowVector & bow() const
Returns the Bag of Words vector.
virtual Sophus::SE3< g_type > pose() const
Returns the camera pose (world-to-camera transform).
bool mbHasPose
Whether a valid pose has been set.
FrameInfo * m_frame_info
Shared camera info (intrinsics, bounds).
static volatile uint04 s_next_id
Global frame ID counter.
const FrameInfo & info() const
Returns the shared frame info.
Eigen::Matrix3< g_type > cameraRotation() const
Returns the world-to-camera rotation (inverse rotation).
virtual Eigen::Matrix< g_type, 3, 3 > GetImuRotation() const
Returns the IMU rotation matrix.
uint04 mapPointCount() const
Returns the number of map points associated with this frame.
virtual Eigen::Vector3< g_type > GetTranslation() const
Returns the camera translation vector (camera-to-world).
bool isSet() const
Checks whether this frame has been initialized.
BowVector m_bow
Bag of Words vector for this frame.
const Eigen::Vector3< g_type > & cameraCenter() const
Returns the camera center in world coordinates.
bool isKeyFrame()
Checks whether this frame is a keyframe.
Frame(FrameInfo *frame_info, const cv::Mat &imLeft, const cv::Mat &imRight, fltp08 timeStamp, ORBextractor *extractorLeft, ORBextractor *extractorRight, ORBVocabulary *voc, GeometricCamera *pCamera2, Sophus::SE3< g_type > &Tlr, const IMU::Calib &ImuCalib=IMU::Calib())
Constructor for stereo cameras with a second camera model.
fltp04 trackDepth(const Eigen::Vector3< g_type > &global_position) const
Computes the depth of a 3D point relative to this frame's camera.
Eigen::Vector3< g_type > GetRelativePoseTlr_translation() const
Returns the translation component of the left-to-right relative pose.
Eigen::Vector3< g_type > m_linear_velocity
IMU linear velocity.
uint04 N
Number of keypoints.
const cv::KeyPoint & keypoint(uint04 i, bool is_right) const
Returns the keypoint at the given index from left or right view.
IMU::Preintegrated * mpImuPreintegrated
IMU preintegration from last keyframe.
void SetNewBias(const IMU::Bias &b)
Updates the IMU bias.
Eigen::Vector3< g_type > unproject(uint04 i)
Backprojects a keypoint into 3D world coordinates using stereo/depth info.
ORBVocabulary * mpORBvocabulary
ORB vocabulary for relocalization.
void ComputeStereoFishEyeMatches()
Computes stereo matches for fisheye cameras.
void setMapPointMatch(uint04, MapPoint *pMP)
Sets a map point association at the given index.
RWLock m_feature_lock
Read-write lock for map point access.
Eigen::Matrix3< g_type > GetRelativePoseTlr_rotation() const
Returns the rotation component of the left-to-right relative pose.
Frame & operator=(Frame &&frame) noexcept
Move assignment operator.
Buffer< Vector< 2, fltp04 > > m_original_points
Original (possibly distorted) keypoint positions.
fltp04 scaleFactor() const
Returns the ORB scale factor.
void computeBoW()
Computes the Bag of Words representation for this frame.
const cv::KeyPoint & undistortedPoint(uint04 idx) const
Returns the undistorted keypoint at the given index.
bool m_is_keyframe
Whether this frame is a keyframe.
bool mbIsSet
Whether this frame has been initialized.
IMU::Preintegrated * mpImuPreintegratedFrame
Frame-level IMU preintegration.
fltp04 depth(uint04 idx) const
Returns the depth at the given keypoint index.
Abstract interface for geometric camera models (pinhole, fisheye, etc.).
A light-weight base class for Log that allows processes to update, without the need for additional in...
A keyframe in the SLAM map, derived from Frame.
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
A 3D point in the SLAM map observed by multiple keyframes.
A readers-writer lock allowing concurrent reads or exclusive writes.
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
TemplatedVocabulary< FORB::TDescriptor, FORB > ORBVocabulary
ORB visual vocabulary type for Bag-of-Words place recognition.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
constexpr uint04 FRAME_GRID_ROWS
Number of rows in the feature grid.
constexpr uint04 FRAME_GRID_COLS
Number of columns in the feature grid.
Shared camera intrinsic and image metadata for frames.
float invfx
Inverse of fx.
float mb
Stereo baseline in meters.
float fy
Focal length in y.
float cy
Principal point y.
float mfGridElementWidthInv
Inverse of grid cell width in pixels.
FrameInfo(const Vector< 2, uint04 > &size, const cv::Mat &mDistCoef, const cv::Mat &mK, GeometricCamera *camera, fltp04 thDepth, fltp04 mbf)
Constructs FrameInfo from camera parameters.
float mbf
Stereo baseline multiplied by fx.
float invfy
Inverse of fy.
Bounds< 2, fltp04 > image_bounds
Undistorted image bounds.
LogPtr log
Logger instance.
fltp04 thDepth
Near/far depth threshold.
GeometricCamera * pCamera
Associated geometric camera model.
float fx
Focal length in x.
float mfGridElementHeightInv
Inverse of grid cell height in pixels.
const cv::Mat K
Camera intrinsic matrix.
Vector< 2, uint04 > image_size
Image dimensions in pixels.
const cv::Mat mDistCoef
Distortion coefficients.
float cx
Principal point x.
Holds per-view (left or right) keypoint data for a frame.
FrameView(const FrameView &other)
Copy constructor.
ORBextractor * extractor
ORB feature extractor for this view.
PrimitiveAlignedBuffer< cv::KeyPoint, 32 > keys
Extracted keypoints.
cv::Mat descriptors
ORB descriptors for extracted keypoints.
Dictionary< Vector< 2, uint04 >, Buffer< uint04 > > grid
Feature grid mapping cell coordinates to keypoint indices.
void init(ORBextractor *extractor, GeometricCamera *camera)
Initializes the view with the given extractor and camera.
FrameView()
Default constructor.
FrameView & operator=(const FrameView &other)
Copy assignment operator.
FrameView(ORBextractor *extractor, GeometricCamera *camera)
Constructs a FrameView with the given extractor and camera.
uint04 keypoint_count
Number of overlapping keypoints.
GeometricCamera * camera
Camera model for this view.
Buffer< uint04 > match_points
Indices of matched map points.
uint04 mono_count
Number of non-lapping (monocular) keypoints.
Holds IMU calibration and bias data for a frame.
IMU::Bias mImuBias
Current IMU bias estimate.
IMU::Calib mImuCalib
IMU calibration parameters.