ObjectData2D.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // Created by wrede on 02.06.16.
  3. //
  4. #ifndef GBMOT_OBJECTDATA2D_H
  5. #define GBMOT_OBJECTDATA2D_H
  6. #include "ObjectData.h"
  7. namespace core
  8. {
  9. class ObjectData2D;
  10. typedef std::shared_ptr<ObjectData2D> ObjectData2DPtr;
  11. /**
  12. * Class for storing a detection in two dimensional space.
  13. */
  14. class ObjectData2D : public ObjectData
  15. {
  16. private:
  17. static const std::string CONSTRAINT_DISTANCE_EUCLID;
  18. /**
  19. * The position in the two dimensional space
  20. */
  21. const cv::Point2d position_;
  22. /**
  23. * The weight of the temporal distance for the comparison.
  24. * The temporal distance is the frame difference.
  25. */
  26. double temporal_weight_;
  27. /**
  28. * The weight of the spatial distance for the comparison.
  29. * The spatial distance is the euclidean distance of the positions.
  30. */
  31. double spatial_weight_;
  32. virtual void Print(std::ostream& os) const override;
  33. public:
  34. /**
  35. * Creates a new detection with the given index and position.
  36. * @param frame_index The frame index
  37. * @param position The position in three dimensional space
  38. */
  39. ObjectData2D(size_t frame_index, cv::Point2d position);
  40. /**
  41. * Sets the temporal weight.
  42. * @param weight The temporal weight
  43. */
  44. void SetTemporalWeight(double weight);
  45. /**
  46. * Sets the spatial weight
  47. * @param weight The spatial weight
  48. */
  49. void SetSpatialWeight(double weight);
  50. /**
  51. * Gets the position in two dimensional space.
  52. * @return The position
  53. */
  54. cv::Point2d GetPosition() const;
  55. /**
  56. * Gets the temporal weight.
  57. * @return The temporal weight
  58. */
  59. double GetTemporalWeight() const;
  60. /**
  61. * Gets the spatial weight
  62. * @return The spatial weight
  63. */
  64. double GetSpatialWeight() const;
  65. virtual double CompareTo(ObjectDataPtr obj) const override;
  66. virtual bool IsWithinConstraints(ObjectDataPtr obj,
  67. std::unordered_map<std::string, double> & constraints)
  68. const override;
  69. virtual ObjectDataPtr Interpolate(ObjectDataPtr obj, double fraction) const override;
  70. virtual void Visualize(cv::Mat& image, cv::Scalar& color) const override;
  71. virtual std::string ToString(char delimiter) const override;
  72. };
  73. }
  74. #endif //GBMOT_OBJECTDATA2D_H