DetectionSequence.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // Created by wrede on 19.04.16.
  3. //
  4. #include "DetectionSequence.h"
  5. namespace core
  6. {
  7. DetectionSequence::DetectionSequence(std::string name)
  8. {
  9. name_ = name;
  10. objects_ = std::vector<std::vector<ObjectData>>();
  11. }
  12. void DetectionSequence::AddObject(ObjectData object_data)
  13. {
  14. if (object_data.GetFrameIndex() >= objects_.size())
  15. {
  16. objects_.push_back(std::vector<ObjectData>());
  17. }
  18. objects_[object_data.GetFrameIndex()].push_back(object_data);
  19. }
  20. void DetectionSequence::Clear()
  21. {
  22. objects_.clear();
  23. }
  24. std::string DetectionSequence::GetName() const
  25. {
  26. return name_;
  27. }
  28. ObjectData DetectionSequence::GetObject(
  29. size_t frame_index, size_t object_index)
  30. {
  31. return objects_[frame_index][object_index];
  32. }
  33. size_t DetectionSequence::GetFrameCount() const
  34. {
  35. return objects_.size();
  36. }
  37. size_t DetectionSequence::GetObjectCount(size_t frame_index) const
  38. {
  39. return objects_[frame_index].size();
  40. }
  41. void DetectionSequence::Print(std::ostream &os) const
  42. {
  43. for (size_t frame_i = 0; frame_i < objects_.size(); ++frame_i)
  44. {
  45. os << "Frame: " << frame_i << std::endl;
  46. for (size_t object_i = 0;
  47. object_i < objects_[frame_i].size();
  48. ++object_i)
  49. {
  50. os << objects_[frame_i][object_i] << std::endl;
  51. }
  52. }
  53. os << std::endl;
  54. }
  55. std::ostream& operator<<(std::ostream &os, const DetectionSequence &obj)
  56. {
  57. obj.Print(os);
  58. return os;
  59. }
  60. }