38 #ifndef PCL_SAMPLE_CONSENSUS_MODEL_CIRCLE3D_H_
39 #define PCL_SAMPLE_CONSENSUS_MODEL_CIRCLE3D_H_
41 #include <pcl/sample_consensus/sac_model.h>
42 #include <pcl/sample_consensus/model_types.h>
60 template <
typename Po
intT>
74 typedef boost::shared_ptr<SampleConsensusModelCircle3D<PointT> >
Ptr;
75 typedef boost::shared_ptr<const SampleConsensusModelCircle3D<PointT> >
ConstPtr;
96 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;
184 const Eigen::VectorXf &model_coefficients,
185 PointCloud &projected_points,
186 bool copy_data_fields =
true)
const;
195 const Eigen::VectorXf &model_coefficients,
196 const double threshold)
const;
210 isModelValid (
const Eigen::VectorXf &model_coefficients)
const;
234 int operator() (
const Eigen::VectorXd &x, Eigen::VectorXd &fvec)
const
236 for (
int i = 0; i < values (); ++i)
240 Eigen::Vector3d P (model_->input_->points[
indices_[i]].x, model_->input_->points[
indices_[i]].y, model_->input_->points[
indices_[i]].z);
242 Eigen::Vector3d C (x[0], x[1], x[2]);
244 Eigen::Vector3d N (x[4], x[5], x[6]);
248 Eigen::Vector3d helperVectorPC = P - C;
251 double lambda = (-(helperVectorPC.dot (N))) / N.dot (N);
253 Eigen::Vector3d P_proj = P + lambda * N;
254 Eigen::Vector3d helperVectorP_projC = P_proj - C;
257 Eigen::Vector3d
K = C + r * helperVectorP_projC.normalized ();
258 Eigen::Vector3d distanceVector = P -
K;
260 fvec[i] = distanceVector.norm ();
271 #ifdef PCL_NO_PRECOMPILE
272 #include <pcl/sample_consensus/impl/sac_model_circle3d.hpp>
275 #endif //#ifndef PCL_SAMPLE_CONSENSUS_MODEL_CIRCLE3D_H_
boost::shared_ptr< SampleConsensusModelCircle3D< PointT > > Ptr
void selectWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold, std::vector< int > &inliers)
Compute all distances from the cloud data to a given 3D circle model.
void optimizeModelCoefficients(const std::vector< int > &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const
Recompute the 3d circle coefficients using the given inlier set and return them to the user...
void getDistancesToModel(const Eigen::VectorXf &model_coefficients, std::vector< double > &distances) const
Compute all distances from the cloud data to a given 3D circle model.
SampleConsensusModelCircle3D(const PointCloudConstPtr &cloud, const std::vector< int > &indices, bool random=false)
Constructor for base SampleConsensusModelCircle3D.
This file defines compatibility wrappers for low level I/O functions.
unsigned int model_size_
The number of coefficients in the model.
pcl::SacModel getModelType() const
Return an unique id for this model (SACMODEL_CIRCLE3D).
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
SampleConsensusModelCircle3D defines a model for 3D circle segmentation.
SampleConsensusModel represents the base model class.
std::string model_name_
The model name.
pcl::PointCloud< PointT >::Ptr PointCloudPtr
SampleConsensusModelCircle3D(const PointCloudConstPtr &cloud, bool random=false)
Constructor for base SampleConsensusModelCircle3D.
virtual int countWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold) const
Count all the points which respect the given model coefficients as inliers.
SampleConsensusModel< PointT >::PointCloudConstPtr PointCloudConstPtr
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 3d circle model.
boost::shared_ptr< const SampleConsensusModelCircle3D< PointT > > ConstPtr
SampleConsensusModelCircle3D(const SampleConsensusModelCircle3D &source)
Copy constructor.
virtual ~SampleConsensusModelCircle3D()
Empty destructor.
pcl::PointCloud< PointT >::ConstPtr PointCloudConstPtr
PointCloud represents the base class in PCL for storing collections of 3D points. ...
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 3d circle model coefficients.
bool isSampleGood(const std::vector< int > &samples) const
Check if a sample of indices results in a good sample of points indices.
virtual bool isModelValid(const Eigen::VectorXf &model_coefficients) const
Check whether a model is valid given the user constraints.
bool computeModelCoefficients(const std::vector< int > &samples, Eigen::VectorXf &model_coefficients) const
Check whether the given index samples can form a valid 2D circle model, compute the model coefficient...
A point structure representing Euclidean xyz coordinates, and the RGB color.
SampleConsensusModel< PointT >::PointCloudPtr PointCloudPtr
unsigned int sample_size_
The size of a sample from which the model is computed.
SampleConsensusModelCircle3D & operator=(const SampleConsensusModelCircle3D &source)
Copy constructor.