43 #include <pcl/sample_consensus/sac_model.h>
44 #include <pcl/sample_consensus/model_types.h>
46 #include <pcl/pcl_exports.h>
67 template <
typename Po
intT,
typename Po
intNT>
84 using Ptr = shared_ptr<SampleConsensusModelCylinder<PointT, PointNT> >;
85 using ConstPtr = shared_ptr<const SampleConsensusModelCylinder<PointT, PointNT>>;
94 , axis_ (
Eigen::Vector3f::Zero ())
112 , axis_ (
Eigen::Vector3f::Zero ())
126 axis_ (
Eigen::Vector3f::Zero ()),
144 axis_ = source.axis_;
145 eps_angle_ = source.eps_angle_;
163 setAxis (
const Eigen::Vector3f &ax) { axis_ = ax; }
166 inline Eigen::Vector3f
177 Eigen::VectorXf &model_coefficients)
const override;
185 std::vector<double> &distances)
const override;
194 const double threshold,
205 const double threshold)
const override;
215 const Eigen::VectorXf &model_coefficients,
216 Eigen::VectorXf &optimized_coefficients)
const override;
227 const Eigen::VectorXf &model_coefficients,
229 bool copy_data_fields =
true)
const override;
238 const Eigen::VectorXf &model_coefficients,
239 const double threshold)
const override;
254 pointToLineDistance (
const Eigen::Vector4f &pt,
const Eigen::VectorXf &model_coefficients)
const;
264 const Eigen::Vector4f &line_pt,
265 const Eigen::Vector4f &line_dir,
266 Eigen::Vector4f &pt_proj)
const
268 float k = (pt.dot (line_dir) - line_pt.dot (line_dir)) / line_dir.dot (line_dir);
270 pt_proj = line_pt + k * line_dir;
281 const Eigen::VectorXf &model_coefficients,
282 Eigen::Vector4f &pt_proj)
const;
288 isModelValid (
const Eigen::VectorXf &model_coefficients)
const override;
299 Eigen::Vector3f axis_;
306 #ifdef PCL_NO_PRECOMPILE
307 #include <pcl/sample_consensus/impl/sac_model_cylinder.hpp>
PointCloud represents the base class in PCL for storing collections of 3D points.
SampleConsensusModelCylinder defines a model for 3D cylinder segmentation.
SampleConsensusModelCylinder(const PointCloudConstPtr &cloud, const Indices &indices, bool random=false)
Constructor for base SampleConsensusModelCylinder.
pcl::SacModel getModelType() const override
Return a unique id for this model (SACMODEL_CYLINDER).
void getDistancesToModel(const Eigen::VectorXf &model_coefficients, std::vector< double > &distances) const override
Compute all distances from the cloud data to a given cylinder model.
SampleConsensusModelCylinder(const SampleConsensusModelCylinder &source)
Copy constructor.
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 cylinder model.
double getEpsAngle() const
Get the angle epsilon (delta) threshold.
void projectPointToLine(const Eigen::Vector4f &pt, const Eigen::Vector4f &line_pt, const Eigen::Vector4f &line_dir, Eigen::Vector4f &pt_proj) const
Project a point onto a line given by a point and a direction vector.
bool isModelValid(const Eigen::VectorXf &model_coefficients) const override
Check whether a model is valid given the user constraints.
void optimizeModelCoefficients(const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const override
Recompute the cylinder coefficients using the given inlier set and return them to the user.
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.
SampleConsensusModelCylinder & operator=(const SampleConsensusModelCylinder &source)
Copy constructor.
void projectPointToCylinder(const Eigen::Vector4f &pt, const Eigen::VectorXf &model_coefficients, Eigen::Vector4f &pt_proj) const
Project a point onto a cylinder given by its model coefficients (point_on_axis, axis_direction,...
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.
SampleConsensusModelCylinder(const PointCloudConstPtr &cloud, bool random=false)
Constructor for base SampleConsensusModelCylinder.
void setEpsAngle(const double ea)
Set the angle epsilon (delta) threshold.
bool isSampleGood(const Indices &samples) const override
Check if a sample of indices results in a good sample of points indices.
void setAxis(const Eigen::Vector3f &ax)
Set the axis along which we need to search for a cylinder direction.
~SampleConsensusModelCylinder() override=default
Empty destructor.
Eigen::Vector3f getAxis() const
Get the axis along which we need to search for a cylinder direction.
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 cylinder model coefficients.
double pointToLineDistance(const Eigen::Vector4f &pt, const Eigen::VectorXf &model_coefficients) const
Get the distance from a point to a line (represented by a point and a direction)
bool computeModelCoefficients(const Indices &samples, Eigen::VectorXf &model_coefficients) const override
Check whether the given index samples can form a valid cylinder model, compute the model coefficients...
SampleConsensusModelFromNormals represents the base model class for models that require the use of su...
SampleConsensusModel represents the base model class.
shared_ptr< SampleConsensusModel< PointT > > Ptr
unsigned int sample_size_
The size of a sample from which the model is computed.
typename PointCloud::ConstPtr PointCloudConstPtr
std::string model_name_
The model name.
unsigned int model_size_
The number of coefficients in the model.
typename PointCloud::Ptr PointCloudPtr
shared_ptr< const SampleConsensusModel< PointT > > ConstPtr
Define standard C methods to do distance calculations.
PCL_EXPORTS int optimizeModelCoefficientsCylinder(Eigen::VectorXf &coeff, const Eigen::ArrayXf &pts_x, const Eigen::ArrayXf &pts_y, const Eigen::ArrayXf &pts_z)
IndicesAllocator<> Indices
Type used for indices in PCL.
A point structure representing Euclidean xyz coordinates, and the RGB color.