Point Cloud Library (PCL)
1.3.1
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2010-2011, Willow Garage, Inc. 00006 * 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * * Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * * Redistributions in binary form must reproduce the above 00016 * copyright notice, this list of conditions and the following 00017 * disclaimer in the documentation and/or other materials provided 00018 * with the distribution. 00019 * * Neither the name of Willow Garage, Inc. nor the names of its 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00032 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00033 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 */ 00037 00038 #ifndef PCL_KEYPOINT_H_ 00039 #define PCL_KEYPOINT_H_ 00040 00041 // PCL includes 00042 #include "pcl/pcl_base.h" 00043 #include <boost/function.hpp> 00044 #include <boost/bind.hpp> 00045 #include "pcl/search/pcl_search.h" 00046 00047 namespace pcl 00048 { 00053 template <typename PointInT, typename PointOutT> 00054 class Keypoint : public PCLBase<PointInT> 00055 { 00056 public: 00057 using PCLBase<PointInT>::indices_; 00058 using PCLBase<PointInT>::input_; 00059 00060 typedef PCLBase<PointInT> BaseClass; 00061 typedef typename pcl::search::Search<PointInT> KdTree; 00062 typedef typename pcl::search::Search<PointInT>::Ptr KdTreePtr; 00063 typedef pcl::PointCloud<PointInT> PointCloudIn; 00064 typedef typename PointCloudIn::Ptr PointCloudInPtr; 00065 typedef typename PointCloudIn::ConstPtr PointCloudInConstPtr; 00066 typedef pcl::PointCloud<PointOutT> PointCloudOut; 00067 typedef boost::function<int (int, double, std::vector<int> &, std::vector<float> &)> SearchMethod; 00068 typedef boost::function<int (const PointCloudIn &cloud, int index, double, std::vector<int> &, std::vector<float> &)> SearchMethodSurface; 00069 00070 public: 00072 Keypoint () : BaseClass(), surface_ (), tree_ (), search_parameter_ (0), search_radius_ (0), k_ (0) {}; 00073 00077 inline void 00078 setSearchSurface (const PointCloudInConstPtr &cloud) { surface_ = cloud; } 00079 00081 inline PointCloudInConstPtr 00082 getSearchSurface () { return (surface_); } 00083 00087 inline void 00088 setSearchMethod (const KdTreePtr &tree) { tree_ = tree; } 00089 00091 inline KdTreePtr 00092 getSearchMethod () { return (tree_); } 00093 00095 inline double 00096 getSearchParameter () { return (search_parameter_); } 00097 00101 inline void 00102 setKSearch (int k) { k_ = k; } 00103 00105 inline int 00106 getKSearch () { return (k_); } 00107 00112 inline void 00113 setRadiusSearch (double radius) { search_radius_ = radius; } 00114 00116 inline double 00117 getRadiusSearch () { return (search_radius_); } 00118 00123 inline void 00124 compute (PointCloudOut &output); 00125 00134 inline int 00135 searchForNeighbors (int index, double parameter, std::vector<int> &indices, std::vector<float> &distances) 00136 { 00137 if (surface_ == input_) // if the two surfaces are the same 00138 return (search_method_ (index, parameter, indices, distances)); 00139 else 00140 return (search_method_surface_ (*input_, index, parameter, indices, distances)); 00141 } 00142 00143 protected: 00144 using PCLBase<PointInT>::deinitCompute; 00145 00146 virtual bool 00147 initCompute (); 00148 00150 std::string name_; 00151 00153 SearchMethod search_method_; 00154 00156 SearchMethodSurface search_method_surface_; 00157 00159 PointCloudInConstPtr surface_; 00160 00162 KdTreePtr tree_; 00163 00165 double search_parameter_; 00166 00168 double search_radius_; 00169 00171 int k_; 00172 00174 inline const std::string& 00175 getClassName () const { return (name_); } 00176 00178 virtual void 00179 detectKeypoints (PointCloudOut &output) = 0; 00180 }; 00181 } 00182 00183 #include <pcl/keypoints/impl/keypoint.hpp> 00184 00185 #endif //#ifndef PCL_KEYPOINT_H_