|
Point Cloud Library (PCL)
1.5.1
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2010, 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 */ 00035 00036 #ifndef PCL_SIFT_KEYPOINT_H_ 00037 #define PCL_SIFT_KEYPOINT_H_ 00038 00039 #include <pcl/keypoints/keypoint.h> 00040 00041 namespace pcl 00042 { 00043 template<typename PointT> 00044 struct SIFTKeypointFieldSelector 00045 { 00046 inline float operator ()(const PointT & p) const 00047 { 00048 return p.intensity; 00049 } 00050 }; 00051 template<> 00052 struct SIFTKeypointFieldSelector<PointNormal> 00053 { 00054 inline float operator ()(const PointNormal & p) const 00055 { 00056 return p.curvature; 00057 } 00058 }; 00059 template<> 00060 struct SIFTKeypointFieldSelector<PointXYZRGB> 00061 { 00062 inline float operator ()(const PointXYZRGB & p) const 00063 { 00064 return ((299*p.r + 587*p.g + 114*p.b)/1000.0f); 00065 } 00066 }; 00067 template<> 00068 struct SIFTKeypointFieldSelector<PointXYZRGBA> 00069 { 00070 inline float operator ()(const PointXYZRGBA & p) const 00071 { 00072 return ((299*p.r + 587*p.g + 114*p.b)/1000.0f); 00073 } 00074 }; 00075 00089 template <typename PointInT, typename PointOutT> 00090 class SIFTKeypoint : public Keypoint<PointInT, PointOutT> 00091 { 00092 public: 00093 typedef typename Keypoint<PointInT, PointOutT>::PointCloudIn PointCloudIn; 00094 typedef typename Keypoint<PointInT, PointOutT>::PointCloudOut PointCloudOut; 00095 typedef typename Keypoint<PointInT, PointOutT>::KdTree KdTree; 00096 00097 using Keypoint<PointInT, PointOutT>::name_; 00098 using Keypoint<PointInT, PointOutT>::input_; 00099 using Keypoint<PointInT, PointOutT>::indices_; 00100 using Keypoint<PointInT, PointOutT>::surface_; 00101 using Keypoint<PointInT, PointOutT>::tree_; 00102 00104 SIFTKeypoint () : min_scale_ (0.0), nr_octaves_ (0), nr_scales_per_octave_ (0), 00105 min_contrast_ (-std::numeric_limits<float>::max ()), scale_idx_ (-1) 00106 { 00107 name_ = "SIFTKeypoint"; 00108 } 00109 00115 void 00116 setScales (float min_scale, int nr_octaves, int nr_scales_per_octave); 00117 00121 void 00122 setMinimumContrast (float min_contrast); 00123 00124 protected: 00129 void 00130 detectKeypoints (PointCloudOut &output); 00131 00132 private: 00140 void 00141 detectKeypointsForOctave (const PointCloudIn &input, KdTree &tree, 00142 float base_scale, int nr_scales_per_octave, 00143 PointCloudOut &output); 00144 00151 void 00152 computeScaleSpace (const PointCloudIn &input, KdTree &tree, 00153 const std::vector<float> &scales, 00154 Eigen::MatrixXf &diff_of_gauss); 00155 00163 void 00164 findScaleSpaceExtrema (const PointCloudIn &input, KdTree &tree, 00165 const Eigen::MatrixXf &diff_of_gauss, 00166 std::vector<int> &extrema_indices, std::vector<int> &extrema_scales); 00167 00168 00170 float min_scale_; 00171 00173 int nr_octaves_; 00174 00176 int nr_scales_per_octave_; 00177 00179 float min_contrast_; 00180 00183 int scale_idx_; 00184 00186 std::vector<sensor_msgs::PointField> out_fields_; 00187 00188 SIFTKeypointFieldSelector<PointInT> getFieldValue_; 00189 }; 00190 } 00191 00192 #include "pcl/keypoints/impl/sift_keypoint.hpp" 00193 00194 #endif // #ifndef PCL_SIFT_KEYPOINT_H_ 00195
1.8.0