ImFusion SDK 4.3
RGBDRelocalization Class Reference

#include <RGBD/Include/ImFusion/RGBD/RGBDRelocalization.h>

Algorithm for relocalization using RGB-D data. More...

+ Inheritance diagram for RGBDRelocalization:

Detailed Description

Algorithm for relocalization using RGB-D data.

This class implements a relocalization algorithm based on the paper "Real-Time RGB-D Camera Relocalization", ISMAR 2013. It uses randomized ferns and keyframe matching to estimate camera pose from RGB-D images. The algorithm supports initialization, frame addition, pose database management, and frame localization.

Usage:

  • Call init() to configure the relocalization parameters and image sizes.
  • Add frames with known poses using addFrame().
  • Use localize() to estimate the pose of a new frame by matching it against the database.
  • Retrieve all keyframe poses using keyframePoses().
  • Use clear() to reset the database.

Important aspects:

  • Supports configurable fern count, matching threshold, image sizes, and downsampling.
  • Maintains a database of keyframes and their poses for relocalization.
  • Returns multiple candidate poses with quality scores for each localization request.
  • Not thread-safe.

Example:

relocal.init(500, 0.2, 640, 480, 640, 480, 8000, 40000, 8, 2.5);
relocal.addFrame(0, depthImg, colorImg, pose);
relocal.localize(depthImg, colorImg, candidates, 4);
RGBDRelocalization()
Constructs a new RGBDRelocalization instance.
int localize(TypedImage< float > *imgDepth, TypedImage< unsigned char > *imgColor, std::vector< std::tuple< mat4, double, int > > &T, int k=4) override
Localizes a frame and returns poses for closest matching frames.
bool init(int widthDepth, int heightDepth, int widthColor, int heightColor) override
Initializes the relocalization algorithm with image sizes.
int addFrame(int id, TypedImage< float > *imgDepth, TypedImage< unsigned char > *imgColor, const mat4 &T, bool *addedToDatabase=0) override
Adds a frame to the relocalization database.
See also
Relocalization, RGBDReconstructionAlgorithm

Public Member Functions

 RGBDRelocalization ()
 Constructs a new RGBDRelocalization instance.
 
bool init (int widthDepth, int heightDepth, int widthColor, int heightColor) override
 Initializes the relocalization algorithm with image sizes.
 
bool init (int ferns=500, double threshold=0.2, int widthDepth=640, int heightDepth=480, int widthColor=640, int heightColor=480, float minDepth=8000, float maxDepth=40000, int downsampleFactor=8, double sigmaSmooth=2.5)
 Initializes relocalization parameters.
 
void clear () override
 Clears all keyframe data and resets the database.
 
int addFrame (int id, TypedImage< float > *imgDepth, TypedImage< unsigned char > *imgColor, const mat4 &T, bool *addedToDatabase=0) override
 Adds a frame to the relocalization database.
 
int localize (TypedImage< float > *imgDepth, TypedImage< unsigned char > *imgColor, std::vector< std::tuple< mat4, double, int > > &T, int k=4) override
 Localizes a frame and returns poses for closest matching frames.
 
void keyframePoses (std::map< int, mat4 > &T) const
 Returns all keyframe poses.
 
- Public Member Functions inherited from Relocalization
 Relocalization ()
 Constructs the relocalization interface.
 
virtual ~Relocalization ()
 Destroys the relocalization interface.
 

Additional Inherited Members

- Protected Member Functions inherited from NotCopyable
 NotCopyable (NotCopyable &&) noexcept=default
 
NotCopyableoperator= (NotCopyable &&) noexcept=default
 
 NotCopyable (const NotCopyable &)=delete
 
NotCopyableoperator= (const NotCopyable &)=delete
 

Member Function Documentation

◆ init() [1/2]

bool init ( int widthDepth,
int heightDepth,
int widthColor,
int heightColor )
overridevirtual

Initializes the relocalization algorithm with image sizes.

Parameters
widthDepthInput depth image width.
heightDepthInput depth image height.
widthColorInput color image width.
heightColorInput color image height.
Returns
True if successful.

Implements Relocalization.

◆ init() [2/2]

bool init ( int ferns = 500,
double threshold = 0.2,
int widthDepth = 640,
int heightDepth = 480,
int widthColor = 640,
int heightColor = 480,
float minDepth = 8000,
float maxDepth = 40000,
int downsampleFactor = 8,
double sigmaSmooth = 2.5 )

Initializes relocalization parameters.

Parameters
fernsNumber of ferns.
thresholdMatching threshold for determining whether an image has been seen before. Range [0;1]. Smaller means more keyframes.
widthDepthInput depth image width.
heightDepthInput depth image height.
widthColorInput color image width.
heightColorInput color image height.
minDepthMinimum depth value for threshold.
maxDepthMaximum depth value for threshold.
downsampleFactorFactor by which input images are downsampled.
sigmaSmoothSigma of gaussian kernel with which image is smoothed prior to downsampling.
Returns
True if successful.

◆ clear()

void clear ( )
overridevirtual

Clears all keyframe data and resets the database.

Implements Relocalization.

◆ addFrame()

int addFrame ( int id,
TypedImage< float > * imgDepth,
TypedImage< unsigned char > * imgColor,
const mat4 & T,
bool * addedToDatabase = 0 )
overridevirtual

Adds a frame to the relocalization database.

Parameters
idFrame id.
imgDepthDepth image.
imgColorColor image.
TPose for frame.
[out]addedToDatabaseTrue if frame was added to pose database, false otherwise.
Returns
Zero if successful.

Implements Relocalization.

◆ localize()

int localize ( TypedImage< float > * imgDepth,
TypedImage< unsigned char > * imgColor,
std::vector< std::tuple< mat4, double, int > > & T,
int k = 4 )
overridevirtual

Localizes a frame and returns poses for closest matching frames.

Parameters
imgDepthDepth image.
imgColorColor image.
[out]TVector of pose candidates with quality score and frame id (score in [0,1], 1 being better).
kMaximum number of poses to return.
Returns
Zero if successful.

Implements Relocalization.

◆ keyframePoses()

void keyframePoses ( std::map< int, mat4 > & T) const
inline

Returns all keyframe poses.

Parameters
[out]TMap of keyframe poses (frame id to pose).

The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close