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