Point Cloud Library (PCL)  1.14.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-suppression
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-suppression
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-suppression
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  :
574  nr_max_keypoints_ (std::numeric_limits<unsigned int>::max ())
575  {
576  k_ = 1;
577  }
578 
579  /** \brief Destructor. */
580  ~AgastKeypoint2DBase () override = default;
581 
582  /** \brief Sets the threshold for corner detection.
583  * \param[in] threshold the threshold used for corner detection.
584  */
585  inline void
586  setThreshold (const double threshold)
587  {
588  threshold_ = threshold;
589  }
590 
591  /** \brief Get the threshold for corner detection, as set by the user. */
592  inline double
594  {
595  return (threshold_);
596  }
597 
598  /** \brief Sets the maximum number of keypoints to return. The
599  * estimated keypoints are sorted by their internal score.
600  * \param[in] nr_max_keypoints set the maximum number of keypoints to return
601  */
602  inline void
603  setMaxKeypoints (const unsigned int nr_max_keypoints)
604  {
605  nr_max_keypoints_ = nr_max_keypoints;
606  }
607 
608  /** \brief Get the maximum number of keypoints to return, as set by the user. */
609  inline unsigned int
611  {
612  return (nr_max_keypoints_);
613  }
614 
615  /** \brief Sets the max image data value (affects how many iterations AGAST does)
616  * \param[in] bmax the max image data value
617  */
618  inline void
619  setMaxDataValue (const double bmax)
620  {
621  bmax_ = bmax;
622  }
623 
624  /** \brief Get the bmax image value, as set by the user. */
625  inline double
627  {
628  return (bmax_);
629  }
630 
631  /** \brief Sets whether non-max-suppression is applied or not.
632  * \param[in] enabled determines whether non-max-suppression is enabled.
633  */
634  inline void
635  setNonMaxSuppression (const bool enabled)
636  {
637  apply_non_max_suppression_ = enabled;
638  }
639 
640  /** \brief Returns whether non-max-suppression is applied or not. */
641  inline bool
643  {
645  }
646 
647  inline void
649  {
650  detector_ = detector;
651  }
652 
653  inline AgastDetectorPtr
655  {
656  return (detector_);
657  }
658  protected:
659 
660  /** \brief Initializes everything and checks whether input data is fine. */
661  bool
662  initCompute () override;
663 
664  /** \brief Detects the keypoints.
665  * \param[out] output the resultant keypoints
666  */
667  void
668  detectKeypoints (PointCloudOut &output) override = 0;
669 
670  /** \brief Intensity field accessor. */
671  IntensityT intensity_;
672 
673  /** \brief Threshold for corner detection. */
674  double threshold_{10};
675 
676  /** \brief Determines whether non-max-suppression is activated. */
678 
679  /** \brief Max image value. */
680  double bmax_{255};
681 
682  /** \brief The Agast detector to use. */
684 
685  /** \brief The maximum number of keypoints to return. */
686  unsigned int nr_max_keypoints_;
687  };
688 
689  /** \brief Detects 2D AGAST corner points. Based on the original work and
690  * paper reference by
691  *
692  * \par
693  * Elmar Mair, Gregory D. Hager, Darius Burschka, Michael Suppa, and Gerhard Hirzinger.
694  * Adaptive and generic corner detection based on the accelerated segment test.
695  * In Proceedings of the European Conference on Computer Vision (ECCV'10), September 2010.
696  *
697  * Code example:
698  *
699  * \code
700  * pcl::PointCloud<pcl::PointXYZRGBA> cloud;
701  * pcl::AgastKeypoint2D<pcl::PointXYZRGBA> agast;
702  * agast.setThreshold (30);
703  * agast.setInputCloud (cloud);
704  *
705  * PointCloud<pcl::PointUV> keypoints;
706  * agast.compute (keypoints);
707  * \endcode
708  *
709  * \note The AGAST keypoint type used is 7_12s.
710  *
711  * \author Stefan Holzer, Radu B. Rusu
712  * \ingroup keypoints
713  */
714  template <typename PointInT, typename PointOutT = pcl::PointUV>
715  class AgastKeypoint2D : public AgastKeypoint2DBase<PointInT, PointOutT, pcl::common::IntensityFieldAccessor<PointInT> >
716  {
717  public:
719 
730 
731  /** \brief Constructor */
733  {
734  name_ = "AgastKeypoint2D";
735  }
736 
737  /** \brief Destructor. */
738  ~AgastKeypoint2D () override = default;
739 
740  protected:
741  /** \brief Detects the keypoints.
742  * \param[out] output the resultant keypoints
743  */
744  void
745  detectKeypoints (PointCloudOut &output) override;
746  };
747 
748  /** \brief Detects 2D AGAST corner points. Based on the original work and
749  * paper reference by
750  *
751  * \par
752  * Elmar Mair, Gregory D. Hager, Darius Burschka, Michael Suppa, and Gerhard Hirzinger.
753  * Adaptive and generic corner detection based on the accelerated segment test.
754  * In Proceedings of the European Conference on Computer Vision (ECCV'10), September 2010.
755  *
756  * Code example:
757  *
758  * \code
759  * pcl::PointCloud<pcl::PointXYZRGBA> cloud;
760  * pcl::AgastKeypoint2D<pcl::PointXYZRGBA> agast;
761  * agast.setThreshold (30);
762  * agast.setInputCloud (cloud);
763  *
764  * PointCloud<pcl::PointUV> keypoints;
765  * agast.compute (keypoints);
766  * \endcode
767  *
768  * \note This is a specialized version for PointXYZ clouds, and operates on depth (z) as float. The output keypoints are of the PointXY type.
769  * \note The AGAST keypoint type used is 7_12s.
770  *
771  * \author Stefan Holzer, Radu B. Rusu
772  * \ingroup keypoints
773  */
774  template <>
776  : public AgastKeypoint2DBase<pcl::PointXYZ, pcl::PointUV, pcl::common::IntensityFieldAccessor<pcl::PointXYZ> >
777  {
778  public:
779  /** \brief Constructor */
781  {
782  name_ = "AgastKeypoint2D";
783  bmax_ = 4; // max data value for an OpenNI camera
784  }
785 
786  /** \brief Destructor. */
787  ~AgastKeypoint2D () override = default;
788 
789  protected:
790  /** \brief Detects the keypoints.
791  * \param[out] output the resultant keypoints
792  */
793  void
795  };
796 
797 }
798 
799 #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:654
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:593
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:619
double threshold_
Threshold for corner detection.
Definition: agast_2d.h:674
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:671
void setMaxKeypoints(const unsigned int nr_max_keypoints)
Sets the maximum number of keypoints to return.
Definition: agast_2d.h:603
double bmax_
Max image value.
Definition: agast_2d.h:680
double getMaxDataValue()
Get the bmax image value, as set by the user.
Definition: agast_2d.h:626
void setThreshold(const double threshold)
Sets the threshold for corner detection.
Definition: agast_2d.h:586
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:648
AgastDetectorPtr detector_
The Agast detector to use.
Definition: agast_2d.h:683
unsigned int nr_max_keypoints_
The maximum number of keypoints to return.
Definition: agast_2d.h:686
bool getNonMaxSuppression()
Returns whether non-max-suppression is applied or not.
Definition: agast_2d.h:642
AgastKeypoint2DBase()
Constructor.
Definition: agast_2d.h:572
bool apply_non_max_suppression_
Determines whether non-max-suppression is activated.
Definition: agast_2d.h:677
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:635
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:610
Detects 2D AGAST corner points.
Definition: agast_2d.h:716
AgastKeypoint2D()
Constructor.
Definition: agast_2d.h:732
typename Keypoint< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition: agast_2d.h:718
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:188
std::string name_
The key point detection method's name.
Definition: keypoint.h:167
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