43 #include <pcl/sample_consensus/sac_model.h>
44 #include <pcl/sample_consensus/model_types.h>
58 template <
typename Po
intT>
73 using Ptr = shared_ptr<SampleConsensusModelSphere<PointT> >;
74 using ConstPtr = shared_ptr<const SampleConsensusModelSphere<PointT>>;
95 const Indices &indices,
135 Eigen::VectorXf &model_coefficients)
const override;
143 std::vector<double> &distances)
const override;
152 const double threshold,
153 Indices &inliers)
override;
163 const double threshold)
const override;
173 const Eigen::VectorXf &model_coefficients,
174 Eigen::VectorXf &optimized_coefficients)
const override;
185 const Eigen::VectorXf &model_coefficients,
187 bool copy_data_fields =
true)
const override;
196 const Eigen::VectorXf &model_coefficients,
197 const double threshold)
const override;
210 isModelValid (
const Eigen::VectorXf &model_coefficients)
const override
246 operator() (
const Eigen::VectorXf &x, Eigen::VectorXf &fvec)
const
248 Eigen::Vector4f cen_t;
250 for (
int i = 0; i < values (); ++i)
253 cen_t[0] = model_->input_->points[
indices_[i]].x - x[0];
254 cen_t[1] = model_->input_->points[
indices_[i]].y - x[1];
255 cen_t[2] = model_->input_->points[
indices_[i]].z - x[2];
258 fvec[i] = std::sqrt (cen_t.dot (cen_t)) - x[3];
269 #ifdef PCL_NO_PRECOMPILE
270 #include <pcl/sample_consensus/impl/sac_model_sphere.hpp>
double radius_min_
The minimum and maximum radius limits for the model.
void projectPoints(const Indices &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields=true) const override
Create a new point cloud with inliers projected onto the sphere model.
bool isSampleGood(const Indices &samples) const override
Check if a sample of indices results in a good sample of points indices.
void selectWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers) override
Select all the points which respect the given model coefficients as inliers.
DeviceArray< int > Indices
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...
typename PointCloud::Ptr PointCloudPtr
SampleConsensusModel represents the base model class.
std::string model_name_
The model name.
bool doSamplesVerifyModel(const std::set< index_t > &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const override
Verify whether a subset of indices verifies the given sphere model coefficients.
pcl::SacModel getModelType() const override
Return a unique id for this model (SACMODEL_SPHERE).
void optimizeModelCoefficients(const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const override
Recompute the sphere coefficients using the given inlier set and return them to the user...
bool isModelValid(const Eigen::VectorXf &model_coefficients) const override
Check whether a model is valid given the user constraints.
typename PointCloud::ConstPtr PointCloudConstPtr
SampleConsensusModelSphere & operator=(const SampleConsensusModelSphere &source)
Copy constructor.
SampleConsensusModelSphere(const PointCloudConstPtr &cloud, bool random=false)
Constructor for base SampleConsensusModelSphere.
SampleConsensusModelSphere(const PointCloudConstPtr &cloud, const Indices &indices, bool random=false)
Constructor for base SampleConsensusModelSphere.
shared_ptr< const SampleConsensusModel< pcl::PointXYZRGB > > ConstPtr
bool computeModelCoefficients(const Indices &samples, Eigen::VectorXf &model_coefficients) const override
Check whether the given index samples can form a valid sphere model, compute the model coefficients f...
IndicesPtr indices_
A pointer to the vector of point indices to use.
~SampleConsensusModelSphere()
Empty destructor.
A point structure representing Euclidean xyz coordinates, and the RGB color.
shared_ptr< SampleConsensusModel< pcl::PointXYZRGB > > Ptr
std::size_t countWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold) const override
Count all the points which respect the given model coefficients as inliers.
SampleConsensusModelSphere defines a model for 3D sphere segmentation.
unsigned int sample_size_
The size of a sample from which the model is computed.
void getDistancesToModel(const Eigen::VectorXf &model_coefficients, std::vector< double > &distances) const override
Compute all distances from the cloud data to a given sphere model.
SampleConsensusModelSphere(const SampleConsensusModelSphere &source)
Copy constructor.