22 #ifndef __LIBS_PCL_UTILS_COMPARISONS_H_ 23 #define __LIBS_PCL_UTILS_COMPARISONS_H_ 25 #include <pcl/point_cloud.h> 26 #include <pcl/ModelCoefficients.h> 27 #include <pcl/filters/conditional_removal.h> 28 #include <pcl/segmentation/extract_polygonal_prism_data.h> 46 template <
typename Po
intT>
49 using pcl::ComparisonBase<PointT>::capable_;
52 typedef boost::shared_ptr<PolygonComparison<PointT> >
Ptr;
54 typedef boost::shared_ptr<const PolygonComparison<PointT> >
ConstPtr;
63 capable_ = (polygon.size() >= 3);
73 virtual bool evaluate(
const PointT &point)
const 76 return pcl::isPointIn2DPolygon(point,
polygon_);
78 return ! pcl::isPointIn2DPolygon(point,
polygon_);
97 template <
typename Po
intT>
100 using pcl::ComparisonBase<PointT>::capable_;
103 typedef boost::shared_ptr<PlaneDistanceComparison<PointT> >
Ptr;
105 typedef boost::shared_ptr<const PlaneDistanceComparison<PointT> >
ConstPtr;
113 pcl::ComparisonOps::CompareOp op = pcl::ComparisonOps::GT,
114 float compare_val = 0.)
115 : coeff_(coeff), op_(op), compare_val_(compare_val)
117 capable_ = (coeff_->values.size() == 4);
128 float val = (coeff_->values[0] * point.x + coeff_->values[1] * point.y +
129 coeff_->values[2] * point.z + coeff_->values[3]) /
130 sqrtf(coeff_->values[0] * coeff_->values[0] +
131 coeff_->values[1] * coeff_->values[1] +
132 coeff_->values[2] * coeff_->values[2]);
136 if (op_ == pcl::ComparisonOps::GT) {
137 return val > compare_val_;
138 }
else if (op_ == pcl::ComparisonOps::GE) {
139 return val >= compare_val_;
140 }
else if (op_ == pcl::ComparisonOps::LT) {
141 return val < compare_val_;
142 }
else if (op_ == pcl::ComparisonOps::LE) {
143 return val <= compare_val_;
145 return val == compare_val_;
153 pcl::ComparisonOps::CompareOp
op_;
Compare points' distance to a plane.
boost::shared_ptr< PlaneDistanceComparison< PointT > > Ptr
Shared pointer.
PolygonComparison(const pcl::PointCloud< PointT > &polygon, bool inside=true)
Constructor.
pcl::ComparisonOps::CompareOp op_
Comparison operation.
virtual bool evaluate(const PointT &point) const
Evaluate for given pixel.
const pcl::PointCloud< PointT > & polygon_
The polygon to check against.
virtual ~PlaneDistanceComparison()
Virtual empty destructor.
Fawkes library namespace.
PlaneDistanceComparison(pcl::ModelCoefficients::ConstPtr coeff, pcl::ComparisonOps::CompareOp op=pcl::ComparisonOps::GT, float compare_val=0.)
Constructor.
float compare_val_
Value to compare against.
Check if point is inside or outside a given polygon.
bool inside_
Flag to determine whether to do inside or outside check.
boost::shared_ptr< PolygonComparison< PointT > > Ptr
Shared pointer.
boost::shared_ptr< const PlaneDistanceComparison< PointT > > ConstPtr
Constant shared pointer.
virtual bool evaluate(const PointT &point) const
Evaluate for given pixel.
pcl::ModelCoefficients::ConstPtr coeff_
Planar model coefficients.
virtual ~PolygonComparison()
Virtual empty destructor.
boost::shared_ptr< const PolygonComparison< PointT > > ConstPtr
Constant shared pointer.