Image Component Library (ICL)
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
icl::geom::PlanarRansacEstimator Class Reference

class for planar RANSAC estimation on poincloud data (xyzh). More...

#include <PlanarRansacEstimator.h>

Classes

struct  Result
 

Public Types

enum  Mode { BEST, GPU, CPU }
 
enum  OptimizationCriterion { MAX_ON =1, ON_ONE_SIDE =2 }
 

Public Member Functions

 PlanarRansacEstimator (Mode mode=BEST)
 Constructor. More...
 
 ~PlanarRansacEstimator ()
 Destructor. More...
 
Result apply (core::DataSegment< float, 4 > &xyzh, std::vector< int > &srcIDs, std::vector< int > &dstIDs, float threshold, int passes, int subset, int tolerance, int optimization)
 Applies the planar RANSAC estimation on a destination region with a model from the src region (e.g. for best fitting plane src=dst). More...
 
Result apply (std::vector< Vec > &srcPoints, std::vector< Vec > &dstPoints, float threshold, int passes, int subset, int tolerance, int optimization)
 Applies the planar RANSAC estimation on a destination region with a model from the src region (e.g. for best fitting plane src=dst). More...
 
math::DynMatrix< Resultapply (core::DataSegment< float, 4 > &xyzh, std::vector< std::vector< int > > &pointIDs, math::DynMatrix< bool > &testMatrix, float threshold, int passes, int tolerance, int optimization, core::Img32s labelImage)
 Applies the planar RANSAC estimation on multiple pairs of surfaces (given by a boolean test matrix). More...
 
void relabel (core::DataSegment< float, 4 > &xyzh, core::Img8u &newMask, core::Img32s &oldLabel, core::Img32s &newLabel, int desiredID, int srcID, float threshold, Result &result)
 Create a label image of all points on the planar model (incl. the original surface) More...
 

Static Public Member Functions

static void calculateRandomModels (std::vector< Vec > &srcPoints, std::vector< Vec > &n0, std::vector< float > &dist, int passes)
 Creates random models (n and distance) for RANSAC. More...
 
static void calculateRandomModels (core::DataSegment< float, 4 > &xyzh, std::vector< int > &srcPoints, std::vector< Vec > &n0, std::vector< float > &dist, int passes)
 Creates random models (n and distance) for RANSAC. More...
 

Private Member Functions

void calculateMultiCL (core::DataSegment< float, 4 > &xyzh, core::Img32s labelImage, math::DynMatrix< bool > &testMatrix, float threshold, int passes, std::vector< Vec > &n0, std::vector< float > &dist, std::vector< int > &cAbove, std::vector< int > &cBelow, std::vector< int > &cOn, std::vector< int > &adjs, std::vector< int > &start, std::vector< int > &end)
 
void calculateMultiCPU (core::DataSegment< float, 4 > &xyzh, std::vector< std::vector< int > > &pointIDs, math::DynMatrix< bool > &testMatrix, float threshold, int passes, std::vector< std::vector< Vec > > &n0Pre, std::vector< std::vector< float > > &distPre, std::vector< int > &cAbove, std::vector< int > &cBelow, std::vector< int > &cOn, std::vector< int > &adjs, std::vector< int > &start, std::vector< int > &end)
 
void calculateSingleCL (std::vector< Vec > &dstPoints, float threshold, int passes, int subset, std::vector< Vec > &n0, std::vector< float > &dist, std::vector< int > &cAbove, std::vector< int > &cBelow, std::vector< int > &cOn)
 
void calculateSingleCPU (std::vector< Vec > &dstPoints, float threshold, int passes, int subset, std::vector< Vec > &n0, std::vector< float > &dist, std::vector< int > &cAbove, std::vector< int > &cBelow, std::vector< int > &cOn)
 
void initOpenCL ()
 
Result createResult (std::vector< Vec > &n0, std::vector< float > &dist, std::vector< int > &cAbove, std::vector< int > &cBelow, std::vector< int > &cOn, float threshold, int passes, int tolerance, int optimization, int numPoints)
 
math::DynMatrix< ResultcreateResultMatrix (math::DynMatrix< bool > &testMatrix, std::vector< int > &start, std::vector< int > &end, std::vector< int > &adjs, std::vector< int > &cAbove, std::vector< int > &cBelow, std::vector< int > &cOn, std::vector< std::vector< int > > &pointIDs, std::vector< std::vector< Vec > > &n0Pre, std::vector< std::vector< float > > &distPre, float threshold, int passes, int tolerance, int optimization)
 
void relabelCL (core::DataSegment< float, 4 > &xyzh, core::Img8u &newMask, core::Img32s &oldLabel, core::Img32s &newLabel, int desiredID, int srcID, float threshold, Result &result, int w, int h)
 
void relabelCPU (core::DataSegment< float, 4 > &xyzh, core::Img8u &newMask, core::Img32s &oldLabel, core::Img32s &newLabel, int desiredID, int srcID, float threshold, Result &result, int w, int h)
 

Static Private Member Functions

static void calculateModel (Vec &fa, Vec &fb, Vec &rPoint, Vec &n0, float &dist)
 

Private Attributes

Data * m_data
 internal data type More...
 

Detailed Description

class for planar RANSAC estimation on poincloud data (xyzh).

The PlanarRansacEstimator class does not minimize the error but simply counts the points with a distance smaller a given threshold. The smaller the threshold the preciser the model. Additionally, it is possible to assign all points on the plane to the initial surface.

Member Enumeration Documentation

◆ Mode

Enumerator
BEST 
GPU 
CPU 

◆ OptimizationCriterion

Enumerator
MAX_ON 
ON_ONE_SIDE 

Constructor & Destructor Documentation

◆ PlanarRansacEstimator()

icl::geom::PlanarRansacEstimator::PlanarRansacEstimator ( Mode  mode = BEST)

Constructor.

Constructs an object of this class.

Parameters
modethe selected mode: CPU, GPU or BEST (uses GPU if available)

◆ ~PlanarRansacEstimator()

icl::geom::PlanarRansacEstimator::~PlanarRansacEstimator ( )

Destructor.

Member Function Documentation

◆ apply() [1/3]

Result icl::geom::PlanarRansacEstimator::apply ( core::DataSegment< float, 4 > &  xyzh,
std::vector< int > &  srcIDs,
std::vector< int > &  dstIDs,
float  threshold,
int  passes,
int  subset,
int  tolerance,
int  optimization 
)

Applies the planar RANSAC estimation on a destination region with a model from the src region (e.g. for best fitting plane src=dst).

Parameters
xyzhthe input xyzh from the pointcloud
srcIDsvector of IDs (pointcloud position – for structured x+y*w) of the source surface (for model determination)
dstIDsvector of IDs of the destination surface (for matching)
thresholdthe maximal euclidean distance in mm
passesnumber of ransac passes
subsetthe subset of points for matching (2 means every second point)
tolerancenumber of points allowed not to be on one single side of the object for ON_ONE_SIDE
optimizationthe optimization criterion (ON_ONE_SIDE e.g. for cutfree adjacency test or MAX_ON e.g. for best fitting plane)
Returns
the Result struct.

◆ apply() [2/3]

Result icl::geom::PlanarRansacEstimator::apply ( std::vector< Vec > &  srcPoints,
std::vector< Vec > &  dstPoints,
float  threshold,
int  passes,
int  subset,
int  tolerance,
int  optimization 
)

Applies the planar RANSAC estimation on a destination region with a model from the src region (e.g. for best fitting plane src=dst).

Parameters
xyzhthe input xyzh from the pointcloud
srcPointsvector of pointcloud points of the source surface (for model determination)
dstIDsvector of pointcloud points of the destination surface (for matching)
thresholdthe maximal euclidean distance in mm
passesnumber of ransac passes
subsetthe subset of points for matching (2 means every second point)
tolerancenumber of points allowed not to be on one single side of the object for ON_ONE_SIDE
optimizationthe optimization criterion (ON_ONE_SIDE e.g. for cutfree adjacency test or MAX_ON e.g. for best fitting plane)
Returns
the Result struct.

◆ apply() [3/3]

math::DynMatrix<Result> icl::geom::PlanarRansacEstimator::apply ( core::DataSegment< float, 4 > &  xyzh,
std::vector< std::vector< int > > &  pointIDs,
math::DynMatrix< bool > &  testMatrix,
float  threshold,
int  passes,
int  tolerance,
int  optimization,
core::Img32s  labelImage 
)

Applies the planar RANSAC estimation on multiple pairs of surfaces (given by a boolean test matrix).

Parameters
xyzhthe input xyzh from the pointcloud
pointsIDsvector (surfaces) of vector IDs (pointcloud position – for structured x+y*w) of the surfaces
testMatrixboolean matrix for surface pair testing (1 = test, 0 = dont test)
thresholdthe maximal euclidean distance in mm
passesnumber of ransac passes
tolerancenumber of points allowed not to be on one single side of the object for ON_ONE_SIDE
optimizationthe optimization criterion (ON_ONE_SIDE e.g. for cutfree adjacency test or MAX_ON e.g. for best fitting plane)
labelImagethe labelImage with the point label
Returns
matrix of Result structs.

◆ calculateModel()

static void icl::geom::PlanarRansacEstimator::calculateModel ( Vec fa,
Vec fb,
Vec rPoint,
Vec n0,
float &  dist 
)
staticprivate

◆ calculateMultiCL()

void icl::geom::PlanarRansacEstimator::calculateMultiCL ( core::DataSegment< float, 4 > &  xyzh,
core::Img32s  labelImage,
math::DynMatrix< bool > &  testMatrix,
float  threshold,
int  passes,
std::vector< Vec > &  n0,
std::vector< float > &  dist,
std::vector< int > &  cAbove,
std::vector< int > &  cBelow,
std::vector< int > &  cOn,
std::vector< int > &  adjs,
std::vector< int > &  start,
std::vector< int > &  end 
)
private

◆ calculateMultiCPU()

void icl::geom::PlanarRansacEstimator::calculateMultiCPU ( core::DataSegment< float, 4 > &  xyzh,
std::vector< std::vector< int > > &  pointIDs,
math::DynMatrix< bool > &  testMatrix,
float  threshold,
int  passes,
std::vector< std::vector< Vec > > &  n0Pre,
std::vector< std::vector< float > > &  distPre,
std::vector< int > &  cAbove,
std::vector< int > &  cBelow,
std::vector< int > &  cOn,
std::vector< int > &  adjs,
std::vector< int > &  start,
std::vector< int > &  end 
)
private

◆ calculateRandomModels() [1/2]

static void icl::geom::PlanarRansacEstimator::calculateRandomModels ( std::vector< Vec > &  srcPoints,
std::vector< Vec > &  n0,
std::vector< float > &  dist,
int  passes 
)
static

Creates random models (n and distance) for RANSAC.

Parameters
srcPointsthe input points
n0the empty input n0 vector
distthe empty input distance vector
passesthe number of passes

◆ calculateRandomModels() [2/2]

static void icl::geom::PlanarRansacEstimator::calculateRandomModels ( core::DataSegment< float, 4 > &  xyzh,
std::vector< int > &  srcPoints,
std::vector< Vec > &  n0,
std::vector< float > &  dist,
int  passes 
)
static

Creates random models (n and distance) for RANSAC.

Parameters
xyzhthe input xyz pointcloud data
srcPointsthe sourcePoint Ids
n0the empty input n0 vector
distthe empty input distance vector
passesthe number of passes

◆ calculateSingleCL()

void icl::geom::PlanarRansacEstimator::calculateSingleCL ( std::vector< Vec > &  dstPoints,
float  threshold,
int  passes,
int  subset,
std::vector< Vec > &  n0,
std::vector< float > &  dist,
std::vector< int > &  cAbove,
std::vector< int > &  cBelow,
std::vector< int > &  cOn 
)
private

◆ calculateSingleCPU()

void icl::geom::PlanarRansacEstimator::calculateSingleCPU ( std::vector< Vec > &  dstPoints,
float  threshold,
int  passes,
int  subset,
std::vector< Vec > &  n0,
std::vector< float > &  dist,
std::vector< int > &  cAbove,
std::vector< int > &  cBelow,
std::vector< int > &  cOn 
)
private

◆ createResult()

Result icl::geom::PlanarRansacEstimator::createResult ( std::vector< Vec > &  n0,
std::vector< float > &  dist,
std::vector< int > &  cAbove,
std::vector< int > &  cBelow,
std::vector< int > &  cOn,
float  threshold,
int  passes,
int  tolerance,
int  optimization,
int  numPoints 
)
private

◆ createResultMatrix()

math::DynMatrix<Result> icl::geom::PlanarRansacEstimator::createResultMatrix ( math::DynMatrix< bool > &  testMatrix,
std::vector< int > &  start,
std::vector< int > &  end,
std::vector< int > &  adjs,
std::vector< int > &  cAbove,
std::vector< int > &  cBelow,
std::vector< int > &  cOn,
std::vector< std::vector< int > > &  pointIDs,
std::vector< std::vector< Vec > > &  n0Pre,
std::vector< std::vector< float > > &  distPre,
float  threshold,
int  passes,
int  tolerance,
int  optimization 
)
private

◆ initOpenCL()

void icl::geom::PlanarRansacEstimator::initOpenCL ( )
private

◆ relabel()

void icl::geom::PlanarRansacEstimator::relabel ( core::DataSegment< float, 4 > &  xyzh,
core::Img8u newMask,
core::Img32s oldLabel,
core::Img32s newLabel,
int  desiredID,
int  srcID,
float  threshold,
Result result 
)

Create a label image of all points on the planar model (incl. the original surface)

Parameters
xyzhthe input xyzh from the pointcloud
newMaskthe mask (e.g. ROI) for the relabeling
oldLabelthe original label image
newLabelthe resulting label image with all points on the model
desiredIDthe id in the resulting label image
srcIDthe ID of the label image from the fitted surface
thresholdthe maximum euclidean distance for relabeling
resultthe result struct returned by apply (contains the model and the original surface ID)

◆ relabelCL()

void icl::geom::PlanarRansacEstimator::relabelCL ( core::DataSegment< float, 4 > &  xyzh,
core::Img8u newMask,
core::Img32s oldLabel,
core::Img32s newLabel,
int  desiredID,
int  srcID,
float  threshold,
Result result,
int  w,
int  h 
)
private

◆ relabelCPU()

void icl::geom::PlanarRansacEstimator::relabelCPU ( core::DataSegment< float, 4 > &  xyzh,
core::Img8u newMask,
core::Img32s oldLabel,
core::Img32s newLabel,
int  desiredID,
int  srcID,
float  threshold,
Result result,
int  w,
int  h 
)
private

Member Data Documentation

◆ m_data

Data* icl::geom::PlanarRansacEstimator::m_data
private

internal data type

internal data pointer


The documentation for this class was generated from the following file: