ObjectDataMap.h 4.0 KB

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