42 #include <pcl/recognition/cg/correspondence_grouping.h>
47 #include <unordered_map>
63 using Ptr = shared_ptr<HoughSpace3D>;
64 using ConstPtr = shared_ptr<const HoughSpace3D>;
72 HoughSpace3D (
const Eigen::Vector3d &min_coord,
const Eigen::Vector3d &bin_size,
const Eigen::Vector3d &max_coord);
86 vote (
const Eigen::Vector3d &single_vote_coord,
double weight,
int voter_id);
96 voteInt (
const Eigen::Vector3d &single_vote_coord,
double weight,
int voter_id);
107 findMaxima (
double min_threshold, std::vector<double> & maxima_values, std::vector<std::vector<int> > &maxima_voter_ids);
121 int partial_bin_products_[4]{};
124 int total_bins_count_{0};
147 template<
typename Po
intModelT,
typename Po
intSceneT,
typename Po
intModelRfT = pcl::ReferenceFrame,
typename Po
intSceneRfT = pcl::ReferenceFrame>
416 recognize (std::vector<Eigen::Matrix4f, Eigen::aligned_allocator<Eigen::Matrix4f> > &transformations);
426 recognize (std::vector<Eigen::Matrix4f, Eigen::aligned_allocator<Eigen::Matrix4f> > &transformations, std::vector<pcl::Correspondences> &clustered_corrs);
443 std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f> >
model_votes_;
501 template<
typename Po
intType,
typename Po
intRfType>
void
506 #ifdef PCL_NO_PRECOMPILE
507 #include <pcl/recognition/impl/cg/hough_3d.hpp>
Abstract base class for Correspondence Grouping algorithms.
CorrespondencesConstPtr model_scene_corrs_
The correspondences between points in the input and the scene datasets.
SceneCloudConstPtr scene_
The scene cloud.
typename SceneCloud::ConstPtr SceneCloudConstPtr
Class implementing a 3D correspondence grouping algorithm that can deal with multiple instances of a ...
void setUseInterpolation(bool use_interpolation)
Sets whether the vote casting procedure interpolates the score between neighboring bins of the Hough ...
ModelRfCloudConstPtr getInputRf() const
Getter for the input dataset's reference frames.
bool getUseDistanceWeight() const
Gets whether the vote casting procedure uses the correspondence's distance as a score.
float local_rf_normals_search_radius_
Normals search radius for the potential Rf calculation.
bool getUseInterpolation() const
Gets whether the vote casting procedure interpolates the score between neighboring bins of the Hough ...
void setLocalRfNormalsSearchRadius(float local_rf_normals_search_radius)
If the Local reference frame has not been set for either the model cloud or the scene cloud,...
void setLocalRfSearchRadius(float local_rf_search_radius)
If the Local reference frame has not been set for either the model cloud or the scene cloud,...
typename SceneRfCloud::ConstPtr SceneRfCloudConstPtr
void setSceneRf(const SceneRfCloudConstPtr &scene_rf)
Provide a pointer to the scene dataset's reference frames.
float getLocalRfNormalsSearchRadius() const
If the Local reference frame has not been set for either the model cloud or the scene cloud,...
bool recognize(std::vector< Eigen::Matrix4f, Eigen::aligned_allocator< Eigen::Matrix4f > > &transformations)
The main function, recognizes instances of the model into the scene set by the user.
double hough_threshold_
The minimum number of votes in the Hough space needed to infer the presence of a model instance into ...
typename ModelRfCloud::Ptr ModelRfCloudPtr
typename SceneRfCloud::Ptr SceneRfCloudPtr
bool use_distance_weight_
Use the weighted correspondence distance when casting votes.
double getHoughThreshold() const
Gets the minimum number of votes in the Hough space needed to infer the presence of a model instance ...
bool houghVoting()
The Hough space voting procedure.
bool needs_training_
If the training of the Hough space is needed; set on change of either the input cloud or the input_rf...
void setInputCloud(const PointCloudConstPtr &cloud) override
Provide a pointer to the input dataset.
bool train()
Call this function after setting the input, the input_rf and the hough_bin_size parameters to perform...
float getLocalRfSearchRadius() const
If the Local reference frame has not been set for either the model cloud or the scene cloud,...
bool hough_space_initialized_
Whether the Hough space already contains the correct votes for the current input parameters and so th...
double hough_bin_size_
The size of each bin of the hough space.
typename ModelRfCloud::ConstPtr ModelRfCloudConstPtr
typename PointCloud::ConstPtr PointCloudConstPtr
std::vector< Eigen::Vector3f, Eigen::aligned_allocator< Eigen::Vector3f > > model_votes_
The result of the training.
void setHoughBinSize(double bin_size)
Sets the size of each bin into the Hough space.
double getHoughBinSize() const
Gets the size of each bin into the Hough space.
void setInputRf(const ModelRfCloudConstPtr &input_rf)
Provide a pointer to the input dataset's reference frames.
std::vector< Eigen::Matrix4f, Eigen::aligned_allocator< Eigen::Matrix4f > > found_transformations_
Transformations found by clusterCorrespondences method.
void computeRf(const typename pcl::PointCloud< PointType >::ConstPtr &input, pcl::PointCloud< PointRfType > &rf)
Computes the reference frame for an input cloud.
void setSceneCloud(const SceneCloudConstPtr &scene) override
Provide a pointer to the scene dataset (i.e.
pcl::recognition::HoughSpace3D::Ptr hough_space_
The Hough space.
ModelRfCloudConstPtr input_rf_
The input Rf cloud.
void setHoughThreshold(double threshold)
Sets the minimum number of votes in the Hough space needed to infer the presence of a model instance ...
void setUseDistanceWeight(bool use_distance_weight)
Sets whether the vote casting procedure uses the correspondence's distance as a score.
Hough3DGrouping()
Constructor.
typename PointCloud::Ptr PointCloudPtr
SceneRfCloudConstPtr getSceneRf() const
Getter for the scene dataset's reference frames.
void setModelSceneCorrespondences(const CorrespondencesConstPtr &corrs) override
Provide a pointer to the precomputed correspondences between points in the input dataset and points i...
float local_rf_search_radius_
Search radius for the potential Rf calculation.
bool use_interpolation_
Use the interpolation between neighboring Hough bins when casting votes.
SceneRfCloudConstPtr scene_rf_
The scene Rf cloud.
void clusterCorrespondences(std::vector< Correspondences > &model_instances) override
Cluster the input correspondences in order to distinguish between different instances of the model in...
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
PointCloud represents the base class in PCL for storing collections of 3D points.
shared_ptr< PointCloud< PointT > > Ptr
shared_ptr< const PointCloud< PointT > > ConstPtr
HoughSpace3D is a 3D voting space.
void reset()
Reset all cast votes.
Eigen::Vector3i bin_count_
Number of bins for each dimension.
double findMaxima(double min_threshold, std::vector< double > &maxima_values, std::vector< std::vector< int > > &maxima_voter_ids)
Find the bins with most votes.
int vote(const Eigen::Vector3d &single_vote_coord, double weight, int voter_id)
Casting a vote for a given position in the Hough space.
std::vector< double > hough_space_
The Hough Space.
std::unordered_map< int, std::vector< int > > voter_ids_
List of voters for each bin.
int voteInt(const Eigen::Vector3d &single_vote_coord, double weight, int voter_id)
Vote for a given position in the 3D space.
HoughSpace3D(const Eigen::Vector3d &min_coord, const Eigen::Vector3d &bin_size, const Eigen::Vector3d &max_coord)
Constructor.
Eigen::Vector3d min_coord_
Minimum coordinate in the Hough Space.
shared_ptr< HoughSpace3D > Ptr
Eigen::Vector3d bin_size_
Size of each bin in the Hough Space.
shared_ptr< const HoughSpace3D > 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.
shared_ptr< const Correspondences > CorrespondencesConstPtr
Defines all the PCL and non-PCL macros used.