33 #ifndef _SAMPLE_CONSENSUS_SAC_H_ 34 #define _SAMPLE_CONSENSUS_SAC_H_ 37 #include <pcl/point_types.h> 127 virtual std::vector<int>
163 std::set<int> random_idx;
164 for (
int i = 0; i < nr_samples; i++)
165 random_idx.insert ((
int) (points.points.size () * (rand () / (RAND_MAX + 1.0))));
180 std::set<int> random_idx;
181 for (
int i = 0; i < nr_samples; i++)
182 random_idx.insert ((
int) (indices.size () * (rand () / (RAND_MAX + 1.0))));
virtual int removeInliers()
Remove the inliers found from the initial set of given point indices.
std::set< int > getRandomSamples(PointCloud points, std::vector< int > indices, int nr_samples)
Get a vector of randomly selected indices.
std::set< int > getRandomSamples(PointCloud points, int nr_samples)
Get a set of randomly selected indices.
std::vector< int > getBestInliers()
Return the best set of inliers found so far for this model.
SAC()
Constructor for base SAC.
pcl::PointCloud< pcl::PointXYZ > PointCloud
int max_iterations_
Maximum number of iterations before giving up.
virtual void computeCoefficients(std::vector< double > &coefficients)
Compute the coefficients of the model and return them.
virtual void projectPoints(const std::vector< int > &inliers, const std::vector< double > &model_coefficients, PointCloud &projected_points)=0
Create a new point cloud with inliers projected onto the model. Pure virtual.
double threshold_
Distance to model threshold.
virtual void setProbability(double probability)
Set the desired probability of choosing at least one sample free from outliers.
PointCloud getPointCloud(std::vector< int > indices)
Return the point cloud representing a set of given indices.
virtual bool computeModelCoefficients(const std::vector< int > &samples)=0
Check whether the given index samples can form a valid model, compute the model coefficients from the...
SACModel * sac_model_
The underlying data model used (i.e. what is it that we attempt to search for).
std::vector< int > getBestModel()
Return the best model found so far.
SAC(SACModel *model)
Constructor for base SAC.
virtual void setMaxIterations(int max_iterations)
Set the maximum number of iterations.
int iterations_
Total number of internal loop iterations that we've done so far.
virtual bool computeModel(int debug=0)=0
Compute the actual model. Pure virtual.
virtual int removeInliers()
Remove the model inliers from the list of data indices. Returns the number of indices left...
virtual void refitModel(const std::vector< int > &inliers, std::vector< double > &refit_coefficients)=0
Recompute the model coefficients using the given inlier set and return them to the user...
virtual void refineCoefficients(std::vector< double > &refined_coefficients)
Use Least-Squares optimizations to refine the coefficients of the model, and return them...
virtual void projectPointsToModel(const std::vector< int > &indices, const std::vector< double > &model_coefficients, PointCloud &projected_points)
Project a set of given points (using their indices) onto the model and return their projections...
virtual std::vector< int > getInliers()
Get a list of the model inliers, found after computeModel ()
virtual void setThreshold(double threshold)
Set the threshold to model.
double probability_
Desired probability of choosing at least one sample free from outliers.
std::vector< double > getModelCoefficients()
Return the model coefficients of the best model found so far.
virtual ~SAC()
Destructor for base SAC.