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>
73 typedef boost::shared_ptr<SampleConsensusModelSphere>
Ptr;
90 const std::vector<int> &indices,
114 tmp_inliers_ = source.tmp_inliers_;
126 Eigen::VectorXf &model_coefficients);
134 std::vector<double> &distances);
143 const double threshold,
144 std::vector<int> &inliers);
154 const double threshold);
164 const Eigen::VectorXf &model_coefficients,
165 Eigen::VectorXf &optimized_coefficients);
176 const Eigen::VectorXf &model_coefficients,
177 PointCloud &projected_points,
178 bool copy_data_fields =
true);
187 const Eigen::VectorXf &model_coefficients,
188 const double threshold);
201 if (model_coefficients.size () != 4)
203 PCL_ERROR (
"[pcl::SampleConsensusModelSphere::isModelValid] Invalid number of model coefficients given (%lu)!\n", model_coefficients.size ());
224 const std::vector<int> *tmp_inliers_;
226 #if defined BUILD_Maintainer && defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ > 3 227 #pragma GCC diagnostic ignored "-Weffc++" 245 operator() (
const Eigen::VectorXf &x, Eigen::VectorXf &fvec)
const 247 Eigen::Vector4f cen_t;
249 for (
int i = 0; i < values (); ++i)
252 cen_t[0] = model_->input_->points[(*model_->tmp_inliers_)[i]].x - x[0];
253 cen_t[1] = model_->input_->points[(*model_->tmp_inliers_)[i]].y - x[1];
254 cen_t[2] = model_->input_->points[(*model_->tmp_inliers_)[i]].z - x[2];
257 fvec[i] = sqrtf (cen_t.dot (cen_t)) - x[3];
264 #if defined BUILD_Maintainer && defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ > 3 265 #pragma GCC diagnostic warning "-Weffc++" 270 #ifdef PCL_NO_PRECOMPILE 271 #include <pcl/sample_consensus/impl/sac_model_sphere.hpp> 274 #endif //#ifndef PCL_SAMPLE_CONSENSUS_MODEL_SPHERE_H_ bool isModelValid(const Eigen::VectorXf &model_coefficients)
Check whether a model is valid given the user constraints.
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
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
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.
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 int countWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold)
Count all the points which respect the given model coefficients as inliers.
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...
pcl::SacModel getModelType() const
Return an unique id for this model (SACMODEL_SPHERE).
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
SampleConsensusModelSphere(const SampleConsensusModelSphere &source)
Copy constructor.