ImFusion SDK 4.3
SurfaceReconstructionGPU Class Reference

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

GPU-accelerated volumetric surface reconstruction from RGB-D data. More...

+ Inheritance diagram for SurfaceReconstructionGPU:

Detailed Description

GPU-accelerated volumetric surface reconstruction from RGB-D data.

This class implements a dense or hashed volumetric fusion algorithm for reconstructing surfaces from depth and color images. It uses OpenCL for parallel processing and supports integration, pose tracking, mesh extraction, and volume management.

Usage:

Important aspects:

  • Supports both dense and hashed volume representations.
  • Error codes from addFrame() and other methods provide detailed feedback.
  • Mesh and volume ownership is transferred to the caller.
  • Not thread-safe.

Example:

reco.init(data);
reco.addFrame(depthImg, colorImg, sensorId, nullptr, &pose);
// some more adding of frames
auto mesh = reco.getMesh();
reco.cleanup();
int addFrame(const TypedImage< float > *imgDepth, const TypedImage< unsigned char > *imgColor, int sensor, const TypedImage< float > *imgDepthToColorMap=0, mat4 *T=0, bool poseHint=false, TypedImage< unsigned char > *imgScene=0, bool updateVolume=true, mat4 *sensorT=0, bool forceFirstFrame=false, bool ortho=false, int *icpMatches=nullptr, bool *isKeyframe=nullptr, double *timestamp=nullptr, const TypedImage< unsigned char > *mask=nullptr)
Adds a frame to the reconstruction.
void cleanup()
Cleans up all reconstruction data and resources.
bool init(SurfaceReconstructionData &data)
Initializes the object based on reconstruction parameters.
SurfaceReconstructionGPU(ClEnvironment *env=nullptr)
Constructs the surface reconstruction object.
void resetReconstruction()
Resets the reconstruction volume. All other settings are left unchanged.
std::unique_ptr< Mesh > getMesh() const override
Retrieves the reconstructed mesh. Ownership is transferred to the caller.

Public Member Functions

 SurfaceReconstructionGPU (ClEnvironment *env=nullptr)
 Constructs the surface reconstruction object.
 
 ~SurfaceReconstructionGPU ()
 Destructor.
 
bool init (SurfaceReconstructionData &data)
 Initializes the object based on reconstruction parameters.
 
bool initialized () const
 Returns true if the surface reconstruction object is initialized and ready for use.
 
void cleanup ()
 Cleans up all reconstruction data and resources.
 
int addFrame (const TypedImage< float > *imgDepth, const TypedImage< unsigned char > *imgColor, int sensor, const TypedImage< float > *imgDepthToColorMap=0, mat4 *T=0, bool poseHint=false, TypedImage< unsigned char > *imgScene=0, bool updateVolume=true, mat4 *sensorT=0, bool forceFirstFrame=false, bool ortho=false, int *icpMatches=nullptr, bool *isKeyframe=nullptr, double *timestamp=nullptr, const TypedImage< unsigned char > *mask=nullptr)
 Adds a frame to the reconstruction.
 
mat4f currentPose () const
 Returns the current pose (world to camera).
 
void setCurrentPose (const mat4f &T)
 Sets the current pose.
 
const ClImagegetVolume () const
 Returns the reconstruction volume as an OpenCL buffer (TSDF).
 
const ClImagegetColorVolume () const
 Returns the reconstruction color volume as an OpenCL buffer.
 
const ClImagegetWeightVolume () const
 Returns the reconstruction weight volume as an OpenCL buffer.
 
void resetReconstruction ()
 Resets the reconstruction volume. All other settings are left unchanged.
 
void detachVolumes (ClImage *&tsdf, ClImage *&color, ClImage *&weights)
 Detaches TSDF and color volume.
 
std::unique_ptr< MeshgetMesh () const override
 Retrieves the reconstructed mesh. Ownership is transferred to the caller.
 
void stopReconstruction () override
 Stops all reconstruction threads.
 
- Public Member Functions inherited from SurfaceReconstruction
virtual ~SurfaceReconstruction ()
 Virtual destructor.
 

Constructor & Destructor Documentation

◆ SurfaceReconstructionGPU()

Constructs the surface reconstruction object.

Parameters
envPointer to OpenCL environment to use. If not provided, the default environment is used.
Exceptions
std::runtime_errorif the OpenCL context could not be initialized.

Member Function Documentation

◆ init()

bool init ( SurfaceReconstructionData & data)
virtual

Initializes the object based on reconstruction parameters.

Parameters
[out]dataReconstruction parameters.
Returns
True when initialization succeeded, false otherwise.

Implements SurfaceReconstruction.

◆ cleanup()

void cleanup ( )
virtual

Cleans up all reconstruction data and resources.

Implements SurfaceReconstruction.

◆ addFrame()

int addFrame ( const TypedImage< float > * imgDepth,
const TypedImage< unsigned char > * imgColor,
int sensor,
const TypedImage< float > * imgDepthToColorMap = 0,
mat4 * T = 0,
bool poseHint = false,
TypedImage< unsigned char > * imgScene = 0,
bool updateVolume = true,
mat4 * sensorT = 0,
bool forceFirstFrame = false,
bool ortho = false,
int * icpMatches = nullptr,
bool * isKeyframe = nullptr,
double * timestamp = nullptr,
const TypedImage< unsigned char > * mask = nullptr )
virtual

Adds a frame to the reconstruction.

Parameters
imgDepthDepth map.
imgColorRGB color image.
sensorSensor index.
imgDepthToColorMapDepth-to-color mapping.
TPose.
poseHintIf true, parameter T is used as the initial pose estimate and refined using ICP. If false, T is used as ground-truth pose.
[out]imgSceneRendered reconstruction volume from current viewpoint (4 channel image).
updateVolumeIf true, volume is updated.
sensorTSensor transformation.
forceFirstFrameIf true, forces integration of first frame.
orthoIf true, uses orthographic projection for rendering imgScene.
[out]icpMatchesNumber of ICP matches.
[out]isKeyframeTrue if frame is a keyframe.
timestampFrame timestamp.
maskMask image.
Returns
Error code: 0: No error. Frame was added. 1: No error. Frame was not added. -1: Invalid OpenCL context. -2: Invalid input. -3: Preprocessing failed. -4: Surface prediction failed. -5: ICP failed. -6: Volume integration failed. -7: Could not download reduction results. -8: Could not update image mapping.

Implements SurfaceReconstruction.

◆ currentPose()

mat4f currentPose ( ) const
inlinevirtual

Returns the current pose (world to camera).

Returns
Current pose.

Implements SurfaceReconstruction.

◆ setCurrentPose()

void setCurrentPose ( const mat4f & T)
inlinevirtual

Sets the current pose.

Don't use from different thread.

Parameters
TCurrent pose.

Implements SurfaceReconstruction.

◆ getVolume()

const ClImage * getVolume ( ) const

Returns the reconstruction volume as an OpenCL buffer (TSDF).

Note: only experimental implementation for hashed representation, use getMesh directly.

◆ getColorVolume()

const ClImage * getColorVolume ( ) const
inline

Returns the reconstruction color volume as an OpenCL buffer.

Note: for the hashed representation getVolume() needs to be executed first.

◆ resetReconstruction()

void resetReconstruction ( )
virtual

Resets the reconstruction volume. All other settings are left unchanged.

Implements SurfaceReconstruction.

◆ detachVolumes()

void detachVolumes ( ClImage *& tsdf,
ClImage *& color,
ClImage *& weights )

Detaches TSDF and color volume.

It is the caller's responsibility to release the buffers. After this call, addFrame will not succeed until initBuffers is called again. (Note: for the hashed representation getVolume() needs to be executed first.)

◆ getMesh()

std::unique_ptr< Mesh > getMesh ( ) const
overridevirtual

Retrieves the reconstructed mesh. Ownership is transferred to the caller.

Implements SurfaceReconstruction.

◆ stopReconstruction()

void stopReconstruction ( )
overridevirtual

Stops all reconstruction threads.

Implements SurfaceReconstruction.


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