ObjectDataMap.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // Created by wrede on 22.04.16.
  3. //
  4. #ifndef GBMOT_OBJECTDATAMAP_H
  5. #define GBMOT_OBJECTDATAMAP_H
  6. #include <string>
  7. #include <unordered_map>
  8. #include <vector>
  9. #include <cmath>
  10. #include "ObjectData.h"
  11. namespace core
  12. {
  13. //TODO RENAME
  14. /**
  15. * Stores a map of key-value-weight pairs.
  16. * The weight is used to compare this object with other objects.
  17. */
  18. class ObjectDataMap : public ObjectData
  19. {
  20. private:
  21. /**
  22. * The stored value-weight-pairs.
  23. */
  24. std::unordered_map<std::string, std::pair<double, double>> value_weight_map_;
  25. protected:
  26. /**
  27. * Used in the << operator
  28. * @param os The stream to write to
  29. */
  30. virtual void Print(std::ostream& os) const;
  31. public:
  32. /**
  33. * Creates a new empty object data map.
  34. * @param frame_index The index of the frame this object was detected in
  35. */
  36. ObjectDataMap(size_t frame_index);
  37. /**
  38. * Creates a object data map with the given keys and values and an
  39. * equal weight for every value.
  40. * @param frame_index The index of the frame this object was detected in
  41. * @param keys The keys for the values to store
  42. * @param value_list The values to store with the given keys
  43. */
  44. ObjectDataMap(
  45. size_t frame_index,
  46. std::vector<std::string> keys,
  47. std::vector<double> value_list);
  48. /**
  49. * Creates a object data map with the given keys and values and an
  50. * given weight for the corresponding key-value pair.
  51. * @param frame_index The index of the frame this object was detected in
  52. * @param keys The keys for the values to store
  53. * @param value_list The values to store with the given keys
  54. * @param weight_list The weights to store with the given key-value pairs
  55. */
  56. ObjectDataMap(
  57. size_t frame_index,
  58. std::vector<std::string> keys,
  59. std::vector<double> value_list,
  60. std::vector<double> weight_list);
  61. /**
  62. * Creates a object data map with the given keys and value-weight pairs.
  63. * @param frame_index The index of the frame this object was detected in
  64. * @param keys The keys for the values to store
  65. * @param value_weight_list The value-weight-pairs to store with the keys
  66. */
  67. ObjectDataMap(
  68. size_t frame_index,
  69. std::vector<std::string> keys,
  70. std::vector<std::pair<double, double>> value_weight_list);
  71. /**
  72. * Gets the value of the given key.
  73. * @param key The key for the value
  74. * @return The value
  75. */
  76. double GetValue(std::string key);
  77. /**
  78. * Gets the weight of the given key.
  79. * @param key The key for the value
  80. * @return The weight
  81. */
  82. double GetWeight(std::string key);
  83. //TODO find a better name
  84. /**
  85. * Stores the given value-weight pair with the given key.
  86. * If the key is already stored it will be overridden with the new pair.
  87. * @param key The key to store the value-weight pair at
  88. * @param value The value of the value-weight pair
  89. * @param weight The weight of the value-weight pair
  90. */
  91. void PutValueWeight(std::string key, double value, double weight);
  92. /**
  93. * Stores the given value-weight pair with the given key.
  94. * If the key is already stored it will be overridden with the new pair.
  95. * @param key The key to store the value-weight pair at
  96. * @param value_weight The value-weight pair
  97. */
  98. void PutValueWeight(std::string key, std::pair<double, double> value_weight);
  99. /**
  100. * Compares this object with the given object by calculating the difference
  101. * in every value and applies the corresponding weight to that difference.
  102. * Than all weighted differences are summed up.
  103. * @param obj A pointer to the object to compare this object to
  104. * @return The summed up weighted differences
  105. */
  106. virtual double CompareTo(ObjectData *obj);
  107. /**
  108. * Compares this object with the given object by calculating the difference
  109. * in every value and applies the corresponding weight to that difference.
  110. * Than all weighted differences are summed up.
  111. * @param obj A pointer to the object to compare this object to
  112. * @return The summed up weighted differences
  113. */
  114. virtual double CompareTo(ObjectDataMap *obj);
  115. };
  116. }
  117. #endif //GBMOT_OBJECTDATAMAP_H