Point Cloud Library (PCL)
1.3.1
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2009, Willow Garage, Inc. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of Willow Garage, Inc. nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 * Author: Siddharth Choudhary (itzsid@gmail.com) 00035 * 00036 */ 00037 00038 #ifndef PCL_SEARCH_AUTO_TUNED_SEARCH_H_ 00039 #define PCL_SEARCH_AUTO_TUNED_SEARCH_H_ 00040 00041 #include <limits.h> 00042 #include <pcl/pcl_base.h> 00043 #include "pcl/pcl_macros.h" 00044 #include "pcl/point_cloud.h" 00045 #include "pcl/point_representation.h" 00046 #include "pcl/search/pcl_search.h" 00047 00048 namespace pcl 00049 { 00050 namespace search 00051 { 00052 enum SearchType 00053 { 00054 KDTREE, ORGANIZED_INDEX, OCTREE, AUTO_TUNED, NEAREST_K_SEARCH, NEAREST_RADIUS_SEARCH 00055 }; 00056 00061 template<typename PointT> 00062 class AutotunedSearch : public pcl::search::Search<PointT> 00063 { 00064 public: 00065 typedef pcl::PointCloud<PointT> PointCloud; 00066 typedef boost::shared_ptr<PointCloud> PointCloudPtr; 00067 typedef boost::shared_ptr<const PointCloud> PointCloudConstPtr; 00068 00069 typedef boost::shared_ptr<pcl::search::Search<PointT> > SearchPtr; 00070 typedef boost::shared_ptr<const pcl::search::Search<PointT> > SearchConstPtr; 00071 00072 typedef boost::shared_ptr<std::vector<int> > IndicesPtr; 00073 typedef boost::shared_ptr<const std::vector<int> > IndicesConstPtr; 00074 00076 AutotunedSearch (int spatial_locator) : 00077 search_ () 00078 { 00079 initSearchDS (spatial_locator); 00080 } 00081 /* Constructor */ 00082 AutotunedSearch () : 00083 search_ () 00084 { 00085 } 00086 00087 /* Destructor */ 00088 virtual 00089 ~AutotunedSearch () 00090 { 00091 } 00092 00096 void 00097 initSearchDS (int spatial_locator); 00098 00103 void 00104 evaluateSearchMethods (const PointCloudConstPtr& cloud, const int search_type); 00105 00110 virtual void 00111 setInputCloud (const PointCloudConstPtr& cloud, const IndicesConstPtr& indices); 00112 00113 virtual PointCloudConstPtr 00114 getInputCloud () 00115 { 00116 return (input_); 00117 } 00118 00119 virtual IndicesConstPtr const 00120 getIndices () 00121 { 00122 return (indices_); 00123 } 00124 00128 virtual void 00129 setInputCloud (const PointCloudConstPtr& cloud); 00130 00139 int 00140 nearestKSearch (const PointT& point, int k, std::vector<int> &k_indices, std::vector<float> &k_sqr_distances); 00141 00151 virtual int 00152 nearestKSearch (const PointCloud& cloud, int index, int k, std::vector<int>& k_indices, 00153 std::vector<float>& k_sqr_distances); 00154 00164 virtual int 00165 nearestKSearch (int index, int k, std::vector<int>& k_indices, std::vector<float>& k_sqr_distances); 00166 00174 inline int 00175 nearestKSearch (std::vector<PointT, Eigen::aligned_allocator<PointT> >& point, std::vector<int>& k, 00176 std::vector<std::vector<int> >& k_indices, std::vector<std::vector<float> >& k_sqr_distances) 00177 { 00178 PCL_ERROR("[pcl::search::AutotunedSearch::nearestKSearch] This function is not supported by AutotunedSearch\n"); 00179 return (0); 00180 } 00181 00190 virtual int 00191 radiusSearch (const PointT& point, const double radius, std::vector<int>& k_indices, 00192 std::vector<float>& k_distances, int max_nn = -1) const; 00193 00204 virtual int 00205 radiusSearch (const PointCloud& cloud, int index, double radius, std::vector<int>& k_indices, 00206 std::vector<float>& k_distances, int max_nn = -1); 00207 00217 virtual int 00218 radiusSearch (int index, double radius, std::vector<int>& k_indices, std::vector<float>& k_distances, 00219 int max_nn = -1) const; 00220 00228 virtual void 00229 approxNearestSearch (const PointCloudConstPtr &cloud_arg, int query_index_arg, int &result_index_arg, 00230 float &sqr_distance_arg); 00231 00237 virtual void 00238 approxNearestSearch (const PointT &p_q_arg, int &result_index_arg, float &sqr_distance_arg); 00239 00246 virtual void 00247 approxNearestSearch (int query_index_arg, int &result_index_arg, float &sqr_distance_arg); 00248 00257 inline int 00258 radiusSearch (std::vector<PointT, Eigen::aligned_allocator<PointT> > &point, std::vector<double> &radiuses, 00259 std::vector<std::vector<int> > &k_indices, std::vector<std::vector<float> > &k_distances, 00260 int max_nn) const 00261 { 00262 PCL_ERROR("[pcl::search::AutotunedSearch::radiusSearch] This function is not supported by AutotunedSearch\n"); 00263 return (0); 00264 } 00265 00275 inline int 00276 approxRadiusSearch (const PointCloudConstPtr &cloud, int index, double radius, std::vector<int> &k_indices, 00277 std::vector<float> &k_distances, int max_nn) const 00278 { 00279 PCL_ERROR("[pcl::search::AutotunedSearch::approxRadiusSearch] This function is not supported by AutotunedSearch\n"); 00280 return (0); 00281 } 00291 inline int 00292 approxNearestKSearch (const PointCloudConstPtr &cloud, int index, int k, std::vector<int> &k_indices, 00293 std::vector<float> &k_sqr_distances) 00294 { 00295 PCL_ERROR("[pcl::search::AutotunedSearch::approxNearestKSearch] This function is not supported by AutotunedSearch\n"); 00296 return (0); 00297 } 00298 00299 private: 00300 00301 SearchPtr search_; 00302 00303 int spatial_loc_; 00304 00305 PointCloudConstPtr input_; 00306 IndicesConstPtr indices_; 00307 }; 00308 } 00309 } 00310 00311 #endif //#ifndef _PCL_SEARCH_AUTO_TUNED_SEARCH_H_