41 #include <pcl/sample_consensus/sac_model.h>
42 #include <pcl/sample_consensus/model_types.h>
43 #include <pcl/common/distances.h>
44 #include <pcl/pcl_exports.h>
49 PCL_EXPORTS
int optimizeModelCoefficientsCone (Eigen::VectorXf& coeff,
const Eigen::ArrayXf& pts_x,
const Eigen::ArrayXf& pts_y,
const Eigen::ArrayXf& pts_z);
66 template <
typename Po
intT,
typename Po
intNT>
83 using Ptr = shared_ptr<SampleConsensusModelCone<PointT, PointNT> >;
84 using ConstPtr = shared_ptr<const SampleConsensusModelCone<PointT, PointNT>>;
93 , axis_ (
Eigen::Vector3f::Zero ())
95 , min_angle_ (-std::numeric_limits<double>::max ())
96 , max_angle_ (std::numeric_limits<double>::max ())
113 , axis_ (
Eigen::Vector3f::Zero ())
115 , min_angle_ (-std::numeric_limits<double>::max ())
116 , max_angle_ (std::numeric_limits<double>::max ())
129 eps_angle_ (), min_angle_ (), max_angle_ ()
146 axis_ = source.axis_;
147 eps_angle_ = source.eps_angle_;
148 min_angle_ = source.min_angle_;
149 max_angle_ = source.max_angle_;
167 setAxis (
const Eigen::Vector3f &ax) { axis_ = ax; }
170 inline Eigen::Vector3f
181 min_angle_ = min_angle;
182 max_angle_ = max_angle;
192 min_angle = min_angle_;
193 max_angle = max_angle_;
204 Eigen::VectorXf &model_coefficients)
const override;
212 std::vector<double> &distances)
const override;
221 const double threshold,
232 const double threshold)
const override;
243 const Eigen::VectorXf &model_coefficients,
244 Eigen::VectorXf &optimized_coefficients)
const override;
255 const Eigen::VectorXf &model_coefficients,
257 bool copy_data_fields =
true)
const override;
266 const Eigen::VectorXf &model_coefficients,
267 const double threshold)
const override;
282 pointToAxisDistance (
const Eigen::Vector4f &pt,
const Eigen::VectorXf &model_coefficients)
const;
288 isModelValid (
const Eigen::VectorXf &model_coefficients)
const override;
299 Eigen::Vector3f axis_;
310 #ifdef PCL_NO_PRECOMPILE
311 #include <pcl/sample_consensus/impl/sac_model_cone.hpp>
SampleConsensusModelCone(const PointCloudConstPtr &cloud, const Indices &indices, bool random=false)
Constructor for base SampleConsensusModelCone.
void getMinMaxOpeningAngle(double &min_angle, double &max_angle) const
Get the opening angle which we need minimum to validate a cone model.
~SampleConsensusModelCone() override=default
Empty destructor.
unsigned int model_size_
The number of coefficients in the model.
void optimizeModelCoefficients(const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const override
Recompute the cone coefficients using the given inlier set and return them to the user...
void getDistancesToModel(const Eigen::VectorXf &model_coefficients, std::vector< double > &distances) const override
Compute all distances from the cloud data to a given cone model.
double getEpsAngle() const
Get the angle epsilon (delta) threshold.
void setEpsAngle(double ea)
Set the angle epsilon (delta) threshold.
typename PointCloud::Ptr PointCloudPtr
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 cone model.
SampleConsensusModel represents the base model class.
std::string model_name_
The model name.
PCL_EXPORTS int optimizeModelCoefficientsCone(Eigen::VectorXf &coeff, const Eigen::ArrayXf &pts_x, const Eigen::ArrayXf &pts_y, const Eigen::ArrayXf &pts_z)
SampleConsensusModelCone defines a model for 3D cone segmentation.
typename PointCloud::ConstPtr PointCloudConstPtr
Eigen::Vector3f getAxis() const
Get the axis along which we need to search for a cone direction.
SampleConsensusModelFromNormals represents the base model class for models that require the use of su...
IndicesAllocator<> Indices
Type used for indices in PCL.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
SampleConsensusModelCone(const SampleConsensusModelCone &source)
Copy constructor.
shared_ptr< const SampleConsensusModel< PointT > > ConstPtr
SampleConsensusModelCone(const PointCloudConstPtr &cloud, bool random=false)
Constructor for base SampleConsensusModelCone.
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 cone model coefficients.
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.
bool isModelValid(const Eigen::VectorXf &model_coefficients) const override
Check whether a model is valid given the user constraints.
double pointToAxisDistance(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 isSampleGood(const Indices &samples) const override
Check if a sample of indices results in a good sample of points indices.
A point structure representing Euclidean xyz coordinates, and the RGB color.
shared_ptr< SampleConsensusModel< PointT > > Ptr
void setAxis(const Eigen::Vector3f &ax)
Set the axis along which we need to search for a cone direction.
SampleConsensusModelCone & operator=(const SampleConsensusModelCone &source)
Copy constructor.
void setMinMaxOpeningAngle(const double &min_angle, const double &max_angle)
Set the minimum and maximum allowable opening angle for a cone model given from a user...
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.
unsigned int sample_size_
The size of a sample from which the model is computed.
pcl::SacModel getModelType() const override
Return a unique id for this model (SACMODEL_CONE).
bool computeModelCoefficients(const Indices &samples, Eigen::VectorXf &model_coefficients) const override
Check whether the given index samples can form a valid cone model, compute the model coefficients fro...