A Sample Consensus Model class for cylinder segmentation. More...
#include <sac_model_cylinder.h>
Public Member Functions | |
virtual bool | computeModelCoefficients (const std::vector< int > &samples) |
Check whether the given index samples can form a valid cylinder model, compute the model coefficients from these samples and store them internally in model_coefficients_. The cylinder coefficients are: x, y, z, R. | |
virtual bool | doSamplesVerifyModel (const std::set< int > &indices, double threshold) |
Verify whether a subset of indices verifies the internal cylinder model coefficients. | |
virtual void | getDistancesToModel (const std::vector< double > &model_coefficients, std::vector< double > &distances) |
Compute all distances from the cloud data to a given cylinder model. | |
virtual int | getModelType () |
Return an unique id for this model (SACMODEL_CYLINDER). | |
virtual void | getSamples (int &iterations, std::vector< int > &samples) |
Get 4 random points (3 non-collinear) as data samples and return them as point indices. | |
virtual void | projectPoints (const std::vector< int > &inliers, const std::vector< double > &model_coefficients, sensor_msgs::PointCloud &projected_points) |
Create a new point cloud with inliers projected onto the cylinder model. | |
virtual void | projectPointsInPlace (const std::vector< int > &inliers, const std::vector< double > &model_coefficients) |
Project inliers (in place) onto the given cylinder model. | |
virtual void | refitModel (const std::vector< int > &inliers, std::vector< double > &refit_coefficients) |
Recompute the cylinder coefficients using the given inlier set and return them to the user. | |
SACModelCylinder () | |
Constructor for base SACModelCylinder. | |
virtual void | selectWithinDistance (const std::vector< double > &model_coefficients, double threshold, std::vector< int > &inliers) |
Select all the points which respect the given model coefficients as inliers. | |
bool | testModelCoefficients (const std::vector< double > &model_coefficients) |
Test whether the given model coefficients are valid given the input point cloud data. | |
virtual | ~SACModelCylinder () |
Destructor for base SACModelCylinder. | |
Static Public Member Functions | |
static int | functionToOptimize (void *p, int m, int n, const double *x, double *fvec, int iflag) |
Cost function to be minimized. | |
Private Attributes | |
int | nx_idx_ |
The coordinates of point normals in the dataset. | |
int | ny_idx_ |
int | nz_idx_ |
const std::vector< int > * | tmp_inliers_ |
temporary pointer to a list of given indices for refitModel () |
A Sample Consensus Model class for cylinder segmentation.
Definition at line 46 of file sac_model_cylinder.h.
sample_consensus::SACModelCylinder::SACModelCylinder | ( | ) | [inline] |
Constructor for base SACModelCylinder.
Definition at line 51 of file sac_model_cylinder.h.
virtual sample_consensus::SACModelCylinder::~SACModelCylinder | ( | ) | [inline, virtual] |
Destructor for base SACModelCylinder.
Definition at line 55 of file sac_model_cylinder.h.
bool sample_consensus::SACModelCylinder::computeModelCoefficients | ( | const std::vector< int > & | samples | ) | [virtual] |
Check whether the given index samples can form a valid cylinder model, compute the model coefficients from these samples and store them internally in model_coefficients_. The cylinder coefficients are: x, y, z, R.
samples | the point indices found as possible good candidates for creating a valid model |
Implements sample_consensus::SACModel.
Definition at line 197 of file sac_model_cylinder.cpp.
bool sample_consensus::SACModelCylinder::doSamplesVerifyModel | ( | const std::set< int > & | indices, | |
double | threshold | |||
) | [virtual] |
Verify whether a subset of indices verifies the internal cylinder model coefficients.
indices | the data indices that need to be tested against the cylinder model | |
threshold | a maximum admissible distance threshold for determining the inliers from the outliers |
Implements sample_consensus::SACModel.
Definition at line 362 of file sac_model_cylinder.cpp.
int sample_consensus::SACModelCylinder::functionToOptimize | ( | void * | p, | |
int | m, | |||
int | n, | |||
const double * | x, | |||
double * | fvec, | |||
int | iflag | |||
) | [static] |
Cost function to be minimized.
p | a pointer to our data structure array | |
m | the number of functions | |
n | the number of variables | |
x | a pointer to the variables array | |
fvec | a pointer to the resultant functions evaluations | |
iflag | set to -1 inside the function to terminate execution |
Definition at line 341 of file sac_model_cylinder.cpp.
void sample_consensus::SACModelCylinder::getDistancesToModel | ( | const std::vector< double > & | model_coefficients, | |
std::vector< double > & | distances | |||
) | [virtual] |
Compute all distances from the cloud data to a given cylinder model.
model_coefficients | the coefficients of a cylinder model that we need to compute distances to | |
distances | the resultant estimated distances |
Implements sample_consensus::SACModel.
Definition at line 151 of file sac_model_cylinder.cpp.
virtual int sample_consensus::SACModelCylinder::getModelType | ( | ) | [inline, virtual] |
Return an unique id for this model (SACMODEL_CYLINDER).
Implements sample_consensus::SACModel.
Definition at line 81 of file sac_model_cylinder.h.
void sample_consensus::SACModelCylinder::getSamples | ( | int & | iterations, | |
std::vector< int > & | samples | |||
) | [virtual] |
Get 4 random points (3 non-collinear) as data samples and return them as point indices.
iterations | the internal number of iterations used by SAC methods | |
samples | the resultant model samples |
Implements sample_consensus::SACModel.
Definition at line 43 of file sac_model_cylinder.cpp.
void sample_consensus::SACModelCylinder::projectPoints | ( | const std::vector< int > & | inliers, | |
const std::vector< double > & | model_coefficients, | |||
sensor_msgs::PointCloud & | projected_points | |||
) | [virtual] |
Create a new point cloud with inliers projected onto the cylinder model.
inliers | the data inliers that we want to project on the cylinder model | |
model_coefficients | the coefficients of a cylinder model | |
projected_points | the resultant projected points |
Implements sample_consensus::SACModel.
Definition at line 172 of file sac_model_cylinder.cpp.
void sample_consensus::SACModelCylinder::projectPointsInPlace | ( | const std::vector< int > & | inliers, | |
const std::vector< double > & | model_coefficients | |||
) | [virtual] |
Project inliers (in place) onto the given cylinder model.
inliers | the data inliers that we want to project on the cylinder model | |
model_coefficients | the coefficients of a cylinder model |
Implements sample_consensus::SACModel.
Definition at line 186 of file sac_model_cylinder.cpp.
void sample_consensus::SACModelCylinder::refitModel | ( | const std::vector< int > & | inliers, | |
std::vector< double > & | refit_coefficients | |||
) | [virtual] |
Recompute the cylinder coefficients using the given inlier set and return them to the user.
inliers | the data inliers found as supporting the model | |
refit_coefficients | the resultant recomputed coefficients after non-linear optimization |
Implements sample_consensus::SACModel.
Definition at line 281 of file sac_model_cylinder.cpp.
void sample_consensus::SACModelCylinder::selectWithinDistance | ( | const std::vector< double > & | model_coefficients, | |
double | threshold, | |||
std::vector< int > & | inliers | |||
) | [virtual] |
Select all the points which respect the given model coefficients as inliers.
model_coefficients | the coefficients of a cylinder model that we need to compute distances to | |
threshold | a maximum admissible distance threshold for determining the inliers from the outliers | |
inliers | the resultant model inliers |
Implements sample_consensus::SACModel.
Definition at line 120 of file sac_model_cylinder.cpp.
bool sample_consensus::SACModelCylinder::testModelCoefficients | ( | const std::vector< double > & | model_coefficients | ) | [inline, virtual] |
Test whether the given model coefficients are valid given the input point cloud data.
model_coefficients | the model coefficients that need to be tested |
Implements sample_consensus::SACModel.
Definition at line 64 of file sac_model_cylinder.h.
int sample_consensus::SACModelCylinder::nx_idx_ [private] |
The coordinates of point normals in the dataset.
Definition at line 85 of file sac_model_cylinder.h.
int sample_consensus::SACModelCylinder::ny_idx_ [private] |
Definition at line 85 of file sac_model_cylinder.h.
int sample_consensus::SACModelCylinder::nz_idx_ [private] |
Definition at line 85 of file sac_model_cylinder.h.
const std::vector<int>* sample_consensus::SACModelCylinder::tmp_inliers_ [private] |
temporary pointer to a list of given indices for refitModel ()
Definition at line 87 of file sac_model_cylinder.h.