Point Cloud Library (PCL)  1.9.1-dev
agast_2d.h
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 #pragma once
40 
41 #include <pcl/point_cloud.h>
42 #include <pcl/point_types.h>
43 #include <pcl/keypoints/keypoint.h>
44 #include <pcl/common/intensity.h>
45 
46 namespace pcl
47 {
48  namespace keypoints
49  {
50  namespace agast
51  {
52 
53  /** \brief Abstract detector class for AGAST corner point detectors.
54  *
55  * Adapted from the C++ implementation of Elmar Mair
56  * (http://www6.in.tum.de/Main/ResearchAgast).
57  *
58  * \author Stefan Holzer
59  * \ingroup keypoints
60  */
61  class PCL_EXPORTS AbstractAgastDetector
62  {
63  public:
64  typedef boost::shared_ptr<AbstractAgastDetector> Ptr;
65  typedef boost::shared_ptr<const AbstractAgastDetector> ConstPtr;
66 
67  /** \brief Constructor.
68  * \param[in] width the width of the image to process
69  * \param[in] height the height of the image to process
70  * \param[in] threshold the corner detection threshold
71  * \param[in] bmax the max image value (default: 255)
72  */
73  AbstractAgastDetector (const size_t width,
74  const size_t height,
75  const double threshold,
76  const double bmax)
77  : width_ (width)
78  , height_ (height)
79  , threshold_ (threshold)
80  , nr_max_keypoints_ (std::numeric_limits<unsigned int>::max ())
81  , bmax_ (bmax)
82  {}
83 
84  /** \brief Destructor. */
85  virtual ~AbstractAgastDetector () {}
86 
87  /** \brief Detects corner points.
88  * \param intensity_data
89  * \param output
90  */
91  void
92  detectKeypoints (const std::vector<unsigned char> &intensity_data,
94 
95  /** \brief Detects corner points.
96  * \param intensity_data
97  * \param output
98  */
99  void
100  detectKeypoints (const std::vector<float> &intensity_data,
102 
103  /** \brief Applies non-max-suppression.
104  * \param[in] intensity_data the image data
105  * \param[in] input the keypoint positions
106  * \param[out] output the resultant keypoints after non-max-supression
107  */
108  void
109  applyNonMaxSuppression (const std::vector<unsigned char>& intensity_data,
110  const pcl::PointCloud<pcl::PointUV> &input,
112 
113  /** \brief Applies non-max-suppression.
114  * \param[in] intensity_data the image data
115  * \param[in] input the keypoint positions
116  * \param[out] output the resultant keypoints after non-max-supression
117  */
118  void
119  applyNonMaxSuppression (const std::vector<float>& intensity_data,
120  const pcl::PointCloud<pcl::PointUV> &input,
122 
123  /** \brief Computes corner score.
124  * \param[in] im the pixels to compute the score at
125  */
126  virtual int
127  computeCornerScore (const unsigned char* im) const = 0;
128 
129  /** \brief Computes corner score.
130  * \param[in] im the pixels to compute the score at
131  */
132  virtual int
133  computeCornerScore (const float* im) const = 0;
134 
135  /** \brief Sets the threshold for corner detection.
136  * \param[in] threshold the threshold used for corner detection.
137  */
138  inline void
139  setThreshold (const double threshold)
140  {
141  threshold_ = threshold;
142  }
143 
144  /** \brief Get the threshold for corner detection, as set by the user. */
145  inline double
147  {
148  return (threshold_);
149  }
150 
151  /** \brief Sets the maximum number of keypoints to return. The
152  * estimated keypoints are sorted by their internal score.
153  * \param[in] nr_max_keypoints set the maximum number of keypoints to return
154  */
155  inline void
156  setMaxKeypoints (const unsigned int nr_max_keypoints)
157  {
158  nr_max_keypoints_ = nr_max_keypoints;
159  }
160 
161  /** \brief Get the maximum number of keypoints to return, as set by the user. */
162  inline unsigned int
164  {
165  return (nr_max_keypoints_);
166  }
167 
168  /** \brief Detects points of interest (i.e., keypoints) in the given image
169  * \param[in] im the image to detect keypoints in
170  * \param[out] corners_all the resultant set of keypoints detected
171  */
172  virtual void
173  detect (const unsigned char* im,
174  std::vector<pcl::PointUV, Eigen::aligned_allocator<pcl::PointUV> > &corners_all) const = 0;
175 
176  /** \brief Detects points of interest (i.e., keypoints) in the given image
177  * \param[in] im the image to detect keypoints in
178  */
179  virtual void
180  detect (const float* im,
181  std::vector<pcl::PointUV, Eigen::aligned_allocator<pcl::PointUV> > &) const = 0;
182 
183  protected:
184 
185  /** \brief Structure holding an index and the associated keypoint score. */
186  struct ScoreIndex
187  {
188  int idx;
189  int score;
190  };
191 
192  /** \brief Score index comparator. */
194  {
195  /** \brief Comparator
196  * \param[in] i1 the first score index
197  * \param[in] i2 the second score index
198  */
199  inline bool
200  operator() (const ScoreIndex &i1, const ScoreIndex &i2)
201  {
202  return (i1.score > i2.score);
203  }
204  };
205 
206  /** \brief Initializes the sample pattern. */
207  virtual void
208  initPattern () = 0;
209 
210  /** \brief Non-max-suppression helper method.
211  * \param[in] input the keypoint positions
212  * \param[in] scores the keypoint scores computed on the image data
213  * \param[out] output the resultant keypoints after non-max-supression
214  */
215  void
216  applyNonMaxSuppression (const pcl::PointCloud<pcl::PointUV> &input,
217  const std::vector<ScoreIndex>& scores,
219 
220  /** \brief Computes corner scores for the specified points.
221  * \param im
222  * \param corners_all
223  * \param scores
224  */
225  void
226  computeCornerScores (const unsigned char* im,
227  const std::vector<pcl::PointUV, Eigen::aligned_allocator<pcl::PointUV> > & corners_all,
228  std::vector<ScoreIndex> & scores);
229 
230  /** \brief Computes corner scores for the specified points.
231  * \param im
232  * \param corners_all
233  * \param scores
234  */
235  void
236  computeCornerScores (const float* im,
237  const std::vector<pcl::PointUV, Eigen::aligned_allocator<pcl::PointUV> > & corners_all,
238  std::vector<ScoreIndex> & scores);
239 
240  /** \brief Width of the image to process. */
241  size_t width_;
242  /** \brief Height of the image to process. */
243  size_t height_;
244 
245  /** \brief Threshold for corner detection. */
246  double threshold_;
247 
248  /** \brief The maximum number of keypoints to return. */
249  unsigned int nr_max_keypoints_;
250 
251  /** \brief Max image value. */
252  double bmax_;
253  };
254 
255  /** \brief Detector class for AGAST corner point detector (7_12s).
256  *
257  * Adapted from the C++ implementation of Elmar Mair
258  * (http://www6.in.tum.de/Main/ResearchAgast).
259  *
260  * \author Stefan Holzer
261  * \ingroup keypoints
262  */
263  class PCL_EXPORTS AgastDetector7_12s : public AbstractAgastDetector
264  {
265  public:
266  typedef boost::shared_ptr<AgastDetector7_12s> Ptr;
267  typedef boost::shared_ptr<const AgastDetector7_12s> ConstPtr;
268 
269  /** \brief Constructor.
270  * \param[in] width the width of the image to process
271  * \param[in] height the height of the image to process
272  * \param[in] threshold the corner detection threshold
273  * \param[in] bmax the max image value (default: 255)
274  */
275  AgastDetector7_12s (const size_t width,
276  const size_t height,
277  const double threshold,
278  const double bmax = 255)
279  : AbstractAgastDetector (width, height, threshold, bmax)
280  {
281  initPattern ();
282  }
283 
284  /** \brief Destructor. */
286 
287  /** \brief Computes corner score.
288  * \param im
289  */
290  int
291  computeCornerScore (const unsigned char* im) const override;
292 
293  /** \brief Computes corner score.
294  * \param im
295  */
296  int
297  computeCornerScore (const float* im) const override;
298 
299  /** \brief Detects points of interest (i.e., keypoints) in the given image
300  * \param[in] im the image to detect keypoints in
301  * \param[out] corners_all the resultant set of keypoints detected
302  */
303  void
304  detect (const unsigned char* im, std::vector<pcl::PointUV, Eigen::aligned_allocator<pcl::PointUV> > &corners_all) const override;
305 
306  /** \brief Detects points of interest (i.e., keypoints) in the given image
307  * \param[in] im the image to detect keypoints in
308  * \param[out] corners_all the resultant set of keypoints detected
309  */
310  void
311  detect (const float* im, std::vector<pcl::PointUV, Eigen::aligned_allocator<pcl::PointUV> > &corners_all) const override;
312 
313  protected:
314  /** \brief Initializes the sample pattern. */
315  void
316  initPattern () override;
317 
318  private:
319  /** \brief Border width. */
320  static const int border_width_ = 2;
321 
322  // offsets defining the sample pattern
323  int_fast16_t s_offset0_;
324  int_fast16_t s_offset1_;
325  int_fast16_t s_offset2_;
326  int_fast16_t s_offset3_;
327  int_fast16_t s_offset4_;
328  int_fast16_t s_offset5_;
329  int_fast16_t s_offset6_;
330  int_fast16_t s_offset7_;
331  int_fast16_t s_offset8_;
332  int_fast16_t s_offset9_;
333  int_fast16_t s_offset10_;
334  int_fast16_t s_offset11_;
335  };
336 
337  /** \brief Detector class for AGAST corner point detector (5_8).
338  *
339  * Adapted from the C++ implementation of Elmar Mair
340  * (http://www6.in.tum.de/Main/ResearchAgast).
341  *
342  * \author Stefan Holzer
343  * \ingroup keypoints
344  */
345  class PCL_EXPORTS AgastDetector5_8 : public AbstractAgastDetector
346  {
347  public:
348  typedef boost::shared_ptr<AgastDetector5_8> Ptr;
349  typedef boost::shared_ptr<const AgastDetector5_8> ConstPtr;
350 
351  /** \brief Constructor.
352  * \param[in] width the width of the image to process
353  * \param[in] height the height of the image to process
354  * \param[in] threshold the corner detection threshold
355  * \param[in] bmax the max image value (default: 255)
356  */
357  AgastDetector5_8 (const size_t width,
358  const size_t height,
359  const double threshold,
360  const double bmax = 255)
361  : AbstractAgastDetector (width, height, threshold, bmax)
362  {
363  initPattern ();
364  }
365 
366  /** \brief Destructor. */
368 
369  /** \brief Computes corner score.
370  * \param im
371  */
372  int
373  computeCornerScore (const unsigned char* im) const override;
374 
375  /** \brief Computes corner score.
376  * \param im
377  */
378  int
379  computeCornerScore (const float* im) const override;
380 
381  /** \brief Detects points of interest (i.e., keypoints) in the given image
382  * \param[in] im the image to detect keypoints in
383  * \param[out] corners_all the resultant set of keypoints detected
384  */
385  void
386  detect (const unsigned char* im, std::vector<pcl::PointUV, Eigen::aligned_allocator<pcl::PointUV> > &corners_all) const override;
387 
388  /** \brief Detects points of interest (i.e., keypoints) in the given image
389  * \param[in] im the image to detect keypoints in
390  * \param[out] corners_all the resultant set of keypoints detected
391  */
392  void
393  detect (const float* im, std::vector<pcl::PointUV, Eigen::aligned_allocator<pcl::PointUV> > &corners_all) const override;
394 
395  protected:
396  /** \brief Initializes the sample pattern. */
397  void
398  initPattern () override;
399 
400  private:
401  /** \brief Border width. */
402  static const int border_width_ = 1;
403 
404  // offsets defining the sample pattern
405  int_fast16_t s_offset0_;
406  int_fast16_t s_offset1_;
407  int_fast16_t s_offset2_;
408  int_fast16_t s_offset3_;
409  int_fast16_t s_offset4_;
410  int_fast16_t s_offset5_;
411  int_fast16_t s_offset6_;
412  int_fast16_t s_offset7_;
413  };
414 
415  /** \brief Detector class for AGAST corner point detector (OAST 9_16).
416  *
417  * Adapted from the C++ implementation of Elmar Mair
418  * (http://www6.in.tum.de/Main/ResearchAgast).
419  *
420  * \author Stefan Holzer
421  * \ingroup keypoints
422  */
423  class PCL_EXPORTS OastDetector9_16 : public AbstractAgastDetector
424  {
425  public:
426  typedef boost::shared_ptr<OastDetector9_16> Ptr;
427  typedef boost::shared_ptr<const OastDetector9_16> ConstPtr;
428 
429  /** \brief Constructor.
430  * \param[in] width the width of the image to process
431  * \param[in] height the height of the image to process
432  * \param[in] threshold the corner detection threshold
433  * \param[in] bmax the max image value (default: 255)
434  */
435  OastDetector9_16 (const size_t width,
436  const size_t height,
437  const double threshold,
438  const double bmax = 255)
439  : AbstractAgastDetector (width, height, threshold, bmax)
440  {
441  initPattern ();
442  }
443 
444  /** \brief Destructor. */
446 
447  /** \brief Computes corner score.
448  * \param im
449  */
450  int
451  computeCornerScore (const unsigned char* im) const override;
452 
453  /** \brief Computes corner score.
454  * \param im
455  */
456  int
457  computeCornerScore (const float* im) const override;
458 
459  /** \brief Detects points of interest (i.e., keypoints) in the given image
460  * \param[in] im the image to detect keypoints in
461  * \param[out] corners_all the resultant set of keypoints detected
462  */
463  void
464  detect (const unsigned char* im, std::vector<pcl::PointUV, Eigen::aligned_allocator<pcl::PointUV> > &corners_all) const override;
465 
466  /** \brief Detects points of interest (i.e., keypoints) in the given image
467  * \param[in] im the image to detect keypoints in
468  * \param[out] corners_all the resultant set of keypoints detected
469  */
470  void
471  detect (const float* im, std::vector<pcl::PointUV, Eigen::aligned_allocator<pcl::PointUV> > &corners_all) const override;
472 
473  protected:
474  /** \brief Initializes the sample pattern. */
475  void
476  initPattern () override;
477 
478  private:
479  /** \brief Border width. */
480  static const int border_width_ = 3;
481 
482  // offsets defining the sample pattern
483  int_fast16_t s_offset0_;
484  int_fast16_t s_offset1_;
485  int_fast16_t s_offset2_;
486  int_fast16_t s_offset3_;
487  int_fast16_t s_offset4_;
488  int_fast16_t s_offset5_;
489  int_fast16_t s_offset6_;
490  int_fast16_t s_offset7_;
491  int_fast16_t s_offset8_;
492  int_fast16_t s_offset9_;
493  int_fast16_t s_offset10_;
494  int_fast16_t s_offset11_;
495  int_fast16_t s_offset12_;
496  int_fast16_t s_offset13_;
497  int_fast16_t s_offset14_;
498  int_fast16_t s_offset15_;
499  };
500  } // namespace agast
501  } // namespace keypoints
502 
503  /////////////////////////////////////////////////////////////////////////////////////////
504  /////////////////////////////////////////////////////////////////////////////////////////
505  /////////////////////////////////////////////////////////////////////////////////////////
506  namespace keypoints
507  {
508  namespace internal
509  {
510  /////////////////////////////////////////////////////////////////////////////////////
511  template <typename Out>
513  {
515  const std::vector<unsigned char> &image_data,
516  const pcl::PointCloud<pcl::PointUV> &tmp_cloud,
518  pcl::PointCloud<Out> &output)
519  {
520  pcl::PointCloud<pcl::PointUV> output_temp;
521  detector->applyNonMaxSuppression (image_data, tmp_cloud, output_temp);
522  pcl::copyPointCloud<pcl::PointUV, Out> (output_temp, output);
523  }
524  };
525 
526  /////////////////////////////////////////////////////////////////////////////////////
527  template <>
529  {
531  const std::vector<unsigned char> &image_data,
532  const pcl::PointCloud<pcl::PointUV> &tmp_cloud,
535  {
536  detector->applyNonMaxSuppression (image_data, tmp_cloud, output);
537  }
538  };
539  /////////////////////////////////////////////////////////////////////////////////////
540  template <typename Out>
542  {
544  const std::vector<unsigned char> &image_data,
546  pcl::PointCloud<Out> &output)
547  {
548  pcl::PointCloud<pcl::PointUV> output_temp;
549  detector->detectKeypoints (image_data, output_temp);
550  pcl::copyPointCloud<pcl::PointUV, Out> (output_temp, output);
551  }
552  };
553 
554  /////////////////////////////////////////////////////////////////////////////////////
555  template <>
557  {
559  const std::vector<unsigned char> &image_data,
562  {
563  detector->detectKeypoints (image_data, output);
564  }
565  };
566  } // namespace agast
567  } // namespace keypoints
568 
569  /////////////////////////////////////////////////////////////////////////////////////////
570  /////////////////////////////////////////////////////////////////////////////////////////
571  /////////////////////////////////////////////////////////////////////////////////////////
572  /** \brief Detects 2D AGAST corner points. Based on the original work and
573  * paper reference by
574  *
575  * \par
576  * Elmar Mair, Gregory D. Hager, Darius Burschka, Michael Suppa, and Gerhard Hirzinger.
577  * Adaptive and generic corner detection based on the accelerated segment test.
578  * In Proceedings of the European Conference on Computer Vision (ECCV'10), September 2010.
579  *
580  * \note This is an abstract base class. All children must implement a detectKeypoints method, based on the type of AGAST keypoint to be used.
581  *
582  * \author Stefan Holzer, Radu B. Rusu
583  * \ingroup keypoints
584  */
585  template <typename PointInT, typename PointOutT, typename IntensityT = pcl::common::IntensityFieldAccessor<PointInT> >
586  class AgastKeypoint2DBase : public Keypoint<PointInT, PointOutT>
587  {
588  public:
593 
595 
600 
601  /** \brief Constructor */
603  : threshold_ (10)
604  , apply_non_max_suppression_ (true)
605  , bmax_ (255)
606  , detector_ ()
607  , nr_max_keypoints_ (std::numeric_limits<unsigned int>::max ())
608  {
609  k_ = 1;
610  }
611 
612  /** \brief Destructor. */
614  {
615  }
616 
617  /** \brief Sets the threshold for corner detection.
618  * \param[in] threshold the threshold used for corner detection.
619  */
620  inline void
621  setThreshold (const double threshold)
622  {
623  threshold_ = threshold;
624  }
625 
626  /** \brief Get the threshold for corner detection, as set by the user. */
627  inline double
629  {
630  return (threshold_);
631  }
632 
633  /** \brief Sets the maximum number of keypoints to return. The
634  * estimated keypoints are sorted by their internal score.
635  * \param[in] nr_max_keypoints set the maximum number of keypoints to return
636  */
637  inline void
638  setMaxKeypoints (const unsigned int nr_max_keypoints)
639  {
640  nr_max_keypoints_ = nr_max_keypoints;
641  }
642 
643  /** \brief Get the maximum number of keypoints to return, as set by the user. */
644  inline unsigned int
646  {
647  return (nr_max_keypoints_);
648  }
649 
650  /** \brief Sets the max image data value (affects how many iterations AGAST does)
651  * \param[in] bmax the max image data value
652  */
653  inline void
654  setMaxDataValue (const double bmax)
655  {
656  bmax_ = bmax;
657  }
658 
659  /** \brief Get the bmax image value, as set by the user. */
660  inline double
662  {
663  return (bmax_);
664  }
665 
666  /** \brief Sets whether non-max-suppression is applied or not.
667  * \param[in] enabled determines whether non-max-suppression is enabled.
668  */
669  inline void
670  setNonMaxSuppression (const bool enabled)
671  {
672  apply_non_max_suppression_ = enabled;
673  }
674 
675  /** \brief Returns whether non-max-suppression is applied or not. */
676  inline bool
678  {
679  return (apply_non_max_suppression_);
680  }
681 
682  inline void
683  setAgastDetector (const AgastDetectorPtr &detector)
684  {
685  detector_ = detector;
686  }
687 
688  inline AgastDetectorPtr
690  {
691  return (detector_);
692  }
693  protected:
694 
695  /** \brief Initializes everything and checks whether input data is fine. */
696  bool
697  initCompute () override;
698 
699  /** \brief Detects the keypoints.
700  * \param[out] output the resultant keypoints
701  */
702  void
703  detectKeypoints (PointCloudOut &output) override = 0;
704 
705  /** \brief Intensity field accessor. */
706  IntensityT intensity_;
707 
708  /** \brief Threshold for corner detection. */
709  double threshold_;
710 
711  /** \brief Determines whether non-max-suppression is activated. */
713 
714  /** \brief Max image value. */
715  double bmax_;
716 
717  /** \brief The Agast detector to use. */
718  AgastDetectorPtr detector_;
719 
720  /** \brief The maximum number of keypoints to return. */
721  unsigned int nr_max_keypoints_;
722  };
723 
724  /** \brief Detects 2D AGAST corner points. Based on the original work and
725  * paper reference by
726  *
727  * \par
728  * Elmar Mair, Gregory D. Hager, Darius Burschka, Michael Suppa, and Gerhard Hirzinger.
729  * Adaptive and generic corner detection based on the accelerated segment test.
730  * In Proceedings of the European Conference on Computer Vision (ECCV'10), September 2010.
731  *
732  * Code example:
733  *
734  * \code
735  * pcl::PointCloud<pcl::PointXYZRGBA> cloud;
736  * pcl::AgastKeypoint2D<pcl::PointXYZRGBA> agast;
737  * agast.setThreshold (30);
738  * agast.setInputCloud (cloud);
739  *
740  * PointCloud<pcl::PointUV> keypoints;
741  * agast.compute (keypoints);
742  * \endcode
743  *
744  * \note The AGAST keypoint type used is 7_12s.
745  *
746  * \author Stefan Holzer, Radu B. Rusu
747  * \ingroup keypoints
748  */
749  template <typename PointInT, typename PointOutT = pcl::PointUV>
750  class AgastKeypoint2D : public AgastKeypoint2DBase<PointInT, PointOutT, pcl::common::IntensityFieldAccessor<PointInT> >
751  {
752  public:
754 
765 
766  /** \brief Constructor */
768  {
769  name_ = "AgastKeypoint2D";
770  }
771 
772  /** \brief Destructor. */
774  {
775  }
776 
777  protected:
778  /** \brief Detects the keypoints.
779  * \param[out] output the resultant keypoints
780  */
781  void
782  detectKeypoints (PointCloudOut &output) override;
783  };
784 
785  /** \brief Detects 2D AGAST corner points. Based on the original work and
786  * paper reference by
787  *
788  * \par
789  * Elmar Mair, Gregory D. Hager, Darius Burschka, Michael Suppa, and Gerhard Hirzinger.
790  * Adaptive and generic corner detection based on the accelerated segment test.
791  * In Proceedings of the European Conference on Computer Vision (ECCV'10), September 2010.
792  *
793  * Code example:
794  *
795  * \code
796  * pcl::PointCloud<pcl::PointXYZRGBA> cloud;
797  * pcl::AgastKeypoint2D<pcl::PointXYZRGBA> agast;
798  * agast.setThreshold (30);
799  * agast.setInputCloud (cloud);
800  *
801  * PointCloud<pcl::PointUV> keypoints;
802  * agast.compute (keypoints);
803  * \endcode
804  *
805  * \note This is a specialized version for PointXYZ clouds, and operates on depth (z) as float. The output keypoints are of the PointXY type.
806  * \note The AGAST keypoint type used is 7_12s.
807  *
808  * \author Stefan Holzer, Radu B. Rusu
809  * \ingroup keypoints
810  */
811  template <>
813  : public AgastKeypoint2DBase<pcl::PointXYZ, pcl::PointUV, pcl::common::IntensityFieldAccessor<pcl::PointXYZ> >
814  {
815  public:
816  /** \brief Constructor */
818  {
819  name_ = "AgastKeypoint2D";
820  bmax_ = 4; // max data value for an OpenNI camera
821  }
822 
823  /** \brief Destructor. */
825  {
826  }
827 
828  protected:
829  /** \brief Detects the keypoints.
830  * \param[out] output the resultant keypoints
831  */
832  void
833  detectKeypoints (pcl::PointCloud<pcl::PointUV> &output) override;
834  };
835 
836 }
837 
838 #include <pcl/keypoints/impl/agast_2d.hpp>
size_t width_
Width of the image to process.
Definition: agast_2d.h:241
Keypoint< PointInT, PointOutT >::KdTree KdTree
Definition: agast_2d.h:591
AgastDetectorPtr getAgastDetector()
Definition: agast_2d.h:689
void setAgastDetector(const AgastDetectorPtr &detector)
Definition: agast_2d.h:683
Keypoint< PointInT, PointOutT >::PointCloudIn PointCloudIn
Definition: agast_2d.h:589
boost::shared_ptr< const OastDetector9_16 > ConstPtr
Definition: agast_2d.h:427
PointCloudIn::ConstPtr PointCloudInConstPtr
Definition: agast_2d.h:592
boost::shared_ptr< const AgastDetector7_12s > ConstPtr
Definition: agast_2d.h:267
AgastDetector(const std::vector< unsigned char > &image_data, const pcl::keypoints::agast::AbstractAgastDetector::Ptr &detector, pcl::PointCloud< Out > &output)
Definition: agast_2d.h:543
double bmax_
Max image value.
Definition: agast_2d.h:715
double getThreshold()
Get the threshold for corner detection, as set by the user.
Definition: agast_2d.h:146
AgastApplyNonMaxSuppresion(const std::vector< unsigned char > &image_data, const pcl::PointCloud< pcl::PointUV > &tmp_cloud, const pcl::keypoints::agast::AbstractAgastDetector::Ptr &detector, pcl::PointCloud< pcl::PointUV > &output)
Definition: agast_2d.h:530
Detects 2D AGAST corner points.
Definition: agast_2d.h:750
size_t height_
Height of the image to process.
Definition: agast_2d.h:243
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:44
double getMaxDataValue()
Get the bmax image value, as set by the user.
Definition: agast_2d.h:661
OastDetector9_16(const size_t width, const size_t height, const double threshold, const double bmax=255)
Constructor.
Definition: agast_2d.h:435
Detector class for AGAST corner point detector (7_12s).
Definition: agast_2d.h:263
virtual ~AbstractAgastDetector()
Destructor.
Definition: agast_2d.h:85
Detects 2D AGAST corner points.
Definition: agast_2d.h:586
AgastKeypoint2D()
Constructor.
Definition: agast_2d.h:767
Keypoint< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition: agast_2d.h:753
AgastDetector7_12s(const size_t width, const size_t height, const double threshold, const double bmax=255)
Constructor.
Definition: agast_2d.h:275
AgastDetectorPtr detector_
The Agast detector to use.
Definition: agast_2d.h:718
bool getNonMaxSuppression()
Returns whether non-max-suppression is applied or not.
Definition: agast_2d.h:677
void setMaxDataValue(const double bmax)
Sets the max image data value (affects how many iterations AGAST does)
Definition: agast_2d.h:654
unsigned int getMaxKeypoints()
Get the maximum number of keypoints to return, as set by the user.
Definition: agast_2d.h:163
double threshold_
Threshold for corner detection.
Definition: agast_2d.h:709
AgastDetector5_8(const size_t width, const size_t height, const double threshold, const double bmax=255)
Constructor.
Definition: agast_2d.h:357
Structure holding an index and the associated keypoint score.
Definition: agast_2d.h:186
Keypoint represents the base class for key points.
Definition: keypoint.h:48
boost::shared_ptr< AbstractAgastDetector > Ptr
Definition: agast_2d.h:64
void setMaxKeypoints(const unsigned int nr_max_keypoints)
Sets the maximum number of keypoints to return.
Definition: agast_2d.h:156
A 2D point structure representing pixel image coordinates.
A point structure representing Euclidean xyz coordinates.
AgastApplyNonMaxSuppresion(const std::vector< unsigned char > &image_data, const pcl::PointCloud< pcl::PointUV > &tmp_cloud, const pcl::keypoints::agast::AbstractAgastDetector::Ptr &detector, pcl::PointCloud< Out > &output)
Definition: agast_2d.h:514
~AgastKeypoint2DBase()
Destructor.
Definition: agast_2d.h:613
Keypoint< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition: agast_2d.h:590
boost::shared_ptr< OastDetector9_16 > Ptr
Definition: agast_2d.h:426
~AgastKeypoint2D()
Destructor.
Definition: agast_2d.h:773
boost::shared_ptr< const PointCloud< pcl::PointXYZ > > ConstPtr
Definition: point_cloud.h:428
boost::shared_ptr< const AbstractAgastDetector > ConstPtr
Definition: agast_2d.h:65
Detector class for AGAST corner point detector (OAST 9_16).
Definition: agast_2d.h:423
void setThreshold(const double threshold)
Sets the threshold for corner detection.
Definition: agast_2d.h:621
boost::shared_ptr< AgastDetector7_12s > Ptr
Definition: agast_2d.h:266
unsigned int nr_max_keypoints_
The maximum number of keypoints to return.
Definition: agast_2d.h:721
bool apply_non_max_suppression_
Determines whether non-max-suppression is activated.
Definition: agast_2d.h:712
PointCloud represents the base class in PCL for storing collections of 3D points. ...
AgastDetector(const std::vector< unsigned char > &image_data, const pcl::keypoints::agast::AbstractAgastDetector::Ptr &detector, pcl::PointCloud< pcl::PointUV > &output)
Definition: agast_2d.h:558
unsigned int nr_max_keypoints_
The maximum number of keypoints to return.
Definition: agast_2d.h:249
unsigned int getMaxKeypoints()
Get the maximum number of keypoints to return, as set by the user.
Definition: agast_2d.h:645
boost::shared_ptr< AgastDetector5_8 > Ptr
Definition: agast_2d.h:348
double getThreshold()
Get the threshold for corner detection, as set by the user.
Definition: agast_2d.h:628
pcl::keypoints::agast::AbstractAgastDetector::Ptr AgastDetectorPtr
Definition: agast_2d.h:594
boost::shared_ptr< const AgastDetector5_8 > ConstPtr
Definition: agast_2d.h:349
Detector class for AGAST corner point detector (5_8).
Definition: agast_2d.h:345
Abstract detector class for AGAST corner point detectors.
Definition: agast_2d.h:61
void setNonMaxSuppression(const bool enabled)
Sets whether non-max-suppression is applied or not.
Definition: agast_2d.h:670
AgastKeypoint2DBase()
Constructor.
Definition: agast_2d.h:602
double threshold_
Threshold for corner detection.
Definition: agast_2d.h:246
AbstractAgastDetector(const size_t width, const size_t height, const double threshold, const double bmax)
Constructor.
Definition: agast_2d.h:73
void setThreshold(const double threshold)
Sets the threshold for corner detection.
Definition: agast_2d.h:139
IntensityT intensity_
Intensity field accessor.
Definition: agast_2d.h:706
void setMaxKeypoints(const unsigned int nr_max_keypoints)
Sets the maximum number of keypoints to return.
Definition: agast_2d.h:638