ObjectData.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. //
  2. // Created by wrede on 19.04.16.
  3. //
  4. #ifndef GBMOT_NODEDATA_H
  5. #define GBMOT_NODEDATA_H
  6. #include "Definitions.h"
  7. #include <string>
  8. #include <unordered_map>
  9. #include <iostream>
  10. #include <opencv2/core/core.hpp>
  11. namespace core
  12. {
  13. //TODO RENAME ObjectDataBase / ObjectBase / DataBase / AObject / DetectionBase ...
  14. /**
  15. * Base class for all detected objects.
  16. * Stores the corresponding frame index.
  17. */
  18. class ObjectData
  19. {
  20. private:
  21. /**
  22. * If this node is considered virtual
  23. */
  24. bool is_virtual_;
  25. /**
  26. * The frame the object was detected in
  27. */
  28. std::size_t frame_index_;
  29. /**
  30. * The detection score.
  31. * Defines the quality of this detection.
  32. */
  33. double detection_score_;
  34. /**
  35. * Used in the << operator
  36. * @param os The stream to write to
  37. */
  38. virtual void Print(std::ostream& os) const;
  39. public:
  40. /**
  41. * Creates a new empty virtual ObjectData
  42. */
  43. ObjectData();
  44. /**
  45. * Creates a new ObjectData with the given frame index
  46. * @param frame_index the index in which the object was detected
  47. */
  48. ObjectData(std::size_t frame_index);
  49. /**
  50. * Gets the frame index
  51. * @return The frame index
  52. */
  53. std::size_t GetFrameIndex() const;
  54. /**
  55. * Sets the frame index
  56. * @param index The new frame index
  57. */
  58. void SetFrameIndex(size_t index);
  59. /**
  60. * Sets the detection score
  61. * @param score The detection score
  62. */
  63. void SetDetectionScore(double score);
  64. /**
  65. * Gets the detection score
  66. * @return The detection score
  67. */
  68. double GetDetectionScore();
  69. /**
  70. * Is this node considered a virtual node
  71. * @return True, if this node is virtual
  72. */
  73. bool IsVirtual() const;
  74. //TODO RENAME ObjectDataComparable / IComparable ...
  75. /**
  76. * Compares this object with the given object.
  77. * @param obj A pointer to the object to compare this object to
  78. * @return A double value indicating the comparison result
  79. */
  80. virtual double CompareTo(ObjectDataPtr obj) const;
  81. /**
  82. * Linearly interpolates between this and the given object.
  83. * Creates a new object to fit between the two objects.
  84. * @param obj A pointer to the target object
  85. * @param fraction Describes where the interpolation should
  86. * be done. A fraction of zero is a clone of this object,
  87. * a fraction of one is a clone of the target object.
  88. * @return The interpolated object
  89. */
  90. virtual ObjectDataPtr Interpolate(ObjectDataPtr obj, double fraction) const;
  91. /**
  92. * Visualizes the object in the given image with the given color.
  93. * This method does nothing, it needs to be overwritten to visualize
  94. * something.
  95. * @param image The image to write into
  96. * @param color The color to use
  97. */
  98. virtual void Visualize(cv::Mat& image, cv::Scalar& color) const;
  99. /**
  100. * Overrides the << operator for custom output.
  101. * Calls the print method.
  102. * @param os The stream to write to
  103. * @param obj The object to write into the stream
  104. * @return The stream written to
  105. */
  106. friend std::ostream& operator<<(std::ostream& os, const ObjectData& obj);
  107. };
  108. }
  109. #endif //GBMOT_NODEDATA_H