MRPT  1.9.9
CFeature.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in https://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+
9  */
10 #pragma once
11 
12 #include <mrpt/img/CImage.h>
13 #include <mrpt/math/CMatrixF.h>
15 #include <mrpt/vision/TKeyPoint.h>
16 #include <mrpt/vision/types.h>
17 #include <optional>
18 
19 namespace mrpt
20 {
21 namespace vision
22 {
23 class CFeatureList;
25 
27 {
28  firstList = 0,
31 };
32 
33 /** \defgroup mrptvision_features Feature detection, descriptors and matching
34  * \ingroup mrpt_vision_grp
35  */
36 
37 /** \addtogroup mrptvision_features
38  @{ */
39 
40 /****************************************************
41  Class CFEATURE
42 *****************************************************/
43 
44 /** A generic 2D feature from an image, extracted with \a CFeatureExtraction
45  * Each feature may have one or more descriptors (see \a descriptors), in
46  * addition to an image patch.
47  * The (Euclidean) distance between descriptors in a pair of features can be
48  * computed with descriptorDistanceTo,
49  * while the similarity of the patches is given by patchCorrelationTo.
50  *
51  * \sa CFeatureList, TKeyPoint, TKeyPointList
52  */
54 {
55  friend class CFeatureList;
56  friend class CMatchedFeatureList;
57 
59 
60  public:
61  CFeature() = default;
62  ~CFeature() override = default;
63 
65 
66  /** A patch of the image surrounding the feature */
67  std::optional<mrpt::img::CImage> patch;
68 
69  /** Size of the patch (patchSize x patchSize) (it must be an odd number) */
71 
72  /** Keypoint method used to detect this feature */
74 
75  /** Status of the feature tracking process */
77 
78  /** A measure of the "goodness" of the feature */
79  float response{0.0};
80 
81  float orientation{0.0}; //!< Main orientation of the feature
82  // Scale: replaced by keypoint.octave ==> float scale{0};
83 
84  /** A field for any other flags needed by the user (this has not a
85  * predefined meaning) */
87 
88  // # added by Raghavender Sahdev
89  float x2[2], y2[2]; //!< Coordinates for a LSD Detector to represent a line
90 
91  double depth{
92  0}; //!< The estimated depth in 3D of this feature wrt the camera
93  //! in the current frame
94  //!
95  double initialDepth{
96  0}; //!< The estimated depth in 3D of this feature wrt the
97  //! camera that took its image
99  p3D; //!< The estimated 3D point of this feature wrt its camera
100 
101  /** Return false only for Blob detectors (SIFT, SURF) */
102  bool isPointFeature() const;
103 
104  /** All the possible descriptors this feature may have */
106  {
107  TDescriptors() = default;
108 
109  /** SIFT feature descriptor */
110  std::optional<std::vector<uint8_t>> SIFT;
111 
112  /** SURF feature descriptor */
113  std::optional<std::vector<float>> SURF;
114 
115  /** The 2D histogram as a single row */
116  std::optional<std::vector<float>> SpinImg;
117 
118  /** The number of rows (corresponding to range bins in the 2D histogram)
119  * of the original matrix from which SpinImg was extracted as a vector.
120  */
122 
123  /** A polar image centered at the interest point */
124  std::optional<mrpt::math::CMatrixF> PolarImg;
125 
126  /** A log-polar image centered at the interest point */
127  std::optional<mrpt::math::CMatrixF> LogPolarImg;
128 
129  /** If set to true (default=false) the call to "descriptorDistanceTo"
130  * will not consider all the rotations between polar image descriptors
131  * (PolarImg, LogPolarImg) */
132  bool polarImgsNoRotation{false};
133 
134  /** ORB feature descriptor */
135  std::optional<std::vector<uint8_t>> ORB;
136 
137  // added by Raghavender Sadev
138  /** BLD feature descriptor */
139  std::optional<std::vector<uint8_t>> BLD;
140  /** LATCH feature descriptor */
141  std::optional<std::vector<uint8_t>> LATCH;
142 
143  bool hasDescriptorSIFT() const { return SIFT.has_value(); }
144  bool hasDescriptorSURF() const { return SURF.has_value(); }
145  bool hasDescriptorSpinImg() const { return SpinImg.has_value(); }
146  bool hasDescriptorPolarImg() const { return PolarImg.has_value(); }
148  {
149  return LogPolarImg.has_value();
150  }
151 
152  bool hasDescriptorORB() const { return ORB.has_value(); }
153  bool hasDescriptorBLD() const { return BLD.has_value(); }
154  bool hasDescriptorLATCH() const { return LATCH.has_value(); }
155  };
156 
158 
159  /** Return the first found descriptor, as a matrix.
160  * \return false on error, i.e. there is no valid descriptor.
161  */
163 
164  /** Computes the normalized cross-correlation between the patches of this
165  * and another feature (normalized in the range [0,1], such as 0=best,
166  * 1=worst).
167  * \note If this or the other features does not have patches or they are
168  * of different sizes, an exception will be raised.
169  * \sa descriptorDistanceTo
170  */
171  float patchCorrelationTo(const CFeature& oFeature) const;
172 
173  /** Computes the Euclidean Distance between this feature's and other
174  * feature's descriptors, using the given descriptor or the first present
175  * one.
176  * \note If descriptorToUse is not descAny and that descriptor is not
177  * present in one of the features, an exception will be raised.
178  * \sa patchCorrelationTo
179  */
180  float descriptorDistanceTo(
181  const CFeature& oFeature, TDescriptorType descriptorToUse = descAny,
182  bool normalize_distances = true) const;
183 
184  /** Computes the Euclidean Distance between "this" and the "other"
185  * descriptors */
187  const CFeature& oFeature, bool normalize_distances = true) const;
188 
189  /** Computes the Euclidean Distance between "this" and the "other"
190  * descriptors */
192  const CFeature& oFeature, bool normalize_distances = true) const;
193 
194  /** Computes the Euclidean Distance between "this" and the "other"
195  * descriptors */
197  const CFeature& oFeature, bool normalize_distances = true) const;
198 
199  /** Returns the minimum Euclidean Distance between "this" and the "other"
200  * polar image descriptor, for the best shift in orientation.
201  * \param oFeature The other feature to compare with.
202  * \param minDistAngle The placeholder for the angle at which the smallest
203  * distance is found.
204  * \return The distance for the best orientation (minimum distance).
205  */
207  const CFeature& oFeature, float& minDistAngle,
208  bool normalize_distances = true) const;
209 
210  /** Returns the minimum Euclidean Distance between "this" and the "other"
211  * log-polar image descriptor, for the best shift in orientation.
212  * \param oFeature The other feature to compare with.
213  * \param minDistAngle The placeholder for the angle at which the smallest
214  * distance is found.
215  * \return The distance for the best orientation (minimum distance).
216  */
218  const CFeature& oFeature, float& minDistAngle,
219  bool normalize_distances = true) const;
220 
221  /** Computes the Hamming distance "this" and the "other" descriptor ORB
222  * descriptor */
223  uint8_t descriptorORBDistanceTo(const CFeature& oFeature) const;
224 
225  // # added by Raghavender Sahdev
226  /** Computes the Euclidean Distance between "this" and the "other"
227  * descriptors */
229  const CFeature& oFeature, bool normalize_distances = true) const;
230  /** Computes the Euclidean Distance between "this" and the "other"
231  * descriptors */
233  const CFeature& oFeature, bool normalize_distances = true) const;
234 
235  /** Save the feature to a text file in this format:
236  * "%% Dump of mrpt::vision::CFeatureList. Each line format is:\n"
237  * "%% ID TYPE X Y ORIENTATION SCALE TRACK_STATUS RESPONSE HAS_SIFT
238  *[SIFT] HAS_SURF [SURF] HAS_MULTI [MULTI_i] HAS_ORB [ORB]"
239  * "%% |---------------------- feature ------------------|
240  *|---------------------- descriptors ------------------------|"
241  * "%% with:\n"
242  * "%% TYPE : The used detector: 0:KLT, 1: Harris, 2: BCD, 3: SIFT, 4:
243  *SURF, 5: Beacon, 6: FAST, 7: ORB\n"
244  * "%% HAS_* : 1 if a descriptor of that type is associated to the
245  *feature."
246  * "%% SIFT : Present if HAS_SIFT=1: N DESC_0 ... DESC_N-1"
247  * "%% SURF : Present if HAS_SURF=1: N DESC_0 ... DESC_N-1"
248  * "%% MULTI : Present if HAS_MULTI=1: SCALE ORI N DESC_0 ... DESC_N-1"
249  * "%% ORB : Present if HAS_ORB=1: DESC_0 ... DESC_31
250  * "%%-----------------------------------------------------------------------------\n");
251  */
252  void saveToTextFile(const std::string& filename, bool APPEND = false);
253 
254  /** Get the type of the feature
255  */
256  TKeyPointMethod get_type() const { return type; }
257  /** Dump feature information into a text stream */
258  void dumpToTextStream(std::ostream& out) const;
259 
260  void dumpToConsole() const;
261 
262  protected:
263  /** Internal function used by "descriptorLogPolarImgDistanceTo" and
264  * "descriptorPolarImgDistanceTo"
265  */
267  const mrpt::math::CMatrixF& desc1, const mrpt::math::CMatrixF& desc2,
268  float& minDistAngle, bool normalize_distances, bool dont_shift_angle);
269 
270 }; // end of class
271 
272 /** A list of visual features, to be used as output by detectors, as
273  * input/output by trackers, etc.
274  */
275 class CFeatureList : public mrpt::math::KDTreeCapable<CFeatureList>
276 {
277  protected:
278  using TInternalFeatList = std::vector<CFeature>;
279 
280  /** The actual container with the list of features */
282 
283  public:
284  /** The type of the first feature in the list */
285  inline TKeyPointMethod get_type() const
286  {
287  return empty() ? featNotDefined : (*begin()).get_type();
288  }
289 
290  /** Save feature list to a text file */
291  void saveToTextFile(const std::string& fileName, bool APPEND = false);
292 
293  /** Save feature list to a text file */
294  void loadFromTextFile(const std::string& fileName);
295 
296  /** Copies the content of another CFeatureList inside this one. The inner
297  * features are also copied. */
298  void copyListFrom(const CFeatureList& otherList);
299 
300  /** Get the maximum ID into the list */
301  TFeatureID getMaxID() const;
302 
303  /** Get a reference to a Feature from its ID */
304  const CFeature* getByID(const TFeatureID& ID) const;
305  const CFeature* getByID(const TFeatureID& ID, int& out_idx) const;
306 
307  /** Get a reference to the nearest feature to the a given 2D point (version
308  * returning distance to closest feature in "max_dist")
309  * \param x [IN] The query point x-coordinate
310  * \param y [IN] The query point y-coordinate
311  * \param max_dist [IN/OUT] At input: The maximum distance to search for.
312  * At output: The actual distance to the feature.
313  * \return A pointer to the found feature, or nullptr if not found.
314  * \note See also all the available KD-tree search methods, listed in
315  * mrpt::math::KDTreeCapable
316  */
317  const CFeature* nearest(
318  const float x, const float y, double& max_dist) const;
319 
320  /** Constructor */
321  CFeatureList() = default;
322 
323  /** Virtual destructor */
324  virtual ~CFeatureList();
325 
326  /** Call this when the list of features has been modified so the KD-tree is
327  * marked as outdated. */
329  /** @name Method and datatypes to emulate a STL container
330  @{ */
331  using iterator = TInternalFeatList::iterator;
332  using const_iterator = TInternalFeatList::const_iterator;
333 
334  using reverse_iterator = TInternalFeatList::reverse_iterator;
335  using const_reverse_iterator = TInternalFeatList::const_reverse_iterator;
336 
337  inline iterator begin() { return m_feats.begin(); }
338  inline iterator end() { return m_feats.end(); }
339  inline const_iterator begin() const { return m_feats.begin(); }
340  inline const_iterator end() const { return m_feats.end(); }
341  inline reverse_iterator rbegin() { return m_feats.rbegin(); }
342  inline reverse_iterator rend() { return m_feats.rend(); }
343  inline const_reverse_iterator rbegin() const { return m_feats.rbegin(); }
344  inline const_reverse_iterator rend() const { return m_feats.rend(); }
345  inline iterator erase(const iterator& it)
346  {
348  return m_feats.erase(it);
349  }
350 
351  inline bool empty() const { return m_feats.empty(); }
352  inline size_t size() const { return m_feats.size(); }
353  inline void clear()
354  {
355  m_feats.clear();
357  }
358  inline void resize(size_t N)
359  {
360  m_feats.resize(N);
362  }
363 
364  inline void emplace_back(CFeature&& f)
365  {
367  m_feats.emplace_back(std::move(f));
368  }
369  inline void push_back(const CFeature& f)
370  {
372  m_feats.push_back(f);
373  }
374 
375  inline CFeature& operator[](const unsigned int index)
376  {
377  return m_feats[index];
378  }
379  inline const CFeature& operator[](const unsigned int index) const
380  {
381  return m_feats[index];
382  }
383 
384  /** @} */
385 
386  /** @name Methods that MUST be implemented by children classes of
387  KDTreeCapable
388  @{ */
389 
390  /// Must return the number of data points
391  inline size_t kdtree_get_point_count() const { return this->size(); }
392  /// Returns the dim'th component of the idx'th point in the class:
393  inline float kdtree_get_pt(const size_t idx, int dim) const
394  {
395  ASSERTDEB_(dim == 0 || dim == 1);
396  if (dim == 0)
397  return m_feats[idx].keypoint.pt.x;
398  else
399  return m_feats[idx].keypoint.pt.y;
400  }
401 
402  /// Returns the distance between the vector "p1[0:size-1]" and the data
403  /// point with index "idx_p2" stored in the class:
404  inline float kdtree_distance(
405  const float* p1, const size_t idx_p2, size_t size) const
406  {
407  ASSERTDEB_(size == 2);
408  MRPT_UNUSED_PARAM(size); // in release mode
409 
410  const float d0 = p1[0] - m_feats[idx_p2].keypoint.pt.x;
411  const float d1 = p1[1] - m_feats[idx_p2].keypoint.pt.y;
412  return d0 * d0 + d1 * d1;
413  }
414 
415  // Optional bounding-box computation: return false to default to a standard
416  // bbox computation loop.
417  // Return true if the BBOX was already computed by the class and returned
418  // in "bb" so it can be avoided to redo it again.
419  // Look at bb.size() to find out the expected dimensionality (e.g. 2 or 3
420  // for point clouds)
421  template <typename BBOX>
422  bool kdtree_get_bbox(BBOX& bb) const
423  {
424  MRPT_UNUSED_PARAM(bb);
425  return false;
426  }
427 
428  /** @} */
429 
430  /** @name getFeature*() methods for template-based access to feature list
431  @{ */
432  inline float getFeatureX(size_t i) const
433  {
434  return m_feats[i].keypoint.pt.x;
435  }
436  inline float getFeatureY(size_t i) const
437  {
438  return m_feats[i].keypoint.pt.y;
439  }
440  inline TFeatureID getFeatureID(size_t i) const
441  {
442  return m_feats[i].keypoint.ID;
443  }
444  inline float getFeatureResponse(size_t i) const
445  {
446  return m_feats[i].keypoint.response;
447  }
448  inline bool isPointFeature(size_t i) const
449  {
450  return m_feats[i].isPointFeature();
451  }
452  inline float getScale(size_t i) const { return m_feats[i].keypoint.octave; }
454  {
455  return m_feats[i].keypoint.track_status;
456  }
457 
458  inline void setFeatureX(size_t i, float x) { m_feats[i].keypoint.pt.x = x; }
459  inline void setFeatureXf(size_t i, float x)
460  {
461  m_feats[i].keypoint.pt.x = x;
462  }
463  inline void setFeatureY(size_t i, float y) { m_feats[i].keypoint.pt.y = y; }
464  inline void setFeatureYf(size_t i, float y)
465  {
466  m_feats[i].keypoint.pt.y = y;
467  }
468  inline void setFeatureID(size_t i, TFeatureID id)
469  {
470  m_feats[i].keypoint.ID = id;
471  }
472  inline void setFeatureResponse(size_t i, float r)
473  {
474  m_feats[i].keypoint.response = r;
475  }
476  inline void setScale(size_t i, float s) { m_feats[i].keypoint.octave = s; }
477  inline void setTrackStatus(size_t i, TFeatureTrackStatus s)
478  {
479  m_feats[i].keypoint.track_status = s;
480  }
481 
482  inline void mark_as_outdated() const { kdtree_mark_as_outdated(); }
483  /** @} */
484 
485 }; // end of class
486 
487 /****************************************************
488  Class CMATCHEDFEATURELIST
489 *****************************************************/
490 /** A list of features
491  */
492 class CMatchedFeatureList : public std::deque<std::pair<CFeature, CFeature>>
493 {
494  public:
495  /** The type of the first feature in the list */
496  inline TKeyPointMethod get_type() const
497  {
498  return empty() ? featNotDefined : begin()->first.get_type();
499  }
500 
501  /** Save list of matched features to a text file */
502  void saveToTextFile(const std::string& fileName);
503 
504  /** Returns the matching features as two separate CFeatureLists */
505  void getBothFeatureLists(CFeatureList& list1, CFeatureList& list2);
506 
507  /** Returns a smart pointer to the feature with the provided ID or a empty
508  * one if not found */
509  const CFeature* getByID(const TFeatureID& ID, const TListIdx& idx);
510 
511  /** Returns the maximum ID of the features in the list. If the max ID has
512  been already set up, this method just returns it.
513  Otherwise, this method finds, stores and returns it.*/
514  void getMaxID(
515  const TListIdx& idx, TFeatureID& firstListID, TFeatureID& secondListID);
516 
517  /** Updates the value of the maximum ID of the features in the matched list,
518  * i.e. it explicitly searches for the max ID and updates the member
519  * variables. */
520  void updateMaxID(const TListIdx& idx);
521 
522  /** Explicitly set the max IDs values to certain values */
523  inline void setLeftMaxID(const TFeatureID& leftID) { m_leftMaxID = leftID; }
524  inline void setRightMaxID(const TFeatureID& rightID)
525  {
526  m_rightMaxID = rightID;
527  }
528  inline void setMaxIDs(const TFeatureID& leftID, const TFeatureID& rightID)
529  {
530  setLeftMaxID(leftID);
531  setRightMaxID(rightID);
532  }
533 
534  CMatchedFeatureList() = default;
535  virtual ~CMatchedFeatureList() = default;
536 
537  protected:
539 }; // end of class
540 
541 /** @} */ // End of add to module: mrptvision_features
542 
543 } // namespace vision
544 
545 namespace typemeta
546 {
547 // Specialization must occur in the same namespace
549 } // namespace typemeta
550 } // namespace mrpt
void updateMaxID(const TListIdx &idx)
Updates the value of the maximum ID of the features in the matched list, i.e.
Definition: CFeature.cpp:1199
float descriptorDistanceTo(const CFeature &oFeature, TDescriptorType descriptorToUse=descAny, bool normalize_distances=true) const
Computes the Euclidean Distance between this feature&#39;s and other feature&#39;s descriptors, using the given descriptor or the first present one.
Definition: CFeature.cpp:407
const_reverse_iterator rend() const
Definition: CFeature.h:344
uint8_t descriptorORBDistanceTo(const CFeature &oFeature) const
Computes the Hamming distance "this" and the "other" descriptor ORB descriptor.
Definition: CFeature.cpp:734
uint64_t TFeatureID
Definition of a feature ID.
unsigned __int16 uint16_t
Definition: rptypes.h:47
float descriptorSpinImgDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
Definition: CFeature.cpp:532
CFeatureList()=default
Constructor.
TInternalFeatList::iterator iterator
Definition: CFeature.h:331
std::optional< std::vector< uint8_t > > ORB
ORB feature descriptor.
Definition: CFeature.h:135
void loadFromTextFile(const std::string &fileName)
Save feature list to a text file.
Definition: CFeature.cpp:972
Non-defined feature (also used for Occupancy features)
std::optional< std::vector< uint8_t > > BLD
BLD feature descriptor.
Definition: CFeature.h:139
void setRightMaxID(const TFeatureID &rightID)
Definition: CFeature.h:524
TKeyPointMethod type
Keypoint method used to detect this feature.
Definition: CFeature.h:73
TFeatureTrackStatus track_status
Status of the feature tracking process.
Definition: CFeature.h:76
reverse_iterator rend()
Definition: CFeature.h:342
void setFeatureX(size_t i, float x)
Definition: CFeature.h:458
size_t size() const
Definition: CFeature.h:352
void dumpToConsole() const
Definition: CFeature.cpp:325
float descriptorSIFTDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
Definition: CFeature.cpp:477
TFeatureID getFeatureID(size_t i) const
Definition: CFeature.h:440
float getFeatureY(size_t i) const
Definition: CFeature.h:436
float descriptorSURFDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
Definition: CFeature.cpp:504
float getScale(size_t i) const
Definition: CFeature.h:452
void setFeatureResponse(size_t i, float r)
Definition: CFeature.h:472
void setMaxIDs(const TFeatureID &leftID, const TFeatureID &rightID)
Definition: CFeature.h:528
bool isPointFeature(size_t i) const
Definition: CFeature.h:448
GLint GLint GLsizei GLsizei GLsizei depth
Definition: glext.h:3606
const_iterator begin() const
Definition: CFeature.h:339
TKeyPointMethod get_type() const
The type of the first feature in the list.
Definition: CFeature.h:285
void setTrackStatus(size_t i, TFeatureTrackStatus s)
Definition: CFeature.h:477
GLdouble s
Definition: glext.h:3682
float kdtree_distance(const float *p1, const size_t idx_p2, size_t size) const
Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored ...
Definition: CFeature.h:404
const_reverse_iterator rbegin() const
Definition: CFeature.h:343
Used in some methods to mean "any of the present descriptors".
TKeyPointMethod get_type() const
The type of the first feature in the list.
Definition: CFeature.h:496
TInternalFeatList m_feats
The actual container with the list of features.
Definition: CFeature.h:281
unsigned char uint8_t
Definition: rptypes.h:44
A generic adaptor class for providing Nearest Neighbor (NN) lookup via the nanoflann library...
Definition: KDTreeCapable.h:83
void setFeatureY(size_t i, float y)
Definition: CFeature.h:463
const CFeature & operator[](const unsigned int index) const
Definition: CFeature.h:379
reverse_iterator rbegin()
Definition: CFeature.h:341
void push_back(const CFeature &f)
Definition: CFeature.h:369
const_iterator end() const
Definition: CFeature.h:340
void dumpToTextStream(std::ostream &out) const
Dump feature information into a text stream.
Definition: CFeature.cpp:257
TInternalFeatList::reverse_iterator reverse_iterator
Definition: CFeature.h:334
bool polarImgsNoRotation
If set to true (default=false) the call to "descriptorDistanceTo" will not consider all the rotations...
Definition: CFeature.h:132
void getBothFeatureLists(CFeatureList &list1, CFeatureList &list2)
Returns the matching features as two separate CFeatureLists.
Definition: CFeature.cpp:1235
void saveToTextFile(const std::string &filename, bool APPEND=false)
Save the feature to a text file in this format: "%% Dump of mrpt::vision::CFeatureList. Each line format is:\n" "%% ID TYPE X Y ORIENTATION SCALE TRACK_STATUS RESPONSE HAS_SIFT [SIFT] HAS_SURF [SURF] HAS_MULTI [MULTI_i] HAS_ORB [ORB]" "%% |---------------------- feature ------------------| |---------------------- descriptors ------------------------|" "%% with:\n" "%% TYPE : The used detector: 0:KLT, 1: Harris, 2: BCD, 3: SIFT, 4: SURF, 5: Beacon, 6: FAST, 7: ORB\n" "%% HAS_* : 1 if a descriptor of that type is associated to the feature.
Definition: CFeature.cpp:814
Inactive (right after detection, and before being tried to track)
void resize(size_t N)
Definition: CFeature.h:358
TKeyPointf keypoint
Definition: CFeature.h:64
std::optional< mrpt::img::CImage > patch
A patch of the image surrounding the feature.
Definition: CFeature.h:67
void getMaxID(const TListIdx &idx, TFeatureID &firstListID, TFeatureID &secondListID)
Returns the maximum ID of the features in the list.
Definition: CFeature.cpp:1219
GLuint index
Definition: glext.h:4068
CFeature & operator[](const unsigned int index)
Definition: CFeature.h:375
TKeyPointMethod
Types of key point detectors.
TDescriptorType
The bitwise OR combination of values of TDescriptorType are used in CFeatureExtraction::computeDescri...
All the possible descriptors this feature may have.
Definition: CFeature.h:105
Classes for computer vision, detectors, features, etc.
Definition: CDifodo.h:17
uint16_t SpinImg_range_rows
The number of rows (corresponding to range bins in the 2D histogram) of the original matrix from whic...
Definition: CFeature.h:121
TInternalFeatList::const_reverse_iterator const_reverse_iterator
Definition: CFeature.h:335
A generic 2D feature from an image, extracted with CFeatureExtraction Each feature may have one or mo...
Definition: CFeature.h:53
float descriptorLATCHDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
Definition: CFeature.cpp:789
virtual ~CMatchedFeatureList()=default
static float internal_distanceBetweenPolarImages(const mrpt::math::CMatrixF &desc1, const mrpt::math::CMatrixF &desc2, float &minDistAngle, bool normalize_distances, bool dont_shift_angle)
Internal function used by "descriptorLogPolarImgDistanceTo" and "descriptorPolarImgDistanceTo".
Definition: CFeature.cpp:560
iterator erase(const iterator &it)
Definition: CFeature.h:345
void saveToTextFile(const std::string &fileName)
Save list of matched features to a text file.
Definition: CFeature.cpp:1162
GLsizei const GLchar ** string
Definition: glext.h:4116
const CFeature * getByID(const TFeatureID &ID) const
Get a reference to a Feature from its ID.
Definition: CFeature.cpp:1099
A list of visual features, to be used as output by detectors, as input/output by trackers, etc.
Definition: CFeature.h:275
const CFeature * nearest(const float x, const float y, double &max_dist) const
Get a reference to the nearest feature to the a given 2D point (version returning distance to closest...
Definition: CFeature.cpp:1123
uint8_t user_flags
A field for any other flags needed by the user (this has not a predefined meaning) ...
Definition: CFeature.h:86
float kdtree_get_pt(const size_t idx, int dim) const
Returns the dim&#39;th component of the idx&#39;th point in the class:
Definition: CFeature.h:393
void mark_as_outdated() const
Definition: CFeature.h:482
bool empty() const
Definition: ts_hash_map.h:190
mrpt::math::TPoint3D p3D
camera that took its image
Definition: CFeature.h:99
TInternalFeatList::const_iterator const_iterator
Definition: CFeature.h:332
#define MRPT_DECLARE_TTYPENAME_PTR_NAMESPACE(_TYPE, __NS)
Definition: TTypeName.h:142
std::optional< mrpt::math::CMatrixF > PolarImg
A polar image centered at the interest point.
Definition: CFeature.h:124
float getFeatureResponse(size_t i) const
Definition: CFeature.h:444
void saveToTextFile(const std::string &fileName, bool APPEND=false)
Save feature list to a text file.
Definition: CFeature.cpp:894
float response
A measure of the "goodness" of the feature.
Definition: CFeature.h:79
virtual ~CFeatureList()
Virtual destructor.
bool getFirstDescriptorAsMatrix(mrpt::math::CMatrixFloat &desc) const
Return the first found descriptor, as a matrix.
Definition: CFeature.cpp:1254
This class is a "CSerializable" wrapper for "CMatrixFloat".
Definition: CMatrixF.h:22
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
TKeyPointMethod get_type() const
Get the type of the feature.
Definition: CFeature.h:256
const_iterator begin() const
Definition: ts_hash_map.h:229
GLdouble GLdouble GLdouble r
Definition: glext.h:3711
void setFeatureID(size_t i, TFeatureID id)
Definition: CFeature.h:468
std::optional< std::vector< uint8_t > > SIFT
SIFT feature descriptor.
Definition: CFeature.h:110
TDescriptors descriptors
Definition: CFeature.h:157
#define ASSERTDEB_(f)
Defines an assertion mechanism - only when compiled in debug.
Definition: exceptions.h:190
const CFeature * getByID(const TFeatureID &ID, const TListIdx &idx)
Returns a smart pointer to the feature with the provided ID or a empty one if not found...
Definition: CFeature.cpp:1184
float descriptorPolarImgDistanceTo(const CFeature &oFeature, float &minDistAngle, bool normalize_distances=true) const
Returns the minimum Euclidean Distance between "this" and the "other" polar image descriptor...
Definition: CFeature.cpp:675
std::optional< std::vector< float > > SURF
SURF feature descriptor.
Definition: CFeature.h:113
void kdtree_mark_as_outdated() const
To be called by child classes when KD tree data changes.
bool kdtree_get_bbox(BBOX &bb) const
Definition: CFeature.h:422
GLuint id
Definition: glext.h:3920
void setLeftMaxID(const TFeatureID &leftID)
Explicitly set the max IDs values to certain values.
Definition: CFeature.h:523
float patchCorrelationTo(const CFeature &oFeature) const
Computes the normalized cross-correlation between the patches of this and another feature (normalized...
Definition: CFeature.cpp:385
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:30
TFeatureID getMaxID() const
Get the maximum ID into the list.
Definition: CFeature.cpp:1148
GLenum GLint GLint y
Definition: glext.h:3542
void setFeatureYf(size_t i, float y)
Definition: CFeature.h:464
void setFeatureXf(size_t i, float x)
Definition: CFeature.h:459
void setScale(size_t i, float s)
Definition: CFeature.h:476
float y2[2]
Coordinates for a LSD Detector to represent a line.
Definition: CFeature.h:89
GLsizeiptr size
Definition: glext.h:3934
float orientation
Main orientation of the feature.
Definition: CFeature.h:81
GLenum GLint x
Definition: glext.h:3542
Lightweight 3D point.
Definition: TPoint3D.h:90
float descriptorLogPolarImgDistanceTo(const CFeature &oFeature, float &minDistAngle, bool normalize_distances=true) const
Returns the minimum Euclidean Distance between "this" and the "other" log-polar image descriptor...
Definition: CFeature.cpp:703
~CFeature() override=default
This template class provides the basic functionality for a general 2D any-size, resizable container o...
float descriptorBLDDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
Definition: CFeature.cpp:764
uint16_t patchSize
Size of the patch (patchSize x patchSize) (it must be an odd number)
Definition: CFeature.h:70
void mark_kdtree_as_outdated() const
Call this when the list of features has been modified so the KD-tree is marked as outdated...
Definition: CFeature.h:328
GLuint GLuint GLsizei GLenum type
Definition: glext.h:3532
double initialDepth
in the current frame
Definition: CFeature.h:95
void emplace_back(CFeature &&f)
Definition: CFeature.h:364
float getFeatureX(size_t i) const
Definition: CFeature.h:432
std::optional< std::vector< float > > SpinImg
The 2D histogram as a single row.
Definition: CFeature.h:116
std::optional< mrpt::math::CMatrixF > LogPolarImg
A log-polar image centered at the interest point.
Definition: CFeature.h:127
void copyListFrom(const CFeatureList &otherList)
Copies the content of another CFeatureList inside this one.
Definition: CFeature.cpp:1087
TFeatureTrackStatus getTrackStatus(size_t i)
Definition: CFeature.h:453
bool isPointFeature() const
Return false only for Blob detectors (SIFT, SURF)
Definition: CFeature.cpp:377
std::vector< CFeature > TInternalFeatList
Definition: CFeature.h:278
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
Definition: common.h:186
size_t kdtree_get_point_count() const
Must return the number of data points.
Definition: CFeature.h:391
A list of features.
Definition: CFeature.h:492
std::optional< std::vector< uint8_t > > LATCH
LATCH feature descriptor.
Definition: CFeature.h:141



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019