#include <RGBD/Include/ImFusion/RGBD/RGBDRelocalization.h>
Algorithm for relocalization using RGB-D data.
More...
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
|
|
| 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.
|
| |
|
| Relocalization () |
| | Constructs the relocalization interface.
|
| |
|
virtual | ~Relocalization () |
| | Destroys the relocalization interface.
|
| |
◆ init() [1/2]
| bool init |
( |
int | widthDepth, |
|
|
int | heightDepth, |
|
|
int | widthColor, |
|
|
int | heightColor ) |
|
overridevirtual |
Initializes the relocalization algorithm with image sizes.
- Parameters
-
| widthDepth | Input depth image width. |
| heightDepth | Input depth image height. |
| widthColor | Input color image width. |
| heightColor | Input 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
-
| ferns | Number of ferns. |
| threshold | Matching threshold for determining whether an image has been seen before. Range [0;1]. Smaller means more keyframes. |
| widthDepth | Input depth image width. |
| heightDepth | Input depth image height. |
| widthColor | Input color image width. |
| heightColor | Input color image height. |
| minDepth | Minimum depth value for threshold. |
| maxDepth | Maximum depth value for threshold. |
| downsampleFactor | Factor by which input images are downsampled. |
| sigmaSmooth | Sigma of gaussian kernel with which image is smoothed prior to downsampling. |
- Returns
- True if successful.
◆ clear()
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
-
| id | Frame id. |
| imgDepth | Depth image. |
| imgColor | Color image. |
| T | Pose for frame. |
| [out] | addedToDatabase | True if frame was added to pose database, false otherwise. |
- Returns
- Zero if successful.
Implements Relocalization.
◆ localize()
Localizes a frame and returns poses for closest matching frames.
- Parameters
-
| imgDepth | Depth image. |
| imgColor | Color image. |
| [out] | T | Vector of pose candidates with quality score and frame id (score in [0,1], 1 being better). |
| k | Maximum 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] | T | Map of keyframe poses (frame id to pose). |
The documentation for this class was generated from the following file:
- RGBD/Include/ImFusion/RGBD/RGBDRelocalization.h