ObjectData2D.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. static const std::string CONSTRAINT_X_DIFFERENCE;
  19. static const std::string CONSTRAINT_Y_DIFFERENCE;
  20. /**
  21. * The position in the two dimensional space
  22. */
  23. const cv::Point2d position_;
  24. /**
  25. * The weight of the temporal distance for the comparison.
  26. * The temporal distance is the frame difference.
  27. */
  28. double temporal_weight_;
  29. /**
  30. * The weight of the spatial distance for the comparison.
  31. * The spatial distance is the euclidean distance of the positions.
  32. */
  33. double spatial_weight_;
  34. virtual void Print(std::ostream& os) const override;
  35. public:
  36. /**
  37. * Creates a new detection with the given index and position.
  38. * @param frame_index The frame index
  39. * @param position The position in three dimensional space
  40. */
  41. ObjectData2D(size_t frame_index, cv::Point2d position);
  42. /**
  43. * Sets the temporal weight.
  44. * @param weight The temporal weight
  45. */
  46. void SetTemporalWeight(double weight);
  47. /**
  48. * Sets the spatial weight
  49. * @param weight The spatial weight
  50. */
  51. void SetSpatialWeight(double weight);
  52. /**
  53. * Gets the position in two dimensional space.
  54. * @return The position
  55. */
  56. cv::Point2d GetPosition() const;
  57. /**
  58. * Gets the temporal weight.
  59. * @return The temporal weight
  60. */
  61. double GetTemporalWeight() const;
  62. /**
  63. * Gets the spatial weight
  64. * @return The spatial weight
  65. */
  66. double GetSpatialWeight() const;
  67. virtual double CompareTo(ObjectDataPtr obj) const override;
  68. virtual bool IsWithinConstraints(ObjectDataPtr obj,
  69. std::unordered_map<std::string, double> & constraints)
  70. const override;
  71. virtual ObjectDataPtr Interpolate(ObjectDataPtr obj, double fraction) const override;
  72. virtual void Visualize(cv::Mat& image, cv::Scalar& color, double alpha) const override;
  73. virtual std::string ToString(char delimiter) const override;
  74. };
  75. }
  76. #endif //GBMOT_OBJECTDATA2D_H