Loading...
Searching...
No Matches
sac_model_normal_parallel_plane.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2011, Willow Garage, Inc.
* Copyright (c) 2012-, Open Perception, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*
*/
#pragma once
#include <pcl/sample_consensus/sac_model_normal_plane.h>
#include <pcl/sample_consensus/model_types.h>
#include <pcl/memory.h>
#include <pcl/pcl_macros.h>
namespace pcl
{
/** \brief SampleConsensusModelNormalParallelPlane defines a model for 3D
* plane segmentation using additional surface normal constraints. Basically
* this means that checking for inliers will not only involve a "distance to
* model" criterion, but also an additional "maximum angular deviation"
* between the plane's normal and the inlier points normals. In addition,
* the plane <b>normal</b> must lie parallel to a user-specified axis.
* This means that the plane itself will lie perpendicular to that axis, similar to \link pcl::SampleConsensusModelPerpendicularPlane SACMODEL_PERPENDICULAR_PLANE \endlink.
*
* The model coefficients are defined as:
* - \b a : the X coordinate of the plane's normal (normalized)
* - \b b : the Y coordinate of the plane's normal (normalized)
* - \b c : the Z coordinate of the plane's normal (normalized)
* - \b d : the fourth <a href="http://mathworld.wolfram.com/HessianNormalForm.html">Hessian component</a> of the plane's equation
*
* To set the influence of the surface normals in the inlier estimation
* process, set the normal weight (0.0-1.0), e.g.:
* \code
* SampleConsensusModelNormalPlane<pcl::PointXYZ, pcl::Normal> sac_model;
* ...
* sac_model.setNormalDistanceWeight (0.1);
* ...
* \endcode
*
* In addition, the user can specify more constraints, such as:
*
* - an axis along which we need to search for a plane perpendicular to (\ref setAxis);
* - an angle \a tolerance threshold between the plane's normal and the above given axis (\ref setEpsAngle);
* - a distance we expect the plane to be from the origin (\ref setDistanceFromOrigin);
* - a distance \a tolerance as the maximum allowed deviation from the above given distance from the origin (\ref setEpsDist).
*
* \note Please remember that you need to specify an angle > 0 in order to activate the axis-angle constraint!
*
* \author Radu B. Rusu and Jared Glover and Nico Blodow
* \ingroup sample_consensus
*/
template <typename PointT, typename PointNT>
class SampleConsensusModelNormalParallelPlane : public SampleConsensusModelNormalPlane<PointT, PointNT>
{
public:
using SampleConsensusModel<PointT>::model_name_;
using SampleConsensusModel<PointT>::input_;
using SampleConsensusModel<PointT>::indices_;
using SampleConsensusModelFromNormals<PointT, PointNT>::normals_;
using SampleConsensusModelFromNormals<PointT, PointNT>::normal_distance_weight_;
using SampleConsensusModel<PointT>::error_sqr_dists_;
using PointCloud = typename SampleConsensusModel<PointT>::PointCloud;
using PointCloudPtr = typename SampleConsensusModel<PointT>::PointCloudPtr;
using PointCloudConstPtr = typename SampleConsensusModel<PointT>::PointCloudConstPtr;
using PointCloudNPtr = typename SampleConsensusModelFromNormals<PointT, PointNT>::PointCloudNPtr;
using PointCloudNConstPtr = typename SampleConsensusModelFromNormals<PointT, PointNT>::PointCloudNConstPtr;
using Ptr = shared_ptr<SampleConsensusModelNormalParallelPlane<PointT, PointNT> >;
using ConstPtr = shared_ptr<const SampleConsensusModelNormalParallelPlane<PointT, PointNT>>;
/** \brief Constructor for base SampleConsensusModelNormalParallelPlane.
* \param[in] cloud the input point cloud dataset
* \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
*/
SampleConsensusModelNormalParallelPlane (const PointCloudConstPtr &cloud,
bool random = false)
: SampleConsensusModelNormalPlane<PointT, PointNT> (cloud, random)
, axis_ (Eigen::Vector4f::Zero ())
, distance_from_origin_ (0)
, eps_angle_ (-1.0)
, cos_angle_ (-1.0)
, eps_dist_ (0.0)
{
model_name_ = "SampleConsensusModelNormalParallelPlane";
sample_size_ = 3;
model_size_ = 4;
}
/** \brief Constructor for base SampleConsensusModelNormalParallelPlane.
* \param[in] cloud the input point cloud dataset
* \param[in] indices a vector of point indices to be used from \a cloud
* \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
*/
SampleConsensusModelNormalParallelPlane (const PointCloudConstPtr &cloud,
const Indices &indices,
bool random = false)
: SampleConsensusModelNormalPlane<PointT, PointNT> (cloud, indices, random)
, axis_ (Eigen::Vector4f::Zero ())
, distance_from_origin_ (0)
, eps_angle_ (-1.0)
, cos_angle_ (-1.0)
, eps_dist_ (0.0)
{
model_name_ = "SampleConsensusModelNormalParallelPlane";
sample_size_ = 3;
model_size_ = 4;
}
/** \brief Empty destructor */
~SampleConsensusModelNormalParallelPlane () override = default;
/** \brief Set the axis along which we need to search for a plane perpendicular to.
* \param[in] ax the axis along which we need to search for a plane perpendicular to
*/
inline void
setAxis (const Eigen::Vector3f &ax) { axis_.head<3> () = ax; axis_.normalize ();}
/** \brief Get the axis along which we need to search for a plane perpendicular to. */
inline Eigen::Vector3f
getAxis () const { return (axis_.head<3> ()); }
/** \brief Set the angle epsilon (delta) threshold.
* \param[in] ea the maximum allowed deviation from 90 degrees between the plane normal and the given axis.
* \note You need to specify an angle > 0 in order to activate the axis-angle constraint!
*/
inline void
setEpsAngle (const double ea) { eps_angle_ = ea; cos_angle_ = std::abs (std::cos (ea));}
/** \brief Get the angle epsilon (delta) threshold. */
inline double
getEpsAngle () const { return (eps_angle_); }
/** \brief Set the distance we expect the plane to be from the origin
* \param[in] d distance from the template plane to the origin
*/
inline void
setDistanceFromOrigin (const double d) { distance_from_origin_ = d; }
/** \brief Get the distance of the plane from the origin. */
inline double
getDistanceFromOrigin () const { return (distance_from_origin_); }
/** \brief Set the distance epsilon (delta) threshold.
* \param[in] delta the maximum allowed deviation from the template distance from the origin
*/
inline void
setEpsDist (const double delta) { eps_dist_ = delta; }
/** \brief Get the distance epsilon (delta) threshold. */
inline double
getEpsDist () const { return (eps_dist_); }
/** \brief Return a unique id for this model (SACMODEL_NORMAL_PARALLEL_PLANE). */
inline pcl::SacModel
getModelType () const override { return (SACMODEL_NORMAL_PARALLEL_PLANE); }
PCL_MAKE_ALIGNED_OPERATOR_NEW
protected:
using SampleConsensusModel<PointT>::sample_size_;
using SampleConsensusModel<PointT>::model_size_;
/** \brief Check whether a model is valid given the user constraints.
* \param[in] model_coefficients the set of model coefficients
*/
bool
isModelValid (const Eigen::VectorXf &model_coefficients) const override;
private:
/** \brief The axis along which we need to search for a plane perpendicular to. */
Eigen::Vector4f axis_;
/** \brief The distance from the template plane to the origin. */
double distance_from_origin_;
/** \brief The maximum allowed difference between the plane normal and the given axis. */
double eps_angle_;
/** \brief The cosine of the angle*/
double cos_angle_;
/** \brief The maximum allowed deviation from the template distance from the origin. */
double eps_dist_;
};
}
#ifdef PCL_NO_PRECOMPILE
#include <pcl/sample_consensus/impl/sac_model_normal_parallel_plane.hpp>
#endif
pcl::SampleConsensusModelFromNormals
SampleConsensusModelFromNormals represents the base model class for models that require the use of su...
Definition sac_model.h:613
pcl::SampleConsensusModelFromNormals::normals_
PointCloudNConstPtr normals_
A pointer to the input dataset that contains the point normals of the XYZ dataset.
Definition sac_model.h:671
pcl::SampleConsensusModelFromNormals::PointCloudNConstPtr
typename pcl::PointCloud< PointNT >::ConstPtr PointCloudNConstPtr
Definition sac_model.h:615
pcl::SampleConsensusModelFromNormals::PointCloudNPtr
typename pcl::PointCloud< PointNT >::Ptr PointCloudNPtr
Definition sac_model.h:616
pcl::SampleConsensusModelFromNormals::normal_distance_weight_
double normal_distance_weight_
The relative weight (between 0 and 1) to give to the angular distance (0 to pi/2) between point norma...
Definition sac_model.h:666
pcl::SampleConsensusModel
SampleConsensusModel represents the base model class.
Definition sac_model.h:71
pcl::SampleConsensusModel::sample_size_
unsigned int sample_size_
The size of a sample from which the model is computed.
Definition sac_model.h:589
pcl::SampleConsensusModel::PointCloudConstPtr
typename PointCloud::ConstPtr PointCloudConstPtr
Definition sac_model.h:74
pcl::SampleConsensusModel::PointCloud
pcl::PointCloud< PointT > PointCloud
Definition sac_model.h:73
pcl::SampleConsensusModel::indices_
IndicesPtr indices_
A pointer to the vector of point indices to use.
Definition sac_model.h:557
pcl::SampleConsensusModel::input_
PointCloudConstPtr input_
A boost shared pointer to the point cloud data array.
Definition sac_model.h:554
pcl::SampleConsensusModel::model_name_
std::string model_name_
The model name.
Definition sac_model.h:551
pcl::SampleConsensusModel::model_size_
unsigned int model_size_
The number of coefficients in the model.
Definition sac_model.h:592
pcl::SampleConsensusModel::PointCloudPtr
typename PointCloud::Ptr PointCloudPtr
Definition sac_model.h:75
pcl::SampleConsensusModel::error_sqr_dists_
std::vector< double > error_sqr_dists_
A vector holding the distances to the computed model.
Definition sac_model.h:586
pcl::SampleConsensusModelNormalParallelPlane::getDistanceFromOrigin
double getDistanceFromOrigin() const
Get the distance of the plane from the origin.
Definition sac_model_normal_parallel_plane.h:176
pcl::SampleConsensusModelNormalParallelPlane::setEpsDist
void setEpsDist(const double delta)
Set the distance epsilon (delta) threshold.
Definition sac_model_normal_parallel_plane.h:182
pcl::SampleConsensusModelNormalParallelPlane::ConstPtr
shared_ptr< const SampleConsensusModelNormalParallelPlane< PointT, PointNT > > ConstPtr
Definition sac_model_normal_parallel_plane.h:104
pcl::SampleConsensusModelNormalParallelPlane::SampleConsensusModelNormalParallelPlane
SampleConsensusModelNormalParallelPlane(const PointCloudConstPtr &cloud, bool random=false)
Constructor for base SampleConsensusModelNormalParallelPlane.
Definition sac_model_normal_parallel_plane.h:110
pcl::SampleConsensusModelNormalParallelPlane::isModelValid
bool isModelValid(const Eigen::VectorXf &model_coefficients) const override
Check whether a model is valid given the user constraints.
Definition sac_model_normal_parallel_plane.hpp:48
pcl::SampleConsensusModelNormalParallelPlane::PointCloudConstPtr
typename SampleConsensusModel< PointT >::PointCloudConstPtr PointCloudConstPtr
Definition sac_model_normal_parallel_plane.h:98
pcl::SampleConsensusModelNormalParallelPlane::PointCloudPtr
typename SampleConsensusModel< PointT >::PointCloudPtr PointCloudPtr
Definition sac_model_normal_parallel_plane.h:97
pcl::SampleConsensusModelNormalParallelPlane::PointCloudNConstPtr
typename SampleConsensusModelFromNormals< PointT, PointNT >::PointCloudNConstPtr PointCloudNConstPtr
Definition sac_model_normal_parallel_plane.h:101
pcl::SampleConsensusModelNormalParallelPlane::setDistanceFromOrigin
void setDistanceFromOrigin(const double d)
Set the distance we expect the plane to be from the origin.
Definition sac_model_normal_parallel_plane.h:172
pcl::SampleConsensusModelNormalParallelPlane::SampleConsensusModelNormalParallelPlane
SampleConsensusModelNormalParallelPlane(const PointCloudConstPtr &cloud, const Indices &indices, bool random=false)
Constructor for base SampleConsensusModelNormalParallelPlane.
Definition sac_model_normal_parallel_plane.h:129
pcl::SampleConsensusModelNormalParallelPlane::PointCloud
typename SampleConsensusModel< PointT >::PointCloud PointCloud
Definition sac_model_normal_parallel_plane.h:96
pcl::SampleConsensusModelNormalParallelPlane::PointCloudNPtr
typename SampleConsensusModelFromNormals< PointT, PointNT >::PointCloudNPtr PointCloudNPtr
Definition sac_model_normal_parallel_plane.h:100
pcl::SampleConsensusModelNormalParallelPlane::getModelType
pcl::SacModel getModelType() const override
Return a unique id for this model (SACMODEL_NORMAL_PARALLEL_PLANE).
Definition sac_model_normal_parallel_plane.h:190
pcl::SampleConsensusModelNormalParallelPlane::~SampleConsensusModelNormalParallelPlane
~SampleConsensusModelNormalParallelPlane() override=default
Empty destructor.
pcl::SampleConsensusModelNormalParallelPlane::getEpsAngle
double getEpsAngle() const
Get the angle epsilon (delta) threshold.
Definition sac_model_normal_parallel_plane.h:166
pcl::SampleConsensusModelNormalParallelPlane::setEpsAngle
void setEpsAngle(const double ea)
Set the angle epsilon (delta) threshold.
Definition sac_model_normal_parallel_plane.h:162
pcl::SampleConsensusModelNormalParallelPlane::getAxis
Eigen::Vector3f getAxis() const
Get the axis along which we need to search for a plane perpendicular to.
Definition sac_model_normal_parallel_plane.h:155
pcl::SampleConsensusModelNormalParallelPlane::setAxis
void setAxis(const Eigen::Vector3f &ax)
Set the axis along which we need to search for a plane perpendicular to.
Definition sac_model_normal_parallel_plane.h:151
pcl::SampleConsensusModelNormalParallelPlane::Ptr
shared_ptr< SampleConsensusModelNormalParallelPlane< PointT, PointNT > > Ptr
Definition sac_model_normal_parallel_plane.h:103
pcl::SampleConsensusModelNormalParallelPlane::getEpsDist
double getEpsDist() const
Get the distance epsilon (delta) threshold.
Definition sac_model_normal_parallel_plane.h:186
pcl::SampleConsensusModelNormalPlane::SampleConsensusModelNormalPlane
SampleConsensusModelNormalPlane(const PointCloudConstPtr &cloud, bool random=false)
Constructor for base SampleConsensusModelNormalPlane.
Definition sac_model_normal_plane.h:101
PCL_MAKE_ALIGNED_OPERATOR_NEW
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition memory.h:86
memory.h
Defines functions, macros and traits for allocating and using memory.
Eigen
Definition bfgs.h:10
pcl
Definition convolution.h:46
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133
pcl::SacModel
SacModel
Definition model_types.h:46
pcl::SACMODEL_NORMAL_PARALLEL_PLANE
@ SACMODEL_NORMAL_PARALLEL_PLANE
Definition model_types.h:63
pcl_macros.h
Defines all the PCL and non-PCL macros used.