Point Cloud Library (PCL)  1.14.0-dev
rift.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2011, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  * $Id$
38  *
39  */
40 
41 #pragma once
42 
43 #include <pcl/features/feature.h>
44 
45 namespace pcl
46 {
47  /** \brief RIFTEstimation estimates the Rotation Invariant Feature Transform descriptors for a given point cloud
48  * dataset containing points and intensity. For more information about the RIFT descriptor, see:
49  *
50  * Svetlana Lazebnik, Cordelia Schmid, and Jean Ponce.
51  * A sparse texture representation using local affine regions.
52  * In IEEE Transactions on Pattern Analysis and Machine Intelligence, volume 27, pages 1265-1278, August 2005.
53  *
54  * \author Michael Dixon
55  * \ingroup features
56  */
57 
58  template <typename PointInT, typename GradientT, typename PointOutT>
59  class RIFTEstimation: public Feature<PointInT, PointOutT>
60  {
61  public:
64 
67 
70 
73 
77 
78  using Ptr = shared_ptr<RIFTEstimation<PointInT, GradientT, PointOutT> >;
79  using ConstPtr = shared_ptr<const RIFTEstimation<PointInT, GradientT, PointOutT> >;
80 
81 
82  /** \brief Empty constructor. */
84  {
85  feature_name_ = "RIFTEstimation";
86  }
87 
88  /** \brief Provide a pointer to the input gradient data
89  * \param[in] gradient a pointer to the input gradient data
90  */
91  inline void
92  setInputGradient (const PointCloudGradientConstPtr &gradient) { gradient_ = gradient; };
93 
94  /** \brief Returns a shared pointer to the input gradient data */
96  getInputGradient () const { return (gradient_); };
97 
98  /** \brief Set the number of bins to use in the distance dimension of the RIFT descriptor
99  * \param[in] nr_distance_bins the number of bins to use in the distance dimension of the RIFT descriptor
100  */
101  inline void
102  setNrDistanceBins (int nr_distance_bins) { nr_distance_bins_ = nr_distance_bins; };
103 
104  /** \brief Returns the number of bins in the distance dimension of the RIFT descriptor. */
105  inline int
106  getNrDistanceBins () const { return (nr_distance_bins_); };
107 
108  /** \brief Set the number of bins to use in the gradient orientation dimension of the RIFT descriptor
109  * \param[in] nr_gradient_bins the number of bins to use in the gradient orientation dimension of the RIFT descriptor
110  */
111  inline void
112  setNrGradientBins (int nr_gradient_bins) { nr_gradient_bins_ = nr_gradient_bins; };
113 
114  /** \brief Returns the number of bins in the gradient orientation dimension of the RIFT descriptor. */
115  inline int
116  getNrGradientBins () const { return (nr_gradient_bins_); };
117 
118  /** \brief Estimate the Rotation Invariant Feature Transform (RIFT) descriptor for a given point based on its
119  * spatial neighborhood of 3D points and the corresponding intensity gradient vector field
120  * \param[in] cloud the dataset containing the Cartesian coordinates of the points
121  * \param[in] gradient the dataset containing the intensity gradient at each point in \a cloud
122  * \param[in] p_idx the index of the query point in \a cloud (i.e. the center of the neighborhood)
123  * \param[in] radius the radius of the RIFT feature
124  * \param[in] indices the indices of the points that comprise \a p_idx's neighborhood in \a cloud
125  * \param[in] squared_distances the squared distances from the query point to each point in the neighborhood
126  * \param[out] rift_descriptor the resultant RIFT descriptor
127  */
128  void
129  computeRIFT (const PointCloudIn &cloud, const PointCloudGradient &gradient, int p_idx, float radius,
130  const pcl::Indices &indices, const std::vector<float> &squared_distances,
131  Eigen::MatrixXf &rift_descriptor);
132 
133  protected:
134 
135  /** \brief Estimate the Rotation Invariant Feature Transform (RIFT) descriptors at a set of points given by
136  * <setInputCloud (), setIndices ()> using the surface in setSearchSurface (), the gradient in
137  * setInputGradient (), and the spatial locator in setSearchMethod ()
138  * \param[out] output the resultant point cloud model dataset that contains the RIFT feature estimates
139  */
140  void
141  computeFeature (PointCloudOut &output) override;
142 
143  /** \brief The intensity gradient of the input point cloud data*/
145 
146  /** \brief The number of distance bins in the descriptor. */
148 
149  /** \brief The number of gradient orientation bins in the descriptor. */
151  };
152 }
153 
154 #ifdef PCL_NO_PRECOMPILE
155 #include <pcl/features/impl/rift.hpp>
156 #endif
Feature represents the base feature class.
Definition: feature.h:107
shared_ptr< Feature< PointInT, PointOutT > > Ptr
Definition: feature.h:114
std::string feature_name_
The feature name.
Definition: feature.h:220
shared_ptr< const Feature< PointInT, PointOutT > > ConstPtr
Definition: feature.h:115
shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:413
shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:414
RIFTEstimation estimates the Rotation Invariant Feature Transform descriptors for a given point cloud...
Definition: rift.h:60
pcl::PointCloud< PointInT > PointCloudIn
Definition: rift.h:71
void setNrGradientBins(int nr_gradient_bins)
Set the number of bins to use in the gradient orientation dimension of the RIFT descriptor.
Definition: rift.h:112
void computeFeature(PointCloudOut &output) override
Estimate the Rotation Invariant Feature Transform (RIFT) descriptors at a set of points given by <set...
Definition: rift.hpp:113
RIFTEstimation()
Empty constructor.
Definition: rift.h:83
pcl::PointCloud< GradientT > PointCloudGradient
Definition: rift.h:74
int nr_distance_bins_
The number of distance bins in the descriptor.
Definition: rift.h:147
PointCloudGradientConstPtr gradient_
The intensity gradient of the input point cloud data.
Definition: rift.h:144
void setNrDistanceBins(int nr_distance_bins)
Set the number of bins to use in the distance dimension of the RIFT descriptor.
Definition: rift.h:102
int getNrDistanceBins() const
Returns the number of bins in the distance dimension of the RIFT descriptor.
Definition: rift.h:106
void setInputGradient(const PointCloudGradientConstPtr &gradient)
Provide a pointer to the input gradient data.
Definition: rift.h:92
typename PointCloudGradient::ConstPtr PointCloudGradientConstPtr
Definition: rift.h:76
int nr_gradient_bins_
The number of gradient orientation bins in the descriptor.
Definition: rift.h:150
void computeRIFT(const PointCloudIn &cloud, const PointCloudGradient &gradient, int p_idx, float radius, const pcl::Indices &indices, const std::vector< float > &squared_distances, Eigen::MatrixXf &rift_descriptor)
Estimate the Rotation Invariant Feature Transform (RIFT) descriptor for a given point based on its sp...
Definition: rift.hpp:48
typename PointCloudGradient::Ptr PointCloudGradientPtr
Definition: rift.h:75
PointCloudGradientConstPtr getInputGradient() const
Returns a shared pointer to the input gradient data.
Definition: rift.h:96
typename Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition: rift.h:72
int getNrGradientBins() const
Returns the number of bins in the gradient orientation dimension of the RIFT descriptor.
Definition: rift.h:116
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition: types.h:133