Point Cloud Library (PCL)  1.3.1
smoothed_surfaces_keypoint.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2011, Alexandru-Eugen Ichim
00005  *                      Willow Garage, Inc
00006  *  All rights reserved.
00007  *
00008  *  Redistribution and use in source and binary forms, with or without
00009  *  modification, are permitted provided that the following conditions
00010  *  are met:
00011  *
00012  *   * Redistributions of source code must retain the above copyright
00013  *     notice, this list of conditions and the following disclaimer.
00014  *   * Redistributions in binary form must reproduce the above
00015  *     copyright notice, this list of conditions and the following
00016  *     disclaimer in the documentation and/or other materials provided
00017  *     with the distribution.
00018  *   * Neither the name of Willow Garage, Inc. nor the names of its
00019  *     contributors may be used to endorse or promote products derived
00020  *     from this software without specific prior written permission.
00021  *
00022  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033  *  POSSIBILITY OF SUCH DAMAGE.
00034  *
00035  * $Id: smoothed_surfaces_keypoint.h 2127 2011-08-16 20:00:21Z aichim $
00036  */
00037 
00038 #ifndef PCL_SMOOTHEDSURFACESKEYPOINT_H_
00039 #define PCL_SMOOTHEDSURFACESKEYPOINT_H_
00040 
00041 #include "pcl/keypoints/keypoint.h"
00042 
00043 namespace pcl
00044 {
00054   template <typename PointT, typename PointNT>
00055   class SmoothedSurfacesKeypoint : public Keypoint <PointT, PointT>
00056   {
00057     public:
00058       using PCLBase<PointT>::input_;
00059       using Keypoint<PointT, PointT>::name_;
00060       using Keypoint<PointT, PointT>::tree_;
00061       using Keypoint<PointT, PointT>::initCompute;
00062 
00063       typedef pcl::PointCloud<PointT> PointCloudT;
00064       typedef typename PointCloudT::ConstPtr PointCloudTConstPtr;
00065       typedef pcl::PointCloud<PointNT> PointCloudNT;
00066       typedef typename PointCloudNT::ConstPtr PointCloudNTConstPtr;
00067       typedef typename PointCloudT::Ptr PointCloudTPtr;
00068       typedef typename Keypoint<PointT, PointT>::KdTreePtr KdTreePtr;
00069 
00070       SmoothedSurfacesKeypoint ()
00071         : Keypoint<PointT, PointT> (),
00072           neighborhood_constant_ (0.5f),
00073           normals_ ()
00074       {
00075         name_ = "SmoothedSurfacesKeypoint";
00076 
00077         // hack to pass the initCompute () check of Keypoint - although it is never used in SmoothedSurfacesKeypoint
00078         Keypoint<PointT, PointT>::search_radius_ = 0.1;
00079       }
00080 
00081       void
00082       addSmoothedPointCloud (const PointCloudTConstPtr &cloud,
00083                              const PointCloudNTConstPtr &normals,
00084                              KdTreePtr &kdtree,
00085                              float &scale);
00086 
00087 
00088       void
00089       resetClouds ();
00090 
00091       inline void
00092       setNeighborhoodConstant (float neighborhood_constant) { neighborhood_constant_ = neighborhood_constant; }
00093 
00094       inline float
00095       getNeighborhoodConstant () { return neighborhood_constant_; }
00096 
00097       inline void
00098       setInputNormals (const PointCloudNTConstPtr &normals) { normals_ = normals; }
00099 
00100       inline void
00101       setInputScale (float input_scale) { input_scale_ = input_scale; }
00102 
00103       void
00104       detectKeypoints (PointCloudT &output);
00105 
00106     protected:
00107       bool
00108       initCompute ();
00109 
00110     private:
00111       float neighborhood_constant_;
00112       std::vector<PointCloudTConstPtr> clouds_;
00113       std::vector<PointCloudNTConstPtr> cloud_normals_;
00114       std::vector<KdTreePtr> cloud_trees_;
00115       PointCloudNTConstPtr normals_;
00116       std::vector<std::pair<float, size_t> > scales_;
00117       float input_scale_;
00118       size_t input_index_;
00119 
00120       static bool
00121       compareScalesFunction (const std::pair<float, size_t> &a,
00122                              const std::pair<float, size_t> &b) { return a.first < b.first; }
00123   };
00124 }
00125 
00126 #endif /* PCL_SMOOTHEDSURFACESKEYPOINT_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines