FClass.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * File: FClass.h
  3. * Date: November 2011
  4. * Author: Dorian Galvez-Lopez
  5. * Description: generic FClass to instantiate templated classes
  6. * License: see the LICENSE.txt file
  7. *
  8. */
  9. #ifndef __D_T_FCLASS__
  10. #define __D_T_FCLASS__
  11. #include <opencv2/core/core.hpp>
  12. #include <vector>
  13. #include <string>
  14. namespace DBoW2 {
  15. /// Generic class to encapsulate functions to manage descriptors.
  16. /**
  17. * This class must be inherited. Derived classes can be used as the
  18. * parameter F when creating Templated structures
  19. * (TemplatedVocabulary, TemplatedDatabase, ...)
  20. */
  21. class FClass
  22. {
  23. class TDescriptor;
  24. typedef const TDescriptor *pDescriptor;
  25. /**
  26. * Calculates the mean value of a set of descriptors
  27. * @param descriptors
  28. * @param mean mean descriptor
  29. */
  30. virtual void meanValue(const std::vector<pDescriptor> &descriptors,
  31. TDescriptor &mean) = 0;
  32. /**
  33. * Calculates the distance between two descriptors
  34. * @param a
  35. * @param b
  36. * @return distance
  37. */
  38. static double distance(const TDescriptor &a, const TDescriptor &b);
  39. /**
  40. * Returns a string version of the descriptor
  41. * @param a descriptor
  42. * @return string version
  43. */
  44. static std::string toString(const TDescriptor &a);
  45. /**
  46. * Returns a descriptor from a string
  47. * @param a descriptor
  48. * @param s string version
  49. */
  50. static void fromString(TDescriptor &a, const std::string &s);
  51. /**
  52. * Returns a mat with the descriptors in float format
  53. * @param descriptors
  54. * @param mat (out) NxL 32F matrix
  55. */
  56. static void toMat32F(const std::vector<TDescriptor> &descriptors,
  57. cv::Mat &mat);
  58. };
  59. } // namespace DBoW2
  60. #endif