ObjectData.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // Created by wrede on 19.04.16.
  3. //
  4. #include <cmath>
  5. #include "ObjectData.h"
  6. #include "../util/MyMath.h"
  7. namespace core
  8. {
  9. ObjectData::ObjectData()
  10. : frame_index_(0), is_virtual_(true), detection_score_(0.0)
  11. {
  12. /* EMPTY */
  13. }
  14. ObjectData::ObjectData(std::size_t frame_index)
  15. : frame_index_(frame_index), is_virtual_(false), detection_score_(0.0)
  16. {
  17. /* EMPTY */
  18. }
  19. std::size_t ObjectData::GetFrameIndex() const
  20. {
  21. return frame_index_;
  22. }
  23. bool ObjectData::IsVirtual() const
  24. {
  25. return is_virtual_;
  26. }
  27. void ObjectData::Print(std::ostream &os) const
  28. {
  29. if (is_virtual_)
  30. {
  31. os << "Object{-}";
  32. }
  33. else
  34. {
  35. os << "Object{" << frame_index_ << "}";
  36. }
  37. }
  38. double ObjectData::CompareTo(ObjectDataPtr obj) const
  39. {
  40. /* EMPTY */
  41. return 0.0;
  42. }
  43. ObjectDataPtr ObjectData::Interpolate(ObjectDataPtr obj,
  44. double fraction) const
  45. {
  46. size_t index = static_cast<size_t>(
  47. util::MyMath::Lerp(
  48. GetFrameIndex(), obj->GetFrameIndex(), fraction));
  49. return ObjectDataPtr(new ObjectData(index));
  50. }
  51. std::ostream& operator<<(std::ostream &os, const ObjectData &obj)
  52. {
  53. obj.Print(os);
  54. return os;
  55. }
  56. void ObjectData::SetFrameIndex(size_t index)
  57. {
  58. frame_index_ = index;
  59. }
  60. void ObjectData::Visualize(cv::Mat& image, cv::Scalar& color) const
  61. {
  62. /* EMPTY */
  63. }
  64. void ObjectData::SetDetectionScore(double score)
  65. {
  66. detection_score_ = score;
  67. }
  68. double ObjectData::GetDetectionScore() const
  69. {
  70. return detection_score_;
  71. }
  72. }