ObjectData.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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, double fraction) const
  44. {
  45. size_t index = static_cast<size_t>(
  46. util::MyMath::Lerp(GetFrameIndex(), obj->GetFrameIndex(), fraction));
  47. return ObjectDataPtr(new ObjectData(index));
  48. }
  49. std::ostream& operator<<(std::ostream &os, const ObjectData &obj)
  50. {
  51. obj.Print(os);
  52. return os;
  53. }
  54. void ObjectData::SetFrameIndex(size_t index)
  55. {
  56. frame_index_ = index;
  57. }
  58. void ObjectData::Visualize(cv::Mat& image, cv::Scalar& color) const
  59. {
  60. /* EMPTY */
  61. }
  62. void ObjectData::SetDetectionScore(double score)
  63. {
  64. detection_score_ = score;
  65. }
  66. double ObjectData::GetDetectionScore() const
  67. {
  68. return detection_score_;
  69. }
  70. }