00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef PCL_KEYPOINT_IMPL_H_
00039 #define PCL_KEYPOINT_IMPL_H_
00040
00042 template <typename PointInT, typename PointOutT> bool
00043 pcl::Keypoint<PointInT, PointOutT>::initCompute ()
00044 {
00045 if (!PCLBase<PointInT>::initCompute ())
00046 return (false);
00047
00048
00049 if (!tree_)
00050 {
00051 if (input_->isOrganized ())
00052 tree_.reset (new pcl::search::OrganizedNeighbor<PointInT> ());
00053 else
00054 tree_.reset (new pcl::search::KdTree<PointInT> (false));
00055 }
00056
00057
00058 if (!surface_)
00059 surface_ = input_;
00060
00061
00062 tree_->setInputCloud (surface_);
00063
00064
00065 if (search_radius_ != 0.0)
00066 {
00067 if (k_ != 0)
00068 {
00069 PCL_ERROR ("[pcl::%s::initCompute] Both radius (%f) and K (%d) defined! Set one of them to zero first and then re-run compute ().\n", getClassName ().c_str (), search_radius_, k_);
00070 return (false);
00071 }
00072 else
00073 {
00074 search_parameter_ = search_radius_;
00075 if (surface_ == input_)
00076 {
00077
00078 int (KdTree::*radiusSearch)(int index, double radius, std::vector<int> &k_indices,
00079 std::vector<float> &k_distances, unsigned int max_nn) const = &KdTree::radiusSearch;
00080 search_method_ = boost::bind (radiusSearch, boost::ref (tree_), _1, _2, _3, _4, 0);
00081 }
00082 else
00083 {
00084
00085 int (KdTree::*radiusSearchSurface)(const PointCloudIn &cloud, int index, double radius, std::vector<int> &k_indices,
00086 std::vector<float> &k_distances, unsigned int max_nn) const = &KdTree::radiusSearch;
00087 search_method_surface_ = boost::bind (radiusSearchSurface, boost::ref (tree_), _1, _2, _3, _4, _5, 0);
00088 }
00089 }
00090 }
00091 else
00092 {
00093 if (k_ != 0)
00094 {
00095 search_parameter_ = k_;
00096 if (surface_ == input_)
00097 {
00098
00099 int (KdTree::*nearestKSearch)(int index, int k, std::vector<int> &k_indices, std::vector<float> &k_distances) const = &KdTree::nearestKSearch;
00100 search_method_ = boost::bind (nearestKSearch, boost::ref (tree_), _1, _2, _3, _4);
00101 }
00102 else
00103 {
00104
00105 int (KdTree::*nearestKSearchSurface)(const PointCloudIn &cloud, int index, int k, std::vector<int> &k_indices, std::vector<float> &k_distances) const = &KdTree::nearestKSearch;
00106 search_method_surface_ = boost::bind (nearestKSearchSurface, boost::ref (tree_), _1, _2, _3, _4, _5);
00107 }
00108 }
00109 else
00110 {
00111 PCL_ERROR ("[pcl::%s::initCompute] Neither radius nor K defined! Set one of them to a positive number first and then re-run compute ().\n", getClassName ().c_str ());
00112 return (false);
00113 }
00114 }
00115
00116 return (true);
00117 }
00118
00120 template <typename PointInT, typename PointOutT> inline void
00121 pcl::Keypoint<PointInT, PointOutT>::compute (PointCloudOut &output)
00122 {
00123 if (!initCompute ())
00124 {
00125 PCL_ERROR ("[pcl::%s::compute] initCompute failed!\n", getClassName ().c_str ());
00126 return;
00127 }
00128
00129
00130 detectKeypoints (output);
00131
00132 deinitCompute ();
00133
00134
00135 if (input_ == surface_)
00136 surface_.reset ();
00137 }
00138
00139 #endif //#ifndef PCL_KEYPOINT_IMPL_H_
00140