Parser.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 "Grid.h"
  9. #include "FileIO.h"
  10. #include <opencv2/core/core.hpp>
  11. namespace util
  12. {
  13. typedef std::vector<std::vector<std::vector<double>>> Vector3d;
  14. typedef std::vector<std::vector<double>> Vector2d;
  15. /**
  16. * Utility class for parsing diverse objects.
  17. */
  18. class Parser
  19. {
  20. public:
  21. static const std::string KEY_FRAME;
  22. static const std::string KEY_ID;
  23. static const std::string KEY_SCORE;
  24. static const std::string KEY_X;
  25. static const std::string KEY_Y;
  26. static const std::string KEY_Z;
  27. static const std::string KEY_WIDTH;
  28. static const std::string KEY_HEIGHT;
  29. static const std::string KEY_DEPTH;
  30. static const std::string KEY_ANGLE;
  31. /**
  32. * Parses the specified values into the specified sequence.
  33. * The used format is ObjectData2D.
  34. *
  35. * @param values The input values
  36. * @param sequence The output sequence containing the parsed values
  37. * @param image_width The width of the image used for normalized
  38. * coordinates
  39. * @param image_height The height of the image used for normalized
  40. * coordinates
  41. * @param temporal_weight The temporal weight
  42. * @param spatial_weight The spatial weight
  43. */
  44. static void ParseObjectData2D(ValueMapVector& values,
  45. core::DetectionSequence& sequence,
  46. double image_width,
  47. double image_height,
  48. double temporal_weight,
  49. double spatial_weight);
  50. /**
  51. * Parses the specified values into the specified sequence.
  52. * The used format is ObjectDataBox.
  53. *
  54. * @param values The input values
  55. * @param sequence The output sequence containing the parsed values
  56. * @param image_width The width of the image used for normalized
  57. * coordinates
  58. * @param image_height The height of the image used for normalized
  59. * coordinates
  60. * @param temporal_weight The temporal weight
  61. * @param spatial_weight The spatial weight
  62. */
  63. static void ParseObjectDataBox(ValueMapVector& values,
  64. core::DetectionSequence& sequence,
  65. double image_width,
  66. double image_height,
  67. double temporal_weight,
  68. double spatial_weight);
  69. /**
  70. * Parses the specified values into the specified sequence.
  71. * The used format is ObjectDataAngular.
  72. *
  73. * @param values The input values
  74. * @param sequence The sequence to store the created objects in
  75. * @param image_width The width of the image used for normalized
  76. * coordinates
  77. * @param image_height The height of the image used for normalized
  78. * coordinates
  79. * @param temporal_weight The temporal weight
  80. * @param spatial_weight The spatial weight
  81. * @param angular_weight The angular weight
  82. */
  83. static void ParseObjectDataAngular(ValueMapVector& values,
  84. core::DetectionSequence& sequence,
  85. double image_width,
  86. double image_height,
  87. double temporal_weight,
  88. double spatial_weight,
  89. double angular_weight);
  90. /**
  91. * Parses the given sequence into a grid.
  92. * The sequence data need to be a ObjectData2D.
  93. * The frame index is the depth of the grid.
  94. *
  95. * @param sequence The detection sequence to parse
  96. * @param start The first frame to use
  97. * @param stop The first frame not to use
  98. * @param min_x The minimal x value
  99. * @param max_x The maximal x value
  100. * @param res_x The number of cells on the x axis
  101. * @param min_y The minimal y value
  102. * @param max_y The maximal y value
  103. * @param res_y The number of cells on the y axis
  104. * @return The grid with the detection values
  105. */
  106. static Grid ParseGrid(
  107. core::DetectionSequence& sequence,
  108. size_t start, size_t stop,
  109. double min_x, double max_x, int res_x,
  110. double min_y, double max_y, int res_y);
  111. };
  112. }
  113. #endif //GBMOT_PARSE_H