MRPT  2.0.1
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-2020, 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) */
70  uint16_t patchSize{21};
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) */
86  uint8_t user_flags{0};
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  */
121  uint16_t SpinImg_range_rows{0};
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,
406  [[maybe_unused]] size_t size) const
407  {
408  ASSERTDEB_(size == 2);
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([[maybe_unused]] BBOX& bb) const
423  {
424  return false;
425  }
426 
427  /** @} */
428 
429  /** @name getFeature*() methods for template-based access to feature list
430  @{ */
431  inline float getFeatureX(size_t i) const
432  {
433  return m_feats[i].keypoint.pt.x;
434  }
435  inline float getFeatureY(size_t i) const
436  {
437  return m_feats[i].keypoint.pt.y;
438  }
439  inline TFeatureID getFeatureID(size_t i) const
440  {
441  return m_feats[i].keypoint.ID;
442  }
443  inline float getFeatureResponse(size_t i) const
444  {
445  return m_feats[i].keypoint.response;
446  }
447  inline bool isPointFeature(size_t i) const
448  {
449  return m_feats[i].isPointFeature();
450  }
451  inline float getScale(size_t i) const { return m_feats[i].keypoint.octave; }
453  {
454  return m_feats[i].keypoint.track_status;
455  }
456 
457  inline void setFeatureX(size_t i, float x) { m_feats[i].keypoint.pt.x = x; }
458  inline void setFeatureXf(size_t i, float x)
459  {
460  m_feats[i].keypoint.pt.x = x;
461  }
462  inline void setFeatureY(size_t i, float y) { m_feats[i].keypoint.pt.y = y; }
463  inline void setFeatureYf(size_t i, float y)
464  {
465  m_feats[i].keypoint.pt.y = y;
466  }
467  inline void setFeatureID(size_t i, TFeatureID id)
468  {
469  m_feats[i].keypoint.ID = id;
470  }
471  inline void setFeatureResponse(size_t i, float r)
472  {
473  m_feats[i].keypoint.response = r;
474  }
475  inline void setScale(size_t i, uint8_t s)
476  {
477  m_feats[i].keypoint.octave = s;
478  }
479  inline void setTrackStatus(size_t i, TFeatureTrackStatus s)
480  {
481  m_feats[i].keypoint.track_status = s;
482  }
483 
484  inline void mark_as_outdated() const { kdtree_mark_as_outdated(); }
485  /** @} */
486 
487 }; // end of class
488 
489 /****************************************************
490  Class CMATCHEDFEATURELIST
491 *****************************************************/
492 /** A list of features
493  */
494 class CMatchedFeatureList : public std::deque<std::pair<CFeature, CFeature>>
495 {
496  public:
497  /** The type of the first feature in the list */
498  inline TKeyPointMethod get_type() const
499  {
500  return empty() ? featNotDefined : begin()->first.get_type();
501  }
502 
503  /** Save list of matched features to a text file */
504  void saveToTextFile(const std::string& fileName);
505 
506  /** Returns the matching features as two separate CFeatureLists */
507  void getBothFeatureLists(CFeatureList& list1, CFeatureList& list2);
508 
509  /** Returns a smart pointer to the feature with the provided ID or a empty
510  * one if not found */
511  const CFeature* getByID(const TFeatureID& ID, const TListIdx& idx);
512 
513  /** Returns the maximum ID of the features in the list. If the max ID has
514  been already set up, this method just returns it.
515  Otherwise, this method finds, stores and returns it.*/
516  void getMaxID(
517  const TListIdx& idx, TFeatureID& firstListID, TFeatureID& secondListID);
518 
519  /** Updates the value of the maximum ID of the features in the matched list,
520  * i.e. it explicitly searches for the max ID and updates the member
521  * variables. */
522  void updateMaxID(const TListIdx& idx);
523 
524  /** Explicitly set the max IDs values to certain values */
525  inline void setLeftMaxID(const TFeatureID& leftID) { m_leftMaxID = leftID; }
526  inline void setRightMaxID(const TFeatureID& rightID)
527  {
528  m_rightMaxID = rightID;
529  }
530  inline void setMaxIDs(const TFeatureID& leftID, const TFeatureID& rightID)
531  {
532  setLeftMaxID(leftID);
533  setRightMaxID(rightID);
534  }
535 
536  CMatchedFeatureList() = default;
537  virtual ~CMatchedFeatureList() = default;
538 
539  protected:
541 }; // end of class
542 
543 /** @} */ // End of add to module: mrptvision_features
544 
545 } // namespace vision
546 
547 namespace typemeta
548 {
549 // Specialization must occur in the same namespace
551 } // namespace typemeta
552 } // 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:1186
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:394
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:721
uint64_t TFeatureID
Definition of a feature ID.
float descriptorSpinImgDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
Definition: CFeature.cpp:519
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:959
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:526
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:457
size_t size() const
Definition: CFeature.h:352
void dumpToConsole() const
Definition: CFeature.cpp:312
float descriptorSIFTDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
Definition: CFeature.cpp:464
TFeatureID getFeatureID(size_t i) const
Definition: CFeature.h:439
float getFeatureY(size_t i) const
Definition: CFeature.h:435
float descriptorSURFDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
Definition: CFeature.cpp:491
float getScale(size_t i) const
Definition: CFeature.h:451
void setFeatureResponse(size_t i, float r)
Definition: CFeature.h:471
void setMaxIDs(const TFeatureID &leftID, const TFeatureID &rightID)
Definition: CFeature.h:530
bool isPointFeature(size_t i) const
Definition: CFeature.h:447
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:479
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:498
TInternalFeatList m_feats
The actual container with the list of features.
Definition: CFeature.h:281
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:462
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:253
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
double depth
The estimated depth in 3D of this feature wrt the camera.
Definition: CFeature.h:91
void getBothFeatureLists(CFeatureList &list1, CFeatureList &list2)
Returns the matching features as two separate CFeatureLists.
Definition: CFeature.cpp:1222
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:801
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:1206
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:776
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:547
bool kdtree_get_bbox([[maybe_unused]] BBOX &bb) const
Definition: CFeature.h:422
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:1149
const CFeature * getByID(const TFeatureID &ID) const
Get a reference to a Feature from its ID.
Definition: CFeature.cpp:1086
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:1110
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:484
bool empty() const
Definition: ts_hash_map.h:191
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:443
void saveToTextFile(const std::string &fileName, bool APPEND=false)
Save feature list to a text file.
Definition: CFeature.cpp:881
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:1241
void setScale(size_t i, uint8_t s)
Definition: CFeature.h:475
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.
TKeyPointMethod get_type() const
Get the type of the feature.
Definition: CFeature.h:256
const_iterator begin() const
Definition: ts_hash_map.h:240
void setFeatureID(size_t i, TFeatureID id)
Definition: CFeature.h:467
std::optional< std::vector< uint8_t > > SIFT
SIFT feature descriptor.
Definition: CFeature.h:110
mrpt::vision::TStereoCalibResults out
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:1171
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:662
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.
void setLeftMaxID(const TFeatureID &leftID)
Explicitly set the max IDs values to certain values.
Definition: CFeature.h:525
float kdtree_distance(const float *p1, const size_t idx_p2, [[maybe_unused]] 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
float patchCorrelationTo(const CFeature &oFeature) const
Computes the normalized cross-correlation between the patches of this and another feature (normalized...
Definition: CFeature.cpp:372
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:1135
void setFeatureYf(size_t i, float y)
Definition: CFeature.h:463
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
void setFeatureXf(size_t i, float x)
Definition: CFeature.h:458
float y2[2]
Coordinates for a LSD Detector to represent a line.
Definition: CFeature.h:89
float orientation
Main orientation of the feature.
Definition: CFeature.h:81
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:690
~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:751
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
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:431
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:1074
TFeatureTrackStatus getTrackStatus(size_t i)
Definition: CFeature.h:452
bool isPointFeature() const
Return false only for Blob detectors (SIFT, SURF)
Definition: CFeature.cpp:364
std::vector< CFeature > TInternalFeatList
Definition: CFeature.h:278
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:494
std::optional< std::vector< uint8_t > > LATCH
LATCH feature descriptor.
Definition: CFeature.h:141



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020