Point Cloud Library (PCL)  1.7.0
agast_2d.hpp
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2011, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of Willow Garage, Inc. nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  */
38 
39 #ifndef PCL_KEYPOINTS_AGAST_KEYPOINT_2D_IMPL_H_
40 #define PCL_KEYPOINTS_AGAST_KEYPOINT_2D_IMPL_H_
41 
42 #include <pcl/common/io.h>
43 
44 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
45 template <typename PointInT, typename PointOutT, typename IntensityT> bool
47 {
49  {
50  PCL_ERROR ("[pcl::%s::initCompute] init failed.!\n", name_.c_str ());
51  return (false);
52  }
53 
54  if (!input_->isOrganized ())
55  {
56  PCL_ERROR ("[pcl::%s::initCompute] %s doesn't support non organized clouds!\n", name_.c_str ());
57  return (false);
58  }
59 
60  return (true);
61 }
62 
63 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
64 template <typename PointInT, typename PointOutT> void
66 {
67  // image size
68  const size_t width = input_->width;
69  const size_t height = input_->height;
70 
71  // destination for intensity data; will be forwarded to AGAST
72  std::vector<unsigned char> image_data (width*height);
73 
74  for (size_t i = 0; i < image_data.size (); ++i)
75  image_data[i] = static_cast<unsigned char> (intensity_ ((*input_)[i]));
76 
77  if (!detector_)
78  detector_.reset (new pcl::keypoints::agast::AgastDetector7_12s (width, height, threshold_, bmax_));
79 
80  detector_->setMaxKeypoints (nr_max_keypoints_);
81 
82  if (apply_non_max_suppression_)
83  {
85  detector_->detectKeypoints (image_data, tmp_cloud);
86 
88  image_data, tmp_cloud, detector_, output);
89  }
90  else
91  {
93  image_data, detector_, output);
94  }
95 
96  // we do not change the denseness
97  output.is_dense = true;
98 }
99 
100 
101 #define AgastKeypoint2D(T,I) template class PCL_EXPORTS pcl::AgastKeypoint2D<T,I>;
102 #endif