Point Cloud Library (PCL)
1.7.0
|
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 * $Id$ 00037 */ 00038 00039 #ifndef PCL_SUSAN_KEYPOINT_H_ 00040 #define PCL_SUSAN_KEYPOINT_H_ 00041 00042 #include <pcl/keypoints/keypoint.h> 00043 #include <pcl/common/intensity.h> 00044 00045 namespace pcl 00046 { 00047 /** \brief SUSANKeypoint implements a RGB-D extension of the SUSAN detector inluding normal 00048 * directions variation in top of intensity variation. 00049 * It is different from Harris in that it exploits normals directly so it is faster. 00050 * Original paper "SUSAN — A New Approach to Low Level Image Processing", Smith, 00051 * Stephen M. and Brady, J. Michael 00052 * 00053 * \author Nizar Sallem 00054 * \ingroup keypoints 00055 */ 00056 template <typename PointInT, typename PointOutT, typename NormalT = pcl::Normal, typename IntensityT= pcl::common::IntensityFieldAccessor<PointInT> > 00057 class SUSANKeypoint : public Keypoint<PointInT, PointOutT> 00058 { 00059 public: 00060 typedef boost::shared_ptr<SUSANKeypoint<PointInT, PointOutT, NormalT, IntensityT> > Ptr; 00061 typedef boost::shared_ptr<const SUSANKeypoint<PointInT, PointOutT, NormalT, Intensity> > ConstPtr; 00062 00063 typedef typename Keypoint<PointInT, PointOutT>::PointCloudIn PointCloudIn; 00064 typedef typename Keypoint<PointInT, PointOutT>::PointCloudOut PointCloudOut; 00065 typedef typename Keypoint<PointInT, PointOutT>::KdTree KdTree; 00066 typedef typename PointCloudIn::ConstPtr PointCloudInConstPtr; 00067 00068 typedef typename pcl::PointCloud<NormalT> PointCloudN; 00069 typedef typename PointCloudN::Ptr PointCloudNPtr; 00070 typedef typename PointCloudN::ConstPtr PointCloudNConstPtr; 00071 00072 using Keypoint<PointInT, PointOutT>::name_; 00073 using Keypoint<PointInT, PointOutT>::input_; 00074 using Keypoint<PointInT, PointOutT>::indices_; 00075 using Keypoint<PointInT, PointOutT>::surface_; 00076 using Keypoint<PointInT, PointOutT>::tree_; 00077 using Keypoint<PointInT, PointOutT>::k_; 00078 using Keypoint<PointInT, PointOutT>::search_radius_; 00079 using Keypoint<PointInT, PointOutT>::search_parameter_; 00080 using Keypoint<PointInT, PointOutT>::initCompute; 00081 00082 /** \brief Constructor 00083 * \param[in] radius the radius for normal estimation as well as for non maxima suppression 00084 * \param[in] distance_threshold to test if the nucleus is far enough from the centroid 00085 * \param[in] angular_threshold to test if normals are parallel 00086 * \param[in] intensity_threshold to test if points are of same color 00087 */ 00088 SUSANKeypoint (float radius = 0.01f, 00089 float distance_threshold = 0.001f, 00090 float angular_threshold = 0.0001f, 00091 float intensity_threshold = 7.0f) 00092 : distance_threshold_ (distance_threshold) 00093 , angular_threshold_ (angular_threshold) 00094 , intensity_threshold_ (intensity_threshold) 00095 , normals_ (new pcl::PointCloud<NormalT>) 00096 , threads_ (0) 00097 , label_idx_ (-1) 00098 , out_fields_ () 00099 { 00100 name_ = "SUSANKeypoint"; 00101 search_radius_ = radius; 00102 geometric_validation_ = false; 00103 tolerance_ = 2 * distance_threshold_; 00104 } 00105 00106 /** \brief Empty destructor */ 00107 virtual ~SUSANKeypoint () {} 00108 00109 /** \brief set the radius for normal estimation and non maxima supression. 00110 * \param[in] radius 00111 */ 00112 void 00113 setRadius (float radius); 00114 00115 void 00116 setDistanceThreshold (float distance_threshold); 00117 00118 /** \brief set the angular_threshold value for detecting corners. Normals are considered as 00119 * parallel if 1 - angular_threshold <= (Ni.Nj) <= 1 00120 * \param[in] angular_threshold 00121 */ 00122 void 00123 setAngularThreshold (float angular_threshold); 00124 00125 /** \brief set the intensity_threshold value for detecting corners. 00126 * \param[in] intensity_threshold 00127 */ 00128 void 00129 setIntensityThreshold (float intensity_threshold); 00130 00131 /** 00132 * \brief set normals if precalculated normals are available. 00133 * \param normals 00134 */ 00135 void 00136 setNormals (const PointCloudNConstPtr &normals); 00137 00138 virtual void 00139 setSearchSurface (const PointCloudInConstPtr &cloud); 00140 00141 /** \brief Initialize the scheduler and set the number of threads to use. 00142 * \param nr_threads the number of hardware threads to use (0 sets the value back to automatic) 00143 */ 00144 void 00145 setNumberOfThreads (unsigned int nr_threads); 00146 00147 /** \brief Apply non maxima suppression to the responses to keep strongest corners. 00148 * \note in SUSAN points with less response or stronger corners 00149 */ 00150 void 00151 setNonMaxSupression (bool nonmax); 00152 00153 /** \brief Filetr false positive using geometric criteria. 00154 * The nucleus and the centroid should at least distance_threshold_ from each other AND all the 00155 * points belonging to the USAN must be within the segment [nucleus centroid]. 00156 * \param[in] validate 00157 */ 00158 void 00159 setGeometricValidation (bool validate); 00160 00161 protected: 00162 bool 00163 initCompute (); 00164 00165 void 00166 detectKeypoints (PointCloudOut &output); 00167 /** \brief return true if a point lies within the line between the nucleus and the centroid 00168 * \param[in] nucleus coordinate of the nucleus 00169 * \param[in] centroid of the USAN 00170 * \parma[in] nucleus to centroid vector (used to speed up since it is constant for a given 00171 * neighborhood) 00172 * \param[in] point the query point to test against 00173 * \return true if the point lies within [nucleus centroid] 00174 */ 00175 bool 00176 isWithinNucleusCentroid (const Eigen::Vector3f& nucleus, 00177 const Eigen::Vector3f& centroid, 00178 const Eigen::Vector3f& nc, 00179 const PointInT& point) const; 00180 private: 00181 float distance_threshold_; 00182 float angular_threshold_; 00183 float intensity_threshold_; 00184 float tolerance_; 00185 PointCloudNConstPtr normals_; 00186 unsigned int threads_; 00187 bool geometric_validation_; 00188 bool nonmax_; 00189 /// intensity field accessor 00190 IntensityT intensity_; 00191 /** \brief Set to a value different than -1 if the output cloud has a "label" field and we have 00192 * to save the keypoints indices. 00193 */ 00194 int label_idx_; 00195 /** \brief The list of fields present in the output point cloud data. */ 00196 std::vector<pcl::PCLPointField> out_fields_; 00197 pcl::common::IntensityFieldAccessor<PointOutT> intensity_out_; 00198 }; 00199 } 00200 00201 #include <pcl/keypoints/impl/susan.hpp> 00202 00203 #endif // #ifndef PCL_SUSAN_KEYPOINT_H_