41 #ifndef PCL_SAMPLE_CONSENSUS_MODEL_SPHERE_H_
42 #define PCL_SAMPLE_CONSENSUS_MODEL_SPHERE_H_
44 #include <pcl/sample_consensus/sac_model.h>
45 #include <pcl/sample_consensus/model_types.h>
59 template <
typename Po
intT>
74 typedef boost::shared_ptr<SampleConsensusModelSphere>
Ptr;
95 const std::vector<int> &indices,
135 Eigen::VectorXf &model_coefficients)
const;
143 std::vector<double> &distances)
const;
152 const double threshold,
153 std::vector<int> &inliers);
163 const double threshold)
const;
173 const Eigen::VectorXf &model_coefficients,
174 Eigen::VectorXf &optimized_coefficients)
const;
185 const Eigen::VectorXf &model_coefficients,
186 PointCloud &projected_points,
187 bool copy_data_fields =
true)
const;
196 const Eigen::VectorXf &model_coefficients,
197 const double threshold)
const;
232 #if defined BUILD_Maintainer && defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ > 3
233 #pragma GCC diagnostic ignored "-Weffc++"
250 operator() (
const Eigen::VectorXf &x, Eigen::VectorXf &fvec)
const
252 Eigen::Vector4f cen_t;
254 for (
int i = 0; i < values (); ++i)
257 cen_t[0] = model_->input_->points[
indices_[i]].x - x[0];
258 cen_t[1] = model_->input_->points[
indices_[i]].y - x[1];
259 cen_t[2] = model_->input_->points[
indices_[i]].z - x[2];
262 fvec[i] = std::sqrt (cen_t.dot (cen_t)) - x[3];
270 #if defined BUILD_Maintainer && defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ > 3
271 #pragma GCC diagnostic warning "-Weffc++"
276 #ifdef PCL_NO_PRECOMPILE
277 #include <pcl/sample_consensus/impl/sac_model_sphere.hpp>
280 #endif //#ifndef PCL_SAMPLE_CONSENSUS_MODEL_SPHERE_H_
bool doSamplesVerifyModel(const std::set< int > &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const
Verify whether a subset of indices verifies the given sphere model coefficients.
double radius_min_
The minimum and maximum radius limits for the model.
virtual ~SampleConsensusModelSphere()
Empty destructor.
This file defines compatibility wrappers for low level I/O functions.
boost::shared_ptr< SampleConsensusModelSphere > Ptr
unsigned int model_size_
The number of coefficients in the model.
void optimizeModelCoefficients(const std::vector< int > &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
Recompute the sphere coefficients using the given inlier set and return them to the user...
Base functor all the models that need non linear optimization must define their own one and implement...
boost::shared_ptr< std::vector< int > > indices_
A pointer to the vector of point indices to use.
SampleConsensusModel< PointT >::PointCloud PointCloud
SampleConsensusModel< PointT >::PointCloudPtr PointCloudPtr
SampleConsensusModel represents the base model class.
SampleConsensusModelSphere(const PointCloudConstPtr &cloud, const std::vector< int > &indices, bool random=false)
Constructor for base SampleConsensusModelSphere.
std::string model_name_
The model name.
bool isSampleGood(const std::vector< int > &samples) const
Check if a sample of indices results in a good sample of points indices.
pcl::PointCloud< PointT >::Ptr PointCloudPtr
virtual bool isModelValid(const Eigen::VectorXf &model_coefficients) const
Check whether a model is valid given the user constraints.
SampleConsensusModelSphere & operator=(const SampleConsensusModelSphere &source)
Copy constructor.
void projectPoints(const std::vector< int > &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields=true) const
Create a new point cloud with inliers projected onto the sphere model.
virtual int countWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold) const
Count all the points which respect the given model coefficients as inliers.
SampleConsensusModelSphere(const PointCloudConstPtr &cloud, bool random=false)
Constructor for base SampleConsensusModelSphere.
pcl::PointCloud< PointT >::ConstPtr PointCloudConstPtr
PointCloud represents the base class in PCL for storing collections of 3D points. ...
pcl::SacModel getModelType() const
Return an unique id for this model (SACMODEL_SPHERE).
void selectWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold, std::vector< int > &inliers)
Select all the points which respect the given model coefficients as inliers.
A point structure representing Euclidean xyz coordinates, and the RGB color.
bool computeModelCoefficients(const std::vector< int > &samples, Eigen::VectorXf &model_coefficients) const
Check whether the given index samples can form a valid sphere model, compute the model coefficients f...
SampleConsensusModelSphere defines a model for 3D sphere segmentation.
void getDistancesToModel(const Eigen::VectorXf &model_coefficients, std::vector< double > &distances) const
Compute all distances from the cloud data to a given sphere model.
SampleConsensusModel< PointT >::PointCloudConstPtr PointCloudConstPtr
unsigned int sample_size_
The size of a sample from which the model is computed.
SampleConsensusModelSphere(const SampleConsensusModelSphere &source)
Copy constructor.