Parser.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // Created by wrede on 22.04.16.
  3. //
  4. #ifndef GBMOT_PARSE_H
  5. #define GBMOT_PARSE_H
  6. #include "../core/DetectionSequence.h"
  7. #include "../core/ObjectData.h"
  8. #include "../core/ObjectDataMap.h"
  9. #include "../core/ObjectData3D.h"
  10. #include "Grid.h"
  11. #include "FileIO.h"
  12. #include <opencv2/core/core.hpp>
  13. namespace util
  14. {
  15. typedef std::vector<std::vector<std::vector<double>>> Vector3d;
  16. typedef std::vector<std::vector<double>> Vector2d;
  17. /**
  18. * Utility class for parsing diverse objects.
  19. */
  20. class Parser
  21. {
  22. public:
  23. static const std::string KEY_FRAME;
  24. static const std::string KEY_ID;
  25. static const std::string KEY_SCORE;
  26. static const std::string KEY_X;
  27. static const std::string KEY_Y;
  28. static const std::string KEY_Z;
  29. static const std::string KEY_WIDTH;
  30. static const std::string KEY_HEIGHT;
  31. static const std::string KEY_DEPTH;
  32. static const std::string KEY_ANGLE;
  33. //TODO rework old parsers
  34. /**
  35. * Parses the keys and values into a DetectionSequence of ObjectDataMap
  36. * objects.
  37. * The keys are used for the third dimension in the values list.
  38. * @param keys A 1D vector of keys
  39. * @param values A 3D vector of values
  40. * @param sequence The sequence to store the created objects in
  41. */
  42. static void ParseObjectDataMap(const std::vector<std::string>& keys,
  43. const Vector3d& values,
  44. core::DetectionSequence& sequence);
  45. /**
  46. * Parses the values into a DetectionSequence of ObjectData3D
  47. * @param values A 3D vector of values
  48. * @param sequence The sequence to store the created objects in
  49. */
  50. static void ParseObjectData3D(const Vector3d& values,
  51. core::DetectionSequence& sequence);
  52. /**
  53. * Parses the values into a DetectionSequence of ObjectDataAngular objects.
  54. * @param values A 3D vector of values
  55. * @param sequence The sequence to store the created objects in
  56. */
  57. static void ParseObjectDataAngular(const Vector3d& values,
  58. core::DetectionSequence& sequence);
  59. /**
  60. * Parses the values into a DetectionSequence of ObjectDataAngular objects.
  61. * The keys are used for the third dimension in the values list.
  62. * @param values A 3D vector of values
  63. * @param sequence The sequence to store the created objects in
  64. * @param temporal_weight The temporal weight
  65. * @param spatial_weight The spatial weight
  66. * @param angular_weight The angular weight
  67. */
  68. static void ParseObjectDataAngular(const Vector3d& values,
  69. core::DetectionSequence& sequence,
  70. double temporal_weight,
  71. double spatial_weight,
  72. double angular_weight);
  73. /**
  74. * Parses the given sequence into a grid.
  75. * The sequence data need to be a ObjectData2D.
  76. * The frame index is the depth of the grid.
  77. * @param sequence The detection sequence to parse
  78. * @param min_x The minimal x value
  79. * @param max_x The maximal x value
  80. * @param res_x The number of cells on the x axis
  81. * @param min_y The minimal y value
  82. * @param max_y The maximal y value
  83. * @param res_y The number of cells on the y axis
  84. * @return The grid with the detection values
  85. */
  86. static Grid ParseGrid(
  87. core::DetectionSequence& sequence,
  88. double min_x, double max_x, int res_x,
  89. double min_y, double max_y, int res_y);
  90. //TODO comment
  91. static void ParseObjectDataBox(ValueMapVector& values,
  92. core::DetectionSequence& sequence,
  93. double image_width = 1.0,
  94. double image_height = 1.0,
  95. double temporal_weight = 1.0,
  96. double spatial_weight = 1.0);
  97. };
  98. }
  99. #endif //GBMOT_PARSE_H