39 #ifndef PCL_INTEGRALIMAGE_BASED_NORMAL_ESTIMATOR_H_
40 #define PCL_INTEGRALIMAGE_BASED_NORMAL_ESTIMATOR_H_
42 #include <pcl/point_cloud.h>
43 #include <pcl/point_types.h>
44 #include <pcl/features/feature.h>
45 #include <pcl/features/integral_image2D.h>
47 #if defined BUILD_Maintainer && defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ > 3
48 #pragma GCC diagnostic ignored "-Weffc++"
55 template <
typename Po
intInT,
typename Po
intOutT>
64 typedef boost::shared_ptr<IntegralImageNormalEstimation<PointInT, PointOutT> >
Ptr;
65 typedef boost::shared_ptr<const IntegralImageNormalEstimation<PointInT, PointOutT> >
ConstPtr;
100 , rect_width_ (0), rect_width_2_ (0), rect_width_4_ (0)
101 , rect_height_ (0), rect_height_2_ (0), rect_height_4_ (0)
102 , distance_threshold_ (0)
103 , integral_image_DX_ (false)
104 , integral_image_DY_ (false)
105 , integral_image_depth_ (false)
106 , integral_image_XYZ_ (true)
110 , distance_map_ (NULL)
111 , use_depth_dependent_smoothing_ (false)
112 , max_depth_change_factor_ (20.0f*0.001f)
113 , normal_smoothing_size_ (10.0f)
114 , init_covariance_matrix_ (false)
115 , init_average_3d_gradient_ (false)
116 , init_simple_3d_gradient_ (false)
117 , init_depth_change_ (false)
121 , use_sensor_origin_ (true)
144 border_policy_ = border_policy;
154 computePointNormal (
const int pos_x,
const int pos_y,
const unsigned point_index, PointOutT &normal);
172 max_depth_change_factor_ = max_depth_change_factor;
182 if (normal_smoothing_size <= 0)
184 PCL_ERROR (
"[pcl::%s::setNormalSmoothingSize] Invalid normal smoothing size given! (%f). Allowed ranges are: 0 < N. Defaulting to %f.\n",
185 feature_name_.c_str (), normal_smoothing_size, normal_smoothing_size_);
188 normal_smoothing_size_ = normal_smoothing_size;
206 normal_estimation_method_ = normal_estimation_method;
215 use_depth_dependent_smoothing_ = use_depth_dependent_smoothing;
225 if (!cloud->isOrganized ())
227 PCL_ERROR (
"[pcl::IntegralImageNormalEstimation::setInputCloud] Input dataset is not organized (height = 1).\n");
231 init_covariance_matrix_ = init_average_3d_gradient_ = init_depth_change_ =
false;
233 if (use_sensor_origin_)
235 vpx_ =
input_->sensor_origin_.coeff (0);
236 vpy_ =
input_->sensor_origin_.coeff (1);
237 vpz_ =
input_->sensor_origin_.coeff (2);
249 return (distance_map_);
263 use_sensor_origin_ =
false;
289 use_sensor_origin_ =
true;
292 vpx_ =
input_->sensor_origin_.coeff (0);
293 vpy_ =
input_->sensor_origin_.coeff (1);
294 vpz_ =
input_->sensor_origin_.coeff (2);
329 flipNormalTowardsViewpoint (
const PointInT &point,
330 float vp_x,
float vp_y,
float vp_z,
331 float &nx,
float &ny,
float &nz)
339 float cos_theta = (vp_x * nx + vp_y * ny + vp_z * nz);
371 float distance_threshold_;
374 IntegralImage2D<float, 3> integral_image_DX_;
376 IntegralImage2D<float, 3> integral_image_DY_;
378 IntegralImage2D<float, 1> integral_image_depth_;
380 IntegralImage2D<float, 3> integral_image_XYZ_;
391 float *distance_map_;
394 bool use_depth_dependent_smoothing_;
397 float max_depth_change_factor_;
400 float normal_smoothing_size_;
403 bool init_covariance_matrix_;
406 bool init_average_3d_gradient_;
409 bool init_simple_3d_gradient_;
412 bool init_depth_change_;
416 float vpx_, vpy_, vpz_;
419 bool use_sensor_origin_;
427 initCovarianceMatrixMethod ();
431 initAverage3DGradientMethod ();
435 initAverageDepthChangeMethod ();
439 initSimple3DGradientMethod ();
442 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
445 #if defined BUILD_Maintainer && defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ > 3
446 #pragma GCC diagnostic warning "-Weffc++"
449 #ifdef PCL_NO_PRECOMPILE
450 #include <pcl/features/impl/integral_image_normal.hpp>
void setViewPoint(float vpx, float vpy, float vpz)
Set the viewpoint.
void initData()
Initialize the data structures, based on the normal estimation method chosen.
void useSensorOriginAsViewPoint()
sets whether the sensor origin or a user given viewpoint should be used.
virtual void setInputCloud(const typename PointCloudIn::ConstPtr &cloud)
Provide a pointer to the input dataset (overwrites the PCLBase::setInputCloud method) ...
std::string feature_name_
The feature name.
Feature represents the base feature class.
float * getDistanceMap()
Returns a pointer to the distance map which was computed internally.
void setBorderPolicy(const BorderPolicy border_policy)
Sets the policy for handling borders.
Surface normal estimation on organized data using integral images.
Feature< PointInT, PointOutT >::PointCloudIn PointCloudIn
void computeFeature(PointCloudOut &output)
Computes the normal for the complete cloud.
void computePointNormal(const int pos_x, const int pos_y, const unsigned point_index, PointOutT &normal)
Computes the normal at the specified position.
virtual ~IntegralImageNormalEstimation()
Destructor.
void setNormalSmoothingSize(float normal_smoothing_size)
Set the normal smoothing size.
KdTreePtr tree_
A pointer to the spatial search object.
IntegralImageNormalEstimation()
Constructor.
Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
void setMaxDepthChangeFactor(float max_depth_change_factor)
The depth change threshold for computing object borders.
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
void getViewPoint(float &vpx, float &vpy, float &vpz)
Get the viewpoint.
void setNormalEstimationMethod(NormalEstimationMethod normal_estimation_method)
Set the normal estimation method.
int k_
The number of K nearest neighbors to use for each point.
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. ...
BorderPolicy
Different types of border handling.
void setRectSize(const int width, const int height)
Set the regions size which is considered for normal estimation.
boost::shared_ptr< IntegralImageNormalEstimation< PointInT, PointOutT > > Ptr
boost::shared_ptr< const IntegralImageNormalEstimation< PointInT, PointOutT > > ConstPtr
PointCloudConstPtr input_
The input point cloud dataset.
void setDepthDependentSmoothing(bool use_depth_dependent_smoothing)
Set whether to use depth depending smoothing or not.
NormalEstimationMethod
Different normal estimation methods.