43 #include <pcl/point_cloud.h>
45 #include <pcl/features/feature.h>
46 #include <pcl/features/integral_image2D.h>
65 template <
typename Po
intInT,
typename Po
intOutT>
75 using Ptr = shared_ptr<IntegralImageNormalEstimation<PointInT, PointOutT> >;
76 using ConstPtr = shared_ptr<const IntegralImageNormalEstimation<PointInT, PointOutT> >;
111 , rect_width_ (0), rect_width_2_ (0), rect_width_4_ (0)
112 , rect_height_ (0), rect_height_2_ (0), rect_height_4_ (0)
113 , distance_threshold_ (0)
114 , integral_image_DX_ (false)
115 , integral_image_DY_ (false)
116 , integral_image_depth_ (false)
117 , integral_image_XYZ_ (true)
120 , depth_data_ (nullptr)
121 , distance_map_ (nullptr)
122 , use_depth_dependent_smoothing_ (false)
123 , max_depth_change_factor_ (20.0f*0.001f)
124 , normal_smoothing_size_ (10.0f)
125 , init_covariance_matrix_ (false)
126 , init_average_3d_gradient_ (false)
127 , init_simple_3d_gradient_ (false)
128 , init_depth_change_ (false)
132 , use_sensor_origin_ (true)
155 border_policy_ = border_policy;
165 computePointNormal (
const int pos_x,
const int pos_y,
const unsigned point_index, PointOutT &normal);
183 max_depth_change_factor_ = max_depth_change_factor;
193 if (normal_smoothing_size <= 0)
195 PCL_ERROR (
"[pcl::%s::setNormalSmoothingSize] Invalid normal smoothing size given! (%f). Allowed ranges are: 0 < N. Defaulting to %f.\n",
196 feature_name_.c_str (), normal_smoothing_size, normal_smoothing_size_);
199 normal_smoothing_size_ = normal_smoothing_size;
217 normal_estimation_method_ = normal_estimation_method;
226 use_depth_dependent_smoothing_ = use_depth_dependent_smoothing;
236 if (!cloud->isOrganized ())
238 PCL_ERROR (
"[pcl::IntegralImageNormalEstimation::setInputCloud] Input dataset is not organized (height = 1).\n");
242 init_covariance_matrix_ = init_average_3d_gradient_ = init_depth_change_ =
false;
244 if (use_sensor_origin_)
246 vpx_ =
input_->sensor_origin_.coeff (0);
247 vpy_ =
input_->sensor_origin_.coeff (1);
248 vpz_ =
input_->sensor_origin_.coeff (2);
260 return (distance_map_);
274 use_sensor_origin_ =
false;
300 use_sensor_origin_ =
true;
303 vpx_ =
input_->sensor_origin_.coeff (0);
304 vpy_ =
input_->sensor_origin_.coeff (1);
305 vpz_ =
input_->sensor_origin_.coeff (2);
356 flipNormalTowardsViewpoint (
const PointInT &point,
357 float vp_x,
float vp_y,
float vp_z,
358 float &nx,
float &ny,
float &nz)
366 float cos_theta = (vp_x * nx + vp_y * ny + vp_z * nz);
398 float distance_threshold_;
401 IntegralImage2D<float, 3> integral_image_DX_;
403 IntegralImage2D<float, 3> integral_image_DY_;
405 IntegralImage2D<float, 1> integral_image_depth_;
407 IntegralImage2D<float, 3> integral_image_XYZ_;
418 float *distance_map_;
421 bool use_depth_dependent_smoothing_;
424 float max_depth_change_factor_;
427 float normal_smoothing_size_;
430 bool init_covariance_matrix_;
433 bool init_average_3d_gradient_;
436 bool init_simple_3d_gradient_;
439 bool init_depth_change_;
443 float vpx_, vpy_, vpz_;
446 bool use_sensor_origin_;
450 initCompute ()
override;
454 initCovarianceMatrixMethod ();
458 initAverage3DGradientMethod ();
462 initAverageDepthChangeMethod ();
466 initSimple3DGradientMethod ();
473 #ifdef PCL_NO_PRECOMPILE
474 #include <pcl/features/impl/integral_image_normal.hpp>
Feature represents the base feature class.
int k_
The number of K nearest neighbors to use for each point.
shared_ptr< Feature< PointInT, PointOutT > > Ptr
std::string feature_name_
The feature name.
shared_ptr< const Feature< PointInT, PointOutT > > ConstPtr
KdTreePtr tree_
A pointer to the spatial search object.
Surface normal estimation on organized data using integral images.
BorderPolicy
Different types of border handling.
NormalEstimationMethod
Different normal estimation methods.
void setDepthDependentSmoothing(bool use_depth_dependent_smoothing)
Set whether to use depth depending smoothing or not.
void setBorderPolicy(const BorderPolicy border_policy)
Sets the policy for handling borders.
void initData()
Initialize the data structures, based on the normal estimation method chosen.
IntegralImageNormalEstimation()
Constructor.
void useSensorOriginAsViewPoint()
sets whether the sensor origin or a user given viewpoint should be used.
void setRectSize(const int width, const int height)
Set the regions size which is considered for normal estimation.
typename Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
void getViewPoint(float &vpx, float &vpy, float &vpz)
Get the viewpoint.
void setNormalEstimationMethod(NormalEstimationMethod normal_estimation_method)
Set the normal estimation method.
float * getDistanceMap()
Returns a pointer to the distance map which was computed internally.
~IntegralImageNormalEstimation()
Destructor.
void computeFeatureFull(const float *distance_map, const float &bad_point, PointCloudOut &output)
Computes the normal for the complete cloud.
void setInputCloud(const typename PointCloudIn::ConstPtr &cloud) override
Provide a pointer to the input dataset (overwrites the PCLBase::setInputCloud method)
void computePointNormal(const int pos_x, const int pos_y, const unsigned point_index, PointOutT &normal)
Computes the normal at the specified position.
void computeFeature(PointCloudOut &output) override
Computes the normal for the complete cloud or only indices_ if provided.
void computeFeaturePart(const float *distance_map, const float &bad_point, PointCloudOut &output)
Computes the normal for part of the cloud specified by indices_.
void setViewPoint(float vpx, float vpy, float vpz)
Set the viewpoint.
void setNormalSmoothingSize(float normal_smoothing_size)
Set the normal smoothing size.
void setMaxDepthChangeFactor(float max_depth_change_factor)
The depth change threshold for computing object borders.
void computePointNormalMirror(const int pos_x, const int pos_y, const unsigned point_index, PointOutT &normal)
Computes the normal at the specified position with mirroring for border handling.
PointCloudConstPtr input_
The input point cloud dataset.
shared_ptr< const PointCloud< PointInT > > ConstPtr
Defines all the PCL implemented PointT point type structures.
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Defines functions, macros and traits for allocating and using memory.
Defines all the PCL and non-PCL macros used.