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