ObjectDataMap.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. virtual void Print(std::ostream& os) const;
  26. public:
  27. /**
  28. * Creates a new empty object data map.
  29. * @param frame_index The index of the frame this object was detected in
  30. */
  31. ObjectDataMap(size_t frame_index);
  32. /**
  33. * Creates a object data map with the given keys and values and an
  34. * equal weight for every value.
  35. * @param frame_index The index of the frame this object was detected in
  36. * @param keys The keys for the values to store
  37. * @param value_list The values to store with the given keys
  38. */
  39. ObjectDataMap(
  40. size_t frame_index,
  41. std::vector<std::string> keys,
  42. std::vector<double> value_list);
  43. /**
  44. * Creates a object data map with the given keys and values and an
  45. * given weight for the corresponding key-value pair.
  46. * @param frame_index The index of the frame this object was detected in
  47. * @param keys The keys for the values to store
  48. * @param value_list The values to store with the given keys
  49. * @param weight_list The weights to store with the given key-value pairs
  50. */
  51. ObjectDataMap(
  52. size_t frame_index,
  53. std::vector<std::string> keys,
  54. std::vector<double> value_list,
  55. std::vector<double> weight_list);
  56. /**
  57. * Creates a object data map with the given keys and value-weight pairs.
  58. * @param frame_index The index of the frame this object was detected in
  59. * @param keys The keys for the values to store
  60. * @param value_weight_list The value-weight-pairs to store with the keys
  61. */
  62. ObjectDataMap(
  63. size_t frame_index,
  64. std::vector<std::string> keys,
  65. std::vector<std::pair<double, double>> value_weight_list);
  66. /**
  67. * Gets the value of the given key.
  68. * @param key The key for the value
  69. * @return The value
  70. */
  71. double GetValue(std::string key);
  72. /**
  73. * Gets the weight of the given key.
  74. * @param key The key for the value
  75. * @return The weight
  76. */
  77. double GetWeight(std::string key);
  78. //TODO RENAME
  79. /**
  80. * Stores the given value-weight pair with the given key.
  81. * If the key is already stored it will be overridden with the new pair.
  82. * @param key The key to store the value-weight pair at
  83. * @param value The value of the value-weight pair
  84. * @param weight The weight of the value-weight pair
  85. */
  86. void Put(std::string key, double value, double weight);
  87. /**
  88. * Stores the given value-weight pair with the given key.
  89. * If the key is already stored it will be overridden with the new pair.
  90. * @param key The key to store the value-weight pair at
  91. * @param value_weight The value-weight pair
  92. */
  93. void Put(std::string key, std::pair<double, double> value_weight);
  94. virtual double CompareTo(ObjectDataPtr obj) const override;
  95. virtual ObjectDataPtr Interpolate(ObjectDataPtr obj, double fraction) const override;
  96. virtual void Visualize(cv::Mat& image, cv::Scalar& color) const override;
  97. };
  98. }
  99. #endif //GBMOT_OBJECTDATAMAP_H