41 #ifndef PCL_SAMPLE_CONSENSUS_MODEL_PLANE_H_
42 #define PCL_SAMPLE_CONSENSUS_MODEL_PLANE_H_
44 #include <pcl/sample_consensus/sac_model.h>
45 #include <pcl/sample_consensus/model_types.h>
55 template <
typename Po
int>
inline void
56 projectPoint (
const Point &p,
const Eigen::Vector4f &model_coefficients, Point &q)
59 Eigen::Vector4f pp (p.x, p.y, p.z, 1);
61 float distance_to_plane = pp.dot(model_coefficients);
68 Eigen::Vector4f q_e = pp - distance_to_plane * model_coefficients;
82 template <
typename Po
int>
inline double
85 return (a * p.x + b * p.y + c * p.z + d);
93 template <
typename Po
int>
inline double
96 return ( plane_coefficients[0] * p.x + plane_coefficients[1] * p.y + plane_coefficients[2] * p.z + plane_coefficients[3] );
107 template <
typename Po
int>
inline double
118 template <
typename Po
int>
inline double
135 template <
typename Po
intT>
147 typedef boost::shared_ptr<SampleConsensusModelPlane>
Ptr;
162 const std::vector<int> &indices,
177 Eigen::VectorXf &model_coefficients);
185 std::vector<double> &distances);
194 const double threshold,
195 std::vector<int> &inliers);
205 const double threshold);
215 const Eigen::VectorXf &model_coefficients,
216 Eigen::VectorXf &optimized_coefficients);
226 const Eigen::VectorXf &model_coefficients,
228 bool copy_data_fields =
true);
237 const Eigen::VectorXf &model_coefficients,
238 const double threshold);
252 if (model_coefficients.size () != 4)
254 PCL_ERROR (
"[pcl::SampleConsensusModelPlane::isModelValid] Invalid number of model coefficients given (%zu)!\n", model_coefficients.size ());
266 isSampleGood (
const std::vector<int> &samples)
const;
270 #ifdef PCL_NO_PRECOMPILE
271 #include <pcl/sample_consensus/impl/sac_model_plane.hpp>
274 #endif //#ifndef PCL_SAMPLE_CONSENSUS_MODEL_PLANE_H_
pcl::SacModel getModelType() const
Return an unique id for this model (SACMODEL_PLANE).
pcl::PointCloud< PointT >::Ptr PointCloudPtr
bool doSamplesVerifyModel(const std::set< int > &indices, const Eigen::VectorXf &model_coefficients, const double threshold)
Verify whether a subset of indices verifies the given plane model coefficients.
SampleConsensusModelPlane(const PointCloudConstPtr &cloud, bool random=false)
Constructor for base SampleConsensusModelPlane.
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.
bool computeModelCoefficients(const std::vector< int > &samples, Eigen::VectorXf &model_coefficients)
Check whether the given index samples can form a valid plane model, compute the model coefficients fr...
bool isModelValid(const Eigen::VectorXf &model_coefficients)
Check whether a model is valid given the user constraints.
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 plane model.
SampleConsensusModel< PointT >::PointCloudPtr PointCloudPtr
virtual int countWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold)
Count all the points which respect the given model coefficients as inliers.
double pointToPlaneDistance(const Point &p, double a, double b, double c, double d)
Get the distance from a point to a plane (unsigned) defined by ax+by+cz+d=0.
SampleConsensusModelPlane defines a model for 3D plane segmentation.
SampleConsensusModel< PointT >::PointCloud PointCloud
double pointToPlaneDistanceSigned(const Point &p, double a, double b, double c, double d)
Get the distance from a point to a plane (signed) defined by ax+by+cz+d=0.
virtual ~SampleConsensusModelPlane()
Empty destructor.
void projectPoint(const Point &p, const Eigen::Vector4f &model_coefficients, Point &q)
Project a point on a planar model given by a set of normalized coefficients.
SampleConsensusModel represents the base model class.
SampleConsensusModelPlane(const PointCloudConstPtr &cloud, const std::vector< int > &indices, bool random=false)
Constructor for base SampleConsensusModelPlane.
A point structure representing Euclidean xyz coordinates, and the RGB color.
void optimizeModelCoefficients(const std::vector< int > &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients)
Recompute the plane coefficients using the given inlier set and return them to the user...
pcl::PointCloud< PointT >::ConstPtr PointCloudConstPtr
boost::shared_ptr< SampleConsensusModelPlane > Ptr
void getDistancesToModel(const Eigen::VectorXf &model_coefficients, std::vector< double > &distances)
Compute all distances from the cloud data to a given plane model.
SampleConsensusModel< PointT >::PointCloudConstPtr PointCloudConstPtr