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,
124 tmp_inliers_ = source.tmp_inliers_;
136 Eigen::VectorXf &model_coefficients);
144 std::vector<double> &distances);
153 const double threshold,
154 std::vector<int> &inliers);
164 const double threshold);
174 const Eigen::VectorXf &model_coefficients,
175 Eigen::VectorXf &optimized_coefficients);
186 const Eigen::VectorXf &model_coefficients,
187 PointCloud &projected_points,
188 bool copy_data_fields =
true);
197 const Eigen::VectorXf &model_coefficients,
198 const double threshold);
233 const std::vector<int> *tmp_inliers_;
235 #if defined BUILD_Maintainer && defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ > 3 236 #pragma GCC diagnostic ignored "-Weffc++" 254 operator() (
const Eigen::VectorXf &x, Eigen::VectorXf &fvec)
const 256 Eigen::Vector4f cen_t;
258 for (
int i = 0; i < values (); ++i)
261 cen_t[0] = model_->input_->points[(*model_->tmp_inliers_)[i]].x - x[0];
262 cen_t[1] = model_->input_->points[(*model_->tmp_inliers_)[i]].y - x[1];
263 cen_t[2] = model_->input_->points[(*model_->tmp_inliers_)[i]].z - x[2];
266 fvec[i] = std::sqrt (cen_t.dot (cen_t)) - x[3];
273 #if defined BUILD_Maintainer && defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ > 3 274 #pragma GCC diagnostic warning "-Weffc++" 279 #ifdef PCL_NO_PRECOMPILE 280 #include <pcl/sample_consensus/impl/sac_model_sphere.hpp> 283 #endif //#ifndef PCL_SAMPLE_CONSENSUS_MODEL_SPHERE_H_ bool isSampleGood(const std::vector< int > &samples) const
Check if a sample of indices results in a good sample of points indices.
double radius_min_
The minimum and maximum radius limits for the model.
virtual ~SampleConsensusModelSphere()
Empty destructor.
void optimizeModelCoefficients(const std::vector< int > &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients)
Recompute the sphere coefficients using the given inlier set and return them to the user...
boost::shared_ptr< SampleConsensusModelSphere > Ptr
unsigned int model_size_
The number of coefficients in the model.
Base functor all the models that need non linear optimization must define their own one and implement...
void projectPoints(const std::vector< int > &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields=true)
Create a new point cloud with inliers projected onto the sphere model.
SampleConsensusModel< PointT >::PointCloud PointCloud
virtual bool isModelValid(const Eigen::VectorXf &model_coefficients)
Check whether a model is valid given the user constraints.
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.
pcl::PointCloud< PointT >::Ptr PointCloudPtr
virtual int countWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold)
Count all the points which respect the given model coefficients as inliers.
pcl::SacModel getModelType() const
Return an unique id for this model (SACMODEL_SPHERE).
SampleConsensusModelSphere & operator=(const SampleConsensusModelSphere &source)
Copy constructor.
SampleConsensusModelSphere(const PointCloudConstPtr &cloud, bool random=false)
Constructor for base SampleConsensusModelSphere.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
pcl::PointCloud< PointT >::ConstPtr PointCloudConstPtr
bool computeModelCoefficients(const std::vector< int > &samples, Eigen::VectorXf &model_coefficients)
Check whether the given index samples can form a valid sphere model, compute the model coefficients f...
bool doSamplesVerifyModel(const std::set< int > &indices, const Eigen::VectorXf &model_coefficients, const double threshold)
Verify whether a subset of indices verifies the given sphere model coefficients.
void getDistancesToModel(const Eigen::VectorXf &model_coefficients, std::vector< double > &distances)
Compute all distances from the cloud data to a given sphere model.
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.
SampleConsensusModelSphere defines a model for 3D sphere segmentation.
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.