MRPT  1.9.9
CFeature.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+
9  */
10 #ifndef CFeature_H
11 #define CFeature_H
12 
13 #include <mrpt/img/CImage.h>
14 #include <mrpt/math/CMatrix.h>
16 
17 #include <mrpt/vision/types.h>
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, TSimpleFeature, TSimpleFeatureList
52  */
54 {
55  friend class CFeatureList;
56  friend class CMatchedFeatureList;
57 
59 
60  public:
61  float x, y; //!< Coordinates in the image
62  TFeatureID ID; //!< ID of the feature
63  mrpt::img::CImage patch; //!< A patch of the image surrounding the feature
64  uint16_t patchSize; //!< Size of the patch (patchSize x patchSize) (it must
65  //! be an odd number)
66  TFeatureType type; //!< Type of the feature: featNotDefined, featSIFT,
67  //! featKLT, featHarris, featSURF, featBeacon
68  TFeatureTrackStatus track_status; //!< Status of the feature tracking
69  //! process (old name: KLT_status)
70  float response; //!< A measure of the "goodness" of the feature (old name:
71  //! KLT_val)
72  float orientation; //!< Main orientation of the feature
73  float scale; //!< Feature scale into the scale space
74  uint8_t user_flags; //!< A field for any other flags needed by the user
75  //!(this has not a predefined meaning)
76  uint16_t nTimesSeen; //!< Number of frames it has been seen in a sequence
77  //! of images.
78  uint16_t nTimesNotSeen; //!< Number of frames it has not been seen in a
79  //! sequence of images.
80  uint16_t nTimesLastSeen; //!< Number of frames since it was seen for the
81  //! last time.
82 
83  // # added by Raghavender Sahdev
84  float x2[2], y2[2]; //!< Coordinates for a LSD Detector to represent a line
85 
86  double depth; //!< The estimated depth in 3D of this feature wrt the camera
87  //! in the current frame
88  double initialDepth; //!< The estimated depth in 3D of this feature wrt the
89  //! camera that took its image
91  p3D; //!< The estimated 3D point of this feature wrt its camera
92  std::deque<double> multiScales; //!< A set of scales where the
93  //! multi-resolution descriptor has been
94  //! computed
95  std::deque<std::vector<double>> multiOrientations; //!< A vector of main
96  //! orientations (there
97  //! is a vector of
98  //! orientations for each
99  //! scale)
100  std::deque<std::vector<std::vector<int32_t>>>
101  multiHashCoeffs; //!< A set of vectors containing the coefficients for
102  //! a HASH table of descriptors
103  bool isPointFeature()
104  const; //!< Return false only for Blob detectors (SIFT, SURF)
105 
106  /** All the possible descriptors this feature may have */
108  {
109  TDescriptors(); // Initialization
110 
111  std::vector<uint8_t> SIFT; //!< SIFT feature descriptor
112  std::vector<float> SURF; //!< SURF feature descriptor
113  std::vector<float> SpinImg; //!< The 2D histogram as a single row
114  uint16_t SpinImg_range_rows; //!< The number of rows (corresponding to
115  //! range bins in the 2D histogram) of the
116  //! original matrix from which SpinImg was
117  //! extracted as a vector.
119  PolarImg; //!< A polar image centered at the interest point
121  LogPolarImg; //!< A log-polar image centered at the interest point
122  bool polarImgsNoRotation; //!< If set to true (manually, default=false)
123  //! the call to "descriptorDistanceTo" will
124  //! not consider all the rotations between
125  //! polar image descriptors (PolarImg,
126  //! LogPolarImg)
127  std::deque<std::vector<std::vector<int32_t>>>
128  multiSIFTDescriptors; //!< A set of SIFT-like descriptors for each
129  //! orientation and scale of the
130  //! multiResolution feature (there is a vector
131  //! of descriptors for each scale)
132  std::vector<uint8_t> ORB; //!< ORB feature descriptor
133  // # added by Raghavender Sadev
134  std::vector<uint8_t> BLD; //!< BLD feature descriptor
135  std::vector<uint8_t> LATCH; //!< LATCH feature descriptor
136 
137  bool hasDescriptorSIFT() const
138  {
139  return !SIFT.empty();
140  }; //!< Whether this feature has this kind of descriptor
141  bool hasDescriptorSURF() const
142  {
143  return !SURF.empty();
144  } //!< Whether this feature has this kind of descriptor
145  bool hasDescriptorSpinImg() const
146  {
147  return !SpinImg.empty();
148  }; //!< Whether this feature has this kind of descriptor
150  {
151  return PolarImg.rows() != 0;
152  }; //!< Whether this feature has this kind of descriptor
154  {
155  return LogPolarImg.rows() != 0;
156  }; //!< Whether this feature has this kind of descriptor
158  {
159  return (
160  multiSIFTDescriptors.size() > 0 &&
161  multiSIFTDescriptors[0].size() >
162  0); //!< Whether this feature has this kind of descriptor
163  }
164  bool hasDescriptorORB() const
165  {
166  return !ORB.empty();
167  } //!< Whether this feature has this kind of descriptor
168  //# added by Raghavender Sahdev
169  bool hasDescriptorBLD() const
170  {
171  return !BLD.empty();
172  } //!< Whether this feature has this kind of descriptor
173  bool hasDescriptorLATCH() const
174  {
175  return !LATCH.empty();
176  } //!< Whether this feature has this kind of descriptor
177  } descriptors;
178 
179  /** Return the first found descriptor, as a matrix.
180  * \return false on error, i.e. there is no valid descriptor.
181  */
183 
184  /** Computes the normalized cross-correlation between the patches of this
185  * and another feature (normalized in the range [0,1], such as 0=best,
186  * 1=worst).
187  * \note If this or the other features does not have patches or they are
188  * of different sizes, an exception will be raised.
189  * \sa descriptorDistanceTo
190  */
191  float patchCorrelationTo(const CFeature& oFeature) const;
192 
193  /** Computes the Euclidean Distance between this feature's and other
194  * feature's descriptors, using the given descriptor or the first present
195  * one.
196  * \note If descriptorToUse is not descAny and that descriptor is not
197  * present in one of the features, an exception will be raised.
198  * \sa patchCorrelationTo
199  */
200  float descriptorDistanceTo(
201  const CFeature& oFeature, TDescriptorType descriptorToUse = descAny,
202  bool normalize_distances = true) const;
203 
204  /** Computes the Euclidean Distance between "this" and the "other"
205  * descriptors */
207  const CFeature& oFeature, bool normalize_distances = true) const;
208 
209  /** Computes the Euclidean Distance between "this" and the "other"
210  * descriptors */
212  const CFeature& oFeature, bool normalize_distances = true) const;
213 
214  /** Computes the Euclidean Distance between "this" and the "other"
215  * descriptors */
217  const CFeature& oFeature, bool normalize_distances = true) const;
218 
219  /** Returns the minimum Euclidean Distance between "this" and the "other"
220  * polar image descriptor, for the best shift in orientation.
221  * \param oFeature The other feature to compare with.
222  * \param minDistAngle The placeholder for the angle at which the smallest
223  * distance is found.
224  * \return The distance for the best orientation (minimum distance).
225  */
227  const CFeature& oFeature, float& minDistAngle,
228  bool normalize_distances = true) const;
229 
230  /** Returns the minimum Euclidean Distance between "this" and the "other"
231  * log-polar image descriptor, for the best shift in orientation.
232  * \param oFeature The other feature to compare with.
233  * \param minDistAngle The placeholder for the angle at which the smallest
234  * distance is found.
235  * \return The distance for the best orientation (minimum distance).
236  */
238  const CFeature& oFeature, float& minDistAngle,
239  bool normalize_distances = true) const;
240 
241  /** Computes the Hamming distance "this" and the "other" descriptor ORB
242  * descriptor */
243  uint8_t descriptorORBDistanceTo(const CFeature& oFeature) const;
244 
245  // # added by Raghavender Sahdev
246  /** Computes the Euclidean Distance between "this" and the "other"
247  * descriptors */
249  const CFeature& oFeature, bool normalize_distances = true) const;
250  /** Computes the Euclidean Distance between "this" and the "other"
251  * descriptors */
253  const CFeature& oFeature, bool normalize_distances = true) const;
254 
255  /** Save the feature to a text file in this format:
256  * "%% Dump of mrpt::vision::CFeatureList. Each line format is:\n"
257  * "%% ID TYPE X Y ORIENTATION SCALE TRACK_STATUS RESPONSE HAS_SIFT
258  *[SIFT] HAS_SURF [SURF] HAS_MULTI [MULTI_i] HAS_ORB [ORB]"
259  * "%% |---------------------- feature ------------------|
260  *|---------------------- descriptors ------------------------|"
261  * "%% with:\n"
262  * "%% TYPE : The used detector: 0:KLT, 1: Harris, 2: BCD, 3: SIFT, 4:
263  *SURF, 5: Beacon, 6: FAST, 7: ORB\n"
264  * "%% HAS_* : 1 if a descriptor of that type is associated to the
265  *feature."
266  * "%% SIFT : Present if HAS_SIFT=1: N DESC_0 ... DESC_N-1"
267  * "%% SURF : Present if HAS_SURF=1: N DESC_0 ... DESC_N-1"
268  * "%% MULTI : Present if HAS_MULTI=1: SCALE ORI N DESC_0 ... DESC_N-1"
269  * "%% ORB : Present if HAS_ORB=1: DESC_0 ... DESC_31
270  * "%%-----------------------------------------------------------------------------\n");
271  */
272  void saveToTextFile(const std::string& filename, bool APPEND = false);
273 
274  /** Get the type of the feature
275  */
276  TFeatureType get_type() const { return type; }
277  /** Dump feature information into a text stream */
278  void dumpToTextStream(std::ostream& out) const;
279 
280  void dumpToConsole() const;
281 
282  /** Constructor
283  */
284  CFeature();
285 
286  /** Virtual destructor */
287  virtual ~CFeature() {}
288  protected:
289  /** Internal function used by "descriptorLogPolarImgDistanceTo" and
290  * "descriptorPolarImgDistanceTo"
291  */
293  const mrpt::math::CMatrix& desc1, const mrpt::math::CMatrix& desc2,
294  float& minDistAngle, bool normalize_distances, bool dont_shift_angle);
295 
296 }; // end of class
297 
298 /****************************************************
299  Class CFEATURELIST
300 *****************************************************/
301 /** A list of visual features, to be used as output by detectors, as
302  * input/output by trackers, etc.
303  */
304 class CFeatureList : public mrpt::math::KDTreeCapable<CFeatureList>
305 {
306  protected:
307  using TInternalFeatList = std::vector<CFeature::Ptr>;
308 
310  m_feats; //!< The actual container with the list of features
311 
312  public:
313  /** The type of the first feature in the list */
314  inline TFeatureType get_type() const
315  {
316  return empty() ? featNotDefined : (*begin())->get_type();
317  }
318 
319  /** Save feature list to a text file */
320  void saveToTextFile(const std::string& fileName, bool APPEND = false);
321 
322  /** Save feature list to a text file */
323  void loadFromTextFile(const std::string& fileName);
324 
325  /** Copies the content of another CFeatureList inside this one. The inner
326  * features are also copied. */
327  void copyListFrom(const CFeatureList& otherList);
328 
329  /** Get the maximum ID into the list */
330  TFeatureID getMaxID() const;
331 
332  /** Get a reference to a Feature from its ID */
333  CFeature::Ptr getByID(const TFeatureID& ID) const;
334  CFeature::Ptr getByID(const TFeatureID& ID, int& out_idx) const;
335 
336  /** Get a vector of references to a subset of features from their IDs */
337  void getByMultiIDs(
338  const std::vector<TFeatureID>& IDs, std::vector<CFeature::Ptr>& out,
339  std::vector<int>& outIndex) const;
340 
341  /** Get a reference to the nearest feature to the a given 2D point (version
342  * returning distance to closest feature in "max_dist")
343  * \param x [IN] The query point x-coordinate
344  * \param y [IN] The query point y-coordinate
345  * \param max_dist [IN/OUT] At input: The maximum distance to search for.
346  * At output: The actual distance to the feature.
347  * \return A reference to the found feature, or a nullptr smart pointer if
348  * none found.
349  * \note See also all the available KD-tree search methods, listed in
350  * mrpt::math::KDTreeCapable
351  */
352  CFeature::Ptr nearest(const float x, const float y, double& max_dist) const;
353 
354  /** Constructor */
355  CFeatureList();
356 
357  /** Virtual destructor */
358  virtual ~CFeatureList();
359 
360  /** Call this when the list of features has been modified so the KD-tree is
361  * marked as outdated. */
363  /** @name Method and datatypes to emulate a STL container
364  @{ */
367 
368  using reverse_iterator = TInternalFeatList::reverse_iterator;
369  using const_reverse_iterator = TInternalFeatList::const_reverse_iterator;
370 
371  inline iterator begin() { return m_feats.begin(); }
372  inline iterator end() { return m_feats.end(); }
373  inline const_iterator begin() const { return m_feats.begin(); }
374  inline const_iterator end() const { return m_feats.end(); }
375  inline reverse_iterator rbegin() { return m_feats.rbegin(); }
376  inline reverse_iterator rend() { return m_feats.rend(); }
377  inline const_reverse_iterator rbegin() const { return m_feats.rbegin(); }
378  inline const_reverse_iterator rend() const { return m_feats.rend(); }
379  inline iterator erase(const iterator& it)
380  {
382  return m_feats.erase(it);
383  }
384 
385  inline bool empty() const { return m_feats.empty(); }
386  inline size_t size() const { return m_feats.size(); }
387  inline void clear()
388  {
389  m_feats.clear();
391  }
392  inline void resize(size_t N)
393  {
394  m_feats.resize(N);
396  }
397 
398  inline void push_back(const CFeature::Ptr& f)
399  {
401  m_feats.push_back(f);
402  }
403 
404  inline CFeature::Ptr& operator[](const unsigned int index)
405  {
406  return m_feats[index];
407  }
408  inline const CFeature::Ptr& operator[](const unsigned int index) const
409  {
410  return m_feats[index];
411  }
412 
413  /** @} */
414 
415  /** @name Methods that MUST be implemented by children classes of
416  KDTreeCapable
417  @{ */
418 
419  /// Must return the number of data points
420  inline size_t kdtree_get_point_count() const { return this->size(); }
421  /// Returns the dim'th component of the idx'th point in the class:
422  inline float kdtree_get_pt(const size_t idx, int dim) const
423  {
424  ASSERTDEB_(dim == 0 || dim == 1);
425  if (dim == 0)
426  return m_feats[idx]->x;
427  else
428  return m_feats[idx]->y;
429  }
430 
431  /// Returns the distance between the vector "p1[0:size-1]" and the data
432  /// point with index "idx_p2" stored in the class:
433  inline float kdtree_distance(
434  const float* p1, const size_t idx_p2, size_t size) const
435  {
436  ASSERTDEB_(size == 2);
437  MRPT_UNUSED_PARAM(size); // in release mode
438 
439  const float d0 = p1[0] - m_feats[idx_p2]->x;
440  const float d1 = p1[1] - m_feats[idx_p2]->y;
441  return d0 * d0 + d1 * d1;
442  }
443 
444  // Optional bounding-box computation: return false to default to a standard
445  // bbox computation loop.
446  // Return true if the BBOX was already computed by the class and returned
447  // in "bb" so it can be avoided to redo it again.
448  // Look at bb.size() to find out the expected dimensionality (e.g. 2 or 3
449  // for point clouds)
450  template <typename BBOX>
451  bool kdtree_get_bbox(BBOX& bb) const
452  {
453  MRPT_UNUSED_PARAM(bb);
454  return false;
455  }
456 
457  /** @} */
458 
459  /** @name getFeature*() methods for template-based access to feature list
460  @{ */
461  inline float getFeatureX(size_t i) const { return m_feats[i]->x; }
462  inline float getFeatureY(size_t i) const { return m_feats[i]->y; }
463  inline TFeatureID getFeatureID(size_t i) const { return m_feats[i]->ID; }
464  inline float getFeatureResponse(size_t i) const
465  {
466  return m_feats[i]->response;
467  }
468  inline bool isPointFeature(size_t i) const
469  {
470  return m_feats[i]->isPointFeature();
471  }
472  inline float getScale(size_t i) const { return m_feats[i]->scale; }
474  {
475  return m_feats[i]->track_status;
476  }
477 
478  inline void setFeatureX(size_t i, float x) { m_feats[i]->x = x; }
479  inline void setFeatureXf(size_t i, float x) { m_feats[i]->x = x; }
480  inline void setFeatureY(size_t i, float y) { m_feats[i]->y = y; }
481  inline void setFeatureYf(size_t i, float y) { m_feats[i]->y = y; }
482  inline void setFeatureID(size_t i, TFeatureID id) { m_feats[i]->ID = id; }
483  inline void setFeatureResponse(size_t i, float r)
484  {
485  m_feats[i]->response = r;
486  }
487  inline void setScale(size_t i, float s) { m_feats[i]->scale = s; }
488  inline void setTrackStatus(size_t i, TFeatureTrackStatus s)
489  {
490  m_feats[i]->track_status = s;
491  }
492 
493  inline void mark_as_outdated() const { kdtree_mark_as_outdated(); }
494  /** @} */
495 
496 }; // end of class
497 
498 /****************************************************
499  Class CMATCHEDFEATURELIST
500 *****************************************************/
501 /** A list of features
502  */
504  : public std::deque<std::pair<CFeature::Ptr, CFeature::Ptr>>
505 {
506  public:
507  /** The type of the first feature in the list */
508  inline TFeatureType get_type() const
509  {
510  return empty() ? featNotDefined : (begin()->first)->get_type();
511  }
512 
513  /** Save list of matched features to a text file */
514  void saveToTextFile(const std::string& fileName);
515 
516  /** Returns the matching features as two separate CFeatureLists */
517  void getBothFeatureLists(CFeatureList& list1, CFeatureList& list2);
518 
519  /** Returns a smart pointer to the feature with the provided ID or a empty
520  * one if not found */
521  CFeature::Ptr getByID(const TFeatureID& ID, const TListIdx& idx);
522 
523  /** Returns the maximum ID of the features in the list. If the max ID has
524  been already set up, this method just returns it.
525  Otherwise, this method finds, stores and returns it.*/
526  void getMaxID(
527  const TListIdx& idx, TFeatureID& firstListID, TFeatureID& secondListID);
528 
529  /** Updates the value of the maximum ID of the features in the matched list,
530  * i.e. it explicitly searches for the max ID and updates the member
531  * variables. */
532  void updateMaxID(const TListIdx& idx);
533 
534  /** Explicitly set the max IDs values to certain values */
535  inline void setLeftMaxID(const TFeatureID& leftID) { m_leftMaxID = leftID; }
536  inline void setRightMaxID(const TFeatureID& rightID)
537  {
538  m_rightMaxID = rightID;
539  }
540  inline void setMaxIDs(const TFeatureID& leftID, const TFeatureID& rightID)
541  {
542  setLeftMaxID(leftID);
543  setRightMaxID(rightID);
544  };
545 
546  /** Constructor */
548 
549  /** Virtual destructor */
550  virtual ~CMatchedFeatureList();
551 
552  protected:
554 }; // end of class
555 
556 /** @} */ // End of add to module: mrptvision_features
557 
558 } // namespace vision
559 
560 namespace typemeta
561 {
562 // Specialization must occur in the same namespace
564 } // namespace typemeta
565 } // namespace mrpt
566 
567 #endif
void updateMaxID(const TListIdx &idx)
Updates the value of the maximum ID of the features in the matched list, i.e.
Definition: CFeature.cpp:1392
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:523
Scalar * iterator
Definition: eigen_plugins.h:26
Non-defined feature (also used for Occupancy features)
TFeatureID ID
ID of the feature.
Definition: CFeature.h:62
EIGEN_STRONG_INLINE bool empty() const
const_reverse_iterator rend() const
Definition: CFeature.h:378
uint8_t descriptorORBDistanceTo(const CFeature &oFeature) const
Computes the Hamming distance "this" and the "other" descriptor ORB descriptor.
Definition: CFeature.cpp:846
uint64_t TFeatureID
Definition of a feature ID.
unsigned __int16 uint16_t
Definition: rptypes.h:44
float descriptorSpinImgDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
Definition: CFeature.cpp:645
bool hasDescriptorBLD() const
Whether this feature has this kind of descriptor.
Definition: CFeature.h:169
uint16_t nTimesSeen
(this has not a predefined meaning)
Definition: CFeature.h:76
float scale
Feature scale into the scale space.
Definition: CFeature.h:73
TInternalFeatList::iterator iterator
Definition: CFeature.h:365
Used in some methods to mean "any of the present descriptors".
std::vector< uint8_t > BLD
BLD feature descriptor.
Definition: CFeature.h:134
void loadFromTextFile(const std::string &fileName)
Save feature list to a text file.
Definition: CFeature.cpp:1117
bool hasDescriptorLogPolarImg() const
Whether this feature has this kind of descriptor.
Definition: CFeature.h:153
void setRightMaxID(const TFeatureID &rightID)
Definition: CFeature.h:536
std::vector< CFeature::Ptr > TInternalFeatList
Definition: CFeature.h:307
TFeatureTrackStatus track_status
featKLT, featHarris, featSURF, featBeacon
Definition: CFeature.h:68
reverse_iterator rend()
Definition: CFeature.h:376
void setFeatureX(size_t i, float x)
Definition: CFeature.h:478
size_t size() const
Definition: CFeature.h:386
void dumpToConsole() const
Definition: CFeature.cpp:399
float x2[2]
last time.
Definition: CFeature.h:84
float descriptorSIFTDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
Definition: CFeature.cpp:593
TFeatureID getFeatureID(size_t i) const
Definition: CFeature.h:463
float getFeatureY(size_t i) const
Definition: CFeature.h:462
float descriptorSURFDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
Definition: CFeature.cpp:618
float getScale(size_t i) const
Definition: CFeature.h:472
uint16_t nTimesLastSeen
sequence of images.
Definition: CFeature.h:80
void setFeatureResponse(size_t i, float r)
Definition: CFeature.h:483
void getByMultiIDs(const std::vector< TFeatureID > &IDs, std::vector< CFeature::Ptr > &out, std::vector< int > &outIndex) const
Get a vector of references to a subset of features from their IDs.
Definition: CFeature.cpp:1282
EIGEN_STRONG_INLINE iterator begin()
Definition: eigen_plugins.h:29
void setMaxIDs(const TFeatureID &leftID, const TFeatureID &rightID)
Definition: CFeature.h:540
bool isPointFeature(size_t i) const
Definition: CFeature.h:468
std::vector< float > SURF
SURF feature descriptor.
Definition: CFeature.h:112
std::deque< double > multiScales
A set of scales where the.
Definition: CFeature.h:92
const_iterator begin() const
Definition: CFeature.h:373
TFeatureType get_type() const
Get the type of the feature.
Definition: CFeature.h:276
mrpt::math::CMatrix LogPolarImg
A log-polar image centered at the interest point.
Definition: CFeature.h:121
float y
Coordinates in the image.
Definition: CFeature.h:61
void setTrackStatus(size_t i, TFeatureTrackStatus s)
Definition: CFeature.h:488
GLdouble s
Definition: glext.h:3676
bool hasDescriptorMultiSIFT() const
Whether this feature has this kind of descriptor.
Definition: CFeature.h:157
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:433
const_reverse_iterator rbegin() const
Definition: CFeature.h:377
TInternalFeatList m_feats
The actual container with the list of features.
Definition: CFeature.h:310
unsigned char uint8_t
Definition: rptypes.h:41
A generic adaptor class for providing Nearest Neighbor (NN) lookup via the nanoflann library...
Definition: KDTreeCapable.h:77
void setFeatureY(size_t i, float y)
Definition: CFeature.h:480
reverse_iterator rbegin()
Definition: CFeature.h:375
const_iterator end() const
Definition: CFeature.h:374
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:368
bool polarImgsNoRotation
If set to true (manually, default=false)
Definition: CFeature.h:122
TFeatureType type
be an odd number)
Definition: CFeature.h:66
double depth
The estimated depth in 3D of this feature wrt the camera.
Definition: CFeature.h:86
void getBothFeatureLists(CFeatureList &list1, CFeatureList &list2)
Returns the matching features as two separate CFeatureLists.
Definition: CFeature.cpp:1429
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:926
void resize(size_t N)
Definition: CFeature.h:392
uint16_t nTimesNotSeen
of images.
Definition: CFeature.h:78
virtual ~CFeature()
Virtual destructor.
Definition: CFeature.h:287
void getMaxID(const TListIdx &idx, TFeatureID &firstListID, TFeatureID &secondListID)
Returns the maximum ID of the features in the list.
Definition: CFeature.cpp:1413
static float internal_distanceBetweenPolarImages(const mrpt::math::CMatrix &desc1, const mrpt::math::CMatrix &desc2, float &minDistAngle, bool normalize_distances, bool dont_shift_angle)
Internal function used by "descriptorLogPolarImgDistanceTo" and "descriptorPolarImgDistanceTo".
Definition: CFeature.cpp:672
GLuint index
Definition: glext.h:4054
const CFeature::Ptr & operator[](const unsigned int index) const
Definition: CFeature.h:408
CFeature::Ptr & operator[](const unsigned int index)
Definition: CFeature.h:404
std::deque< std::vector< std::vector< int32_t > > > multiHashCoeffs
orientations (there is a vector of orientations for each scale)
Definition: CFeature.h:101
std::vector< uint8_t > SIFT
SIFT feature descriptor.
Definition: CFeature.h:111
std::deque< std::vector< double > > multiOrientations
multi-resolution descriptor has been computed
Definition: CFeature.h:95
CFeature()
Constructor.
Definition: CFeature.cpp:456
All the possible descriptors this feature may have.
Definition: CFeature.h:107
Classes for computer vision, detectors, features, etc.
Definition: CCamModel.h:18
uint16_t SpinImg_range_rows
The number of rows (corresponding to.
Definition: CFeature.h:114
TInternalFeatList::const_reverse_iterator const_reverse_iterator
Definition: CFeature.h:369
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:900
iterator erase(const iterator &it)
Definition: CFeature.h:379
bool hasDescriptorORB() const
Whether this feature has this kind of descriptor.
Definition: CFeature.h:164
void saveToTextFile(const std::string &fileName)
Save list of matched features to a text file.
Definition: CFeature.cpp:1355
GLsizei const GLchar ** string
Definition: glext.h:4101
A list of visual features, to be used as output by detectors, as input/output by trackers, etc.
Definition: CFeature.h:304
uint8_t user_flags
A field for any other flags needed by the user.
Definition: CFeature.h:74
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:422
TDescriptorType
The bitwise OR combination of values of TDescriptorType are used in CFeatureExtraction::computeDescri...
void mark_as_outdated() const
Definition: CFeature.h:493
mrpt::math::TPoint3D p3D
camera that took its image
Definition: CFeature.h:91
TInternalFeatList::const_iterator const_iterator
Definition: CFeature.h:366
CFeature::Ptr 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:1377
#define MRPT_DECLARE_TTYPENAME_PTR_NAMESPACE(_TYPE, __NS)
Definition: TTypeName.h:138
TFeatureType
Types of features - This means that the point has been detected with this algorithm, which is independent of additional descriptors a feature may also have.
float getFeatureResponse(size_t i) const
Definition: CFeature.h:464
bool hasDescriptorLATCH() const
Whether this feature has this kind of descriptor.
Definition: CFeature.h:173
CFeature::Ptr 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:1303
struct mrpt::vision::CFeature::TDescriptors descriptors
void saveToTextFile(const std::string &fileName, bool APPEND=false)
Save feature list to a text file.
Definition: CFeature.cpp:1039
float response
process (old name: KLT_status)
Definition: CFeature.h:70
virtual ~CFeatureList()
Virtual destructor.
Definition: CFeature.cpp:1033
bool getFirstDescriptorAsMatrix(mrpt::math::CMatrixFloat &desc) const
Return the first found descriptor, as a matrix.
Definition: CFeature.cpp:1449
CFeatureList()
Constructor.
Definition: CFeature.cpp:1029
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...
GLdouble GLdouble GLdouble r
Definition: glext.h:3705
void setFeatureID(size_t i, TFeatureID id)
Definition: CFeature.h:482
std::vector< float > SpinImg
The 2D histogram as a single row.
Definition: CFeature.h:113
#define ASSERTDEB_(f)
Defines an assertion mechanism - only when compiled in debug.
Definition: exceptions.h:205
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:790
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:451
GLuint id
Definition: glext.h:3909
std::vector< uint8_t > LATCH
LATCH feature descriptor.
Definition: CFeature.h:135
void setLeftMaxID(const TFeatureID &leftID)
Explicitly set the max IDs values to certain values.
Definition: CFeature.h:535
float patchCorrelationTo(const CFeature &oFeature) const
Computes the normalized cross-correlation between the patches of this and another feature (normalized...
Definition: CFeature.cpp:504
virtual ~CMatchedFeatureList()
Virtual destructor.
Definition: CFeature.cpp:1351
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:1328
GLenum GLint GLint y
Definition: glext.h:3538
void setFeatureYf(size_t i, float y)
Definition: CFeature.h:481
void setFeatureXf(size_t i, float x)
Definition: CFeature.h:479
void setScale(size_t i, float s)
Definition: CFeature.h:487
float y2[2]
Coordinates for a LSD Detector to represent a line.
Definition: CFeature.h:84
bool hasDescriptorPolarImg() const
Whether this feature has this kind of descriptor.
Definition: CFeature.h:149
GLsizeiptr size
Definition: glext.h:3923
float orientation
KLT_val)
Definition: CFeature.h:72
GLenum GLint x
Definition: glext.h:3538
TFeatureType get_type() const
The type of the first feature in the list.
Definition: CFeature.h:314
Lightweight 3D point.
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:816
This class is a "CSerializable" wrapper for "CMatrixFloat".
Definition: CMatrix.h:22
mrpt::img::CImage patch
A patch of the image surrounding the feature.
Definition: CFeature.h:63
float descriptorBLDDistanceTo(const CFeature &oFeature, bool normalize_distances=true) const
Computes the Euclidean Distance between "this" and the "other" descriptors.
Definition: CFeature.cpp:875
uint16_t patchSize
Size of the patch (patchSize x patchSize) (it must.
Definition: CFeature.h:64
const Scalar * const_iterator
Definition: eigen_plugins.h:27
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:362
std::deque< std::vector< std::vector< int32_t > > > multiSIFTDescriptors
the call to "descriptorDistanceTo" will not consider all the rotations between polar image descriptor...
Definition: CFeature.h:128
CFeature::Ptr getByID(const TFeatureID &ID) const
Get a reference to a Feature from its ID.
Definition: CFeature.cpp:1255
double initialDepth
in the current frame
Definition: CFeature.h:88
float getFeatureX(size_t i) const
Definition: CFeature.h:461
mrpt::math::CMatrix PolarImg
range bins in the 2D histogram) of the original matrix from which SpinImg was extracted as a vector...
Definition: CFeature.h:119
void copyListFrom(const CFeatureList &otherList)
Copies the content of another CFeatureList inside this one.
Definition: CFeature.cpp:1239
void push_back(const CFeature::Ptr &f)
Definition: CFeature.h:398
TFeatureTrackStatus getTrackStatus(size_t i)
Definition: CFeature.h:473
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130
bool isPointFeature() const
a HASH table of descriptors
Definition: CFeature.cpp:496
TFeatureType get_type() const
The type of the first feature in the list.
Definition: CFeature.h:508
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
Definition: common.h:186
bool hasDescriptorSURF() const
Whether this feature has this kind of descriptor.
Definition: CFeature.h:141
size_t kdtree_get_point_count() const
Must return the number of data points.
Definition: CFeature.h:420
A list of features.
Definition: CFeature.h:503
std::vector< uint8_t > ORB
orientation and scale of the multiResolution feature (there is a vector of descriptors for each scale...
Definition: CFeature.h:132



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020