40#include <Eigen/src/Core/Matrix.h>
44#include <pcl/point_representation.h>
45#include <pcl/features/feature.h>
46#include <pcl/kdtree/kdtree_flann.h>
69 template <
typename Po
intT>
74 using Ptr = shared_ptr<ISMVoteList<PointT> >;
75 using ConstPtr = shared_ptr<const ISMVoteList<PointT>>;
106 findStrongestPeaks (std::vector<
ISMPeak, Eigen::aligned_allocator<ISMPeak> > &out_peaks,
int in_class_id,
double in_non_maxima_radius,
double in_sigma);
126 shiftMean (
const Eigen::Vector3f& snapPt,
const double in_dSigmaDist);
157 using Ptr = shared_ptr<ISMModel>;
240 template <
int FeatureSize,
typename Po
intT,
typename NormalT = pcl::Normal>
260 LocationInfo (
unsigned int model_num,
const PointT& dir_to_center,
const PointT& origin,
const NormalT& normal) :
342 std::vector<typename pcl::PointCloud<PointT>::Ptr>
352 std::vector<unsigned int>
362 std::vector<typename pcl::PointCloud<NormalT>::Ptr>
454 std::vector<
LocationInfo, Eigen::aligned_allocator<LocationInfo> >& locations);
482 const Eigen::MatrixXi &labels,
483 std::vector<float>& sigmas,
484 std::vector<std::vector<unsigned int> >& clusters,
485 std::vector<std::vector<float> >& statistical_weights,
486 std::vector<float>& learned_weights);
520 applyTransform (Eigen::Vector3f& io_vec,
const Eigen::Matrix3f& in_transform);
544 int number_of_clusters,
545 Eigen::MatrixXi& io_labels,
549 Eigen::MatrixXf& cluster_centers);
560 Eigen::MatrixXf& out_centers,
561 int number_of_clusters,
569 generateRandomCenter (
const std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> >& boxes, Eigen::VectorXf& center);
626 (
float, density, ism_density)
627 (
float, class_id, ism_class_id)
Feature represents the base feature class.
shared_ptr< Feature< PointT, pcl::Histogram< FeatureSize > > > Ptr
shared_ptr< KdTreeFLANN< PointT, Dist > > Ptr
PointCloud represents the base class in PCL for storing collections of 3D points.
shared_ptr< PointCloud< PointT > > Ptr
shared_ptr< const PointCloud< PointT > > ConstPtr
Eigen::Vector3f shiftMean(const Eigen::Vector3f &snapPt, const double in_dSigmaDist)
shared_ptr< ISMVoteList< PointT > > Ptr
bool tree_is_valid_
Signalizes if the tree is valid.
void addVote(pcl::InterestPoint &in_vote, const PointT &vote_origin, int in_class)
This method simply adds another vote to the list.
void findStrongestPeaks(std::vector< ISMPeak, Eigen::aligned_allocator< ISMPeak > > &out_peaks, int in_class_id, double in_non_maxima_radius, double in_sigma)
This method finds the strongest peaks (points were density has most higher values).
std::vector< float > k_sqr_dist_
Stores square distances to the corresponding neighbours.
pcl::KdTreeFLANN< pcl::InterestPoint >::Ptr tree_
Stores the search tree.
std::vector< int > votes_class_
Stores classes for which every single vote was cast.
shared_ptr< const ISMVoteList< PointT > > ConstPtr
pcl::PointCloud< PointT >::Ptr votes_origins_
Stores the origins of the votes.
pcl::Indices k_ind_
Stores neighbours indices.
pcl::PointCloud< pcl::PointXYZRGB >::Ptr getColoredCloud(typename pcl::PointCloud< PointT >::Ptr cloud=0)
Returns the colored cloud that consists of votes for center (blue points) and initial point cloud (if...
pcl::PointCloud< pcl::InterestPoint >::Ptr votes_
Stores all votes.
unsigned int getNumberOfVotes()
This method simply returns the number of votes.
void validateTree()
this method is simply setting up the search tree.
double getDensityAtPoint(const PointT &point, double sigma_dist)
Returns the density at the specified point.
ISMVoteList()
Empty constructor with member variables initialization.
bool trainISM(ISMModelPtr &trained_model)
This method performs training and forms a visual vocabulary.
typename Feature::Ptr FeaturePtr
void applyTransform(Eigen::Vector3f &io_vec, const Eigen::Matrix3f &in_transform)
This method applies transform set in in_transform to vector io_vector.
Eigen::Matrix3f alignYCoordWithNormal(const NormalT &in_normal)
This method simply computes the rotation matrix, so that the given normal would match the Y axis afte...
std::vector< typename pcl::PointCloud< PointT >::Ptr > getTrainingClouds()
This method simply returns the clouds that were set as the training clouds.
void generateRandomCenter(const std::vector< Eigen::Vector2f, Eigen::aligned_allocator< Eigen::Vector2f > > &boxes, Eigen::VectorXf ¢er)
Generates random center for cluster.
void setFeatureEstimator(FeaturePtr feature)
Changes the feature estimator.
void setTrainingClouds(const std::vector< typename pcl::PointCloud< PointT >::Ptr > &training_clouds)
Allows to set clouds for training the ISM model.
void setNVotState(bool state)
Changes the state of the Nvot coeff from [Knopp et al., 2010, (4)].
float computeDistance(Eigen::VectorXf &vec_1, Eigen::VectorXf &vec_2)
Computes the square distance between two vectors.
void shiftCloud(typename pcl::PointCloud< PointT >::Ptr in_cloud, Eigen::Vector3f shift_point)
This method simply shifts the clouds points relative to the passed point.
pcl::features::ISMModel::Ptr ISMModelPtr
bool getNVotState()
Returns the state of Nvot coeff from [Knopp et al., 2010, (4)], if set to false then coeff is taken a...
std::vector< unsigned int > training_classes_
Stores the class number for each cloud from training_clouds_.
void setTrainingNormals(const std::vector< typename pcl::PointCloud< NormalT >::Ptr > &training_normals)
Allows to set normals for the training clouds that were passed through setTrainingClouds method.
void generateCentersPP(const Eigen::MatrixXf &data, Eigen::MatrixXf &out_centers, int number_of_clusters, int trials)
Generates centers for clusters as described in Arthur, David and Sergei Vassilvitski (2007) k-means++...
ImplicitShapeModelEstimation()
Simple constructor that initializes everything.
double computeKMeansClustering(const Eigen::MatrixXf &points_to_cluster, int number_of_clusters, Eigen::MatrixXi &io_labels, TermCriteria criteria, int attempts, int flags, Eigen::MatrixXf &cluster_centers)
Performs K-means clustering.
pcl::Feature< PointT, pcl::Histogram< FeatureSize > > Feature
std::vector< typename pcl::PointCloud< NormalT >::Ptr > training_normals_
Stores the normals for each training cloud.
std::vector< unsigned int > getTrainingClasses()
Returns the array of classes that indicates which class the corresponding training cloud belongs.
void calculateWeights(const std::vector< LocationInfo, Eigen::aligned_allocator< LocationInfo > > &locations, const Eigen::MatrixXi &labels, std::vector< float > &sigmas, std::vector< std::vector< unsigned int > > &clusters, std::vector< std::vector< float > > &statistical_weights, std::vector< float > &learned_weights)
This function forms a visual vocabulary and evaluates weights described in [Knopp et al....
static const int PP_CENTERS
This const value is used for indicating that for k-means clustering centers must be generated as desc...
void estimateFeatures(typename pcl::PointCloud< PointT >::Ptr sampled_point_cloud, typename pcl::PointCloud< NormalT >::Ptr normal_cloud, typename pcl::PointCloud< pcl::Histogram< FeatureSize > >::Ptr feature_cloud)
This method estimates features for the given point cloud.
bool extractDescriptors(std::vector< pcl::Histogram< FeatureSize > > &histograms, std::vector< LocationInfo, Eigen::aligned_allocator< LocationInfo > > &locations)
Extracts the descriptors from the input clouds.
FeaturePtr getFeatureEstimator()
Returns the current feature estimator used for extraction of the descriptors.
bool n_vot_ON_
If set to false then Nvot coeff from [Knopp et al., 2010, (4)] is equal 1.0.
unsigned int getNumberOfClusters()
Returns the number of clusters used for descriptor clustering.
void calculateSigmas(std::vector< float > &sigmas)
This method calculates the value of sigma used for calculating the learned weights for every single c...
unsigned int number_of_clusters_
Number of clusters, is used for clustering descriptors during the training.
void setNumberOfClusters(unsigned int num_of_clusters)
Changes the number of clusters.
bool clusterDescriptors(std::vector< pcl::Histogram< FeatureSize > > &histograms, Eigen::MatrixXi &labels, Eigen::MatrixXf &clusters_centers)
This method performs descriptor clustering.
std::vector< float > getSigmaDists()
Returns the array of sigma values.
static const int USE_INITIAL_LABELS
This const value is used for indicating that input labels must be taken as the initial approximation ...
Feature::Ptr feature_estimator_
Stores the feature estimator.
float sampling_size_
This value is used for the simplification.
void setSamplingSize(float sampling_size)
Changes the sampling size used for cloud simplification.
std::vector< float > training_sigmas_
This array stores the sigma values for each training class.
std::vector< typename pcl::PointCloud< PointT >::Ptr > training_clouds_
Stores the clouds used for training.
pcl::features::ISMVoteList< PointT >::Ptr findObjects(ISMModelPtr model, typename pcl::PointCloud< PointT >::Ptr in_cloud, typename pcl::PointCloud< Normal >::Ptr in_normals, int in_class_of_interest)
This function is searching for the class of interest in a given cloud and returns the list of votes.
void simplifyCloud(typename pcl::PointCloud< PointT >::ConstPtr in_point_cloud, typename pcl::PointCloud< NormalT >::ConstPtr in_normal_cloud, typename pcl::PointCloud< PointT >::Ptr out_sampled_point_cloud, typename pcl::PointCloud< NormalT >::Ptr out_sampled_normal_cloud)
Simplifies the cloud using voxel grid principles.
void setSigmaDists(const std::vector< float > &training_sigmas)
This method allows to set the value of sigma used for calculating the learned weights for every singl...
std::vector< typename pcl::PointCloud< NormalT >::Ptr > getTrainingNormals()
This method returns the corresponding cloud of normals for every training point cloud.
void setTrainingClasses(const std::vector< unsigned int > &training_classes)
Allows to set the class labels for the corresponding training clouds.
float getSamplingSize()
Returns the sampling size used for cloud simplification.
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.
IndicesAllocator<> Indices
Type used for indices in PCL.
Defines all the PCL and non-PCL macros used.
A point structure representing an N-D histogram.
This struct is used for storing peak.
PCL_ADD_POINT4D
Point were this peak is located.
double density
Density of this peak.
int class_id
Determines which class this peak belongs.
A point structure representing an interest point with Euclidean xyz coordinates, and an interest valu...
A point structure representing Euclidean xyz coordinates.
shared_ptr< ISMModel > Ptr
unsigned int number_of_clusters_
Stores the number of clusters.
shared_ptr< const ISMModel > ConstPtr
Eigen::MatrixXf clusters_centers_
Stores the centers of the clusters that were obtained during the visual words clusterization.
ISMModel()
Simple constructor that initializes the structure.
bool loadModelFromfile(std::string &file_name)
This method loads the trained model from file.
unsigned int descriptors_dimension_
Stores descriptors dimension.
std::vector< float > sigmas_
Stores the sigma value for each class.
std::vector< float > learned_weights_
Stores learned weights.
void reset()
this method resets all variables and frees memory.
std::vector< std::vector< unsigned int > > clusters_
This is an array of clusters.
bool saveModelToFile(std::string &file_name)
This method simply saves the trained model for later usage.
std::vector< unsigned int > classes_
Stores the class label for every direction.
Eigen::MatrixXf directions_to_center_
Stores the directions to objects center for each visual word.
unsigned int number_of_classes_
Stores the number of classes.
std::vector< std::vector< float > > statistical_weights_
Stores statistical weights.
unsigned int number_of_visual_words_
Stores the number of visual words.
This structure stores the information about the keypoint.
NormalT normal_
Stores the normal of the initial point.
unsigned int model_num_
Tells from which training model this keypoint was extracted.
PointT point_
Stores the initial point.
LocationInfo(unsigned int model_num, const PointT &dir_to_center, const PointT &origin, const NormalT &normal)
Location info constructor.
PointT dir_to_center_
Expected direction to center for this keypoint.
This structure is used for determining the end of the k-means clustering process.
int type_
Flag that determines when the k-means clustering must be stopped.
float epsilon_
Defines the accuracy for k-means clustering.
TermCriteria(int type, int max_count, float epsilon)
Termination criteria constructor.
int max_count_
Defines maximum number of iterations for k-means clustering.
pcl::PointXYZ dir_to_center_
Expected direction to center.
float learned_weight_
Weight of the vote.
VisualWordStat()
Empty constructor with member variables initialization.
int class_
Which class this vote belongs.