DetectionSequence.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // Created by wrede on 19.04.16.
  3. //
  4. #ifndef GBMOT_DETECTIONSEQUENCE_H
  5. #define GBMOT_DETECTIONSEQUENCE_H
  6. #include <string>
  7. #include "ObjectData.h"
  8. namespace core
  9. {
  10. /**
  11. * Class for storing a full sequence of frame, each with multiple
  12. * detected objects.
  13. */
  14. class DetectionSequence
  15. {
  16. private:
  17. /**
  18. * Display name
  19. */
  20. std::string name_;
  21. /**
  22. * Two dimensional vector of pointers to all detected objects.
  23. * The first dimension is the frame.
  24. * The second dimension is the object in that frame.
  25. */
  26. std::unordered_map<size_t, std::vector<ObjectDataPtr>> objects_;
  27. //TODO ORIGINAL
  28. // std::vector<std::vector<ObjectDataPtr>> objects_;
  29. /**
  30. * The frame offset for the first detection
  31. */
  32. size_t frame_offset_;
  33. /**
  34. * The frame count
  35. */
  36. size_t frame_count_;
  37. public:
  38. /**
  39. * Creates a detection sequence with the given name.
  40. *
  41. * @param name The name of this sequence
  42. */
  43. DetectionSequence(std::string const & name = "DetectionSequence");
  44. /**
  45. * Adds a new object, creates a new frame vector if the given objects
  46. * frame index is greater than the current frame vector size.
  47. *
  48. * @param object_data The object to add
  49. */
  50. void AddObject(ObjectDataPtr object_data);
  51. /**
  52. * Removes all objects.
  53. */
  54. void Clear();
  55. /**
  56. * Gets the name of this sequence.
  57. *
  58. * @return The name
  59. */
  60. std::string GetName() const;
  61. /**
  62. * Gets a pointer to the object in the given frame with the given index.
  63. *
  64. * @param frame_index The frame to get the object from
  65. * @param object_index The objects index in the corresponding frame
  66. * @return A pointer to the stored object data
  67. */
  68. ObjectDataPtr GetObject(size_t frame_index, size_t object_index);
  69. /**
  70. * Gets the frame count.
  71. *
  72. * @return The frame count
  73. */
  74. size_t GetFrameCount() const;
  75. /**
  76. * Gets the frame offset.
  77. *
  78. * @return The Frame offset
  79. */
  80. size_t GetFrameOffset() const;
  81. /**
  82. * Gets the object count in the given frame.
  83. *
  84. * @param frame_index The frame to get the object count of
  85. * @return The number of objects in this frame
  86. */
  87. size_t GetObjectCount(size_t frame_index);
  88. /**
  89. * Overrides the << operator for easy output.
  90. *
  91. * @param os The stream to write to
  92. * @param obj The object to write into the stream
  93. * @return The stream written to
  94. */
  95. friend std::ostream & operator<<(std::ostream & os, DetectionSequence const & obj);
  96. };
  97. }
  98. #endif //GBMOT_DETECTIONSEQUENCE_H