Berclaz.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // Created by wrede on 02.06.16.
  3. //
  4. #ifndef GBMOT_BERCLAZ_H
  5. #define GBMOT_BERCLAZ_H
  6. #include "../graph/Definitions.h"
  7. #include "../core/DetectionSequence.h"
  8. #include "../core/Tracklet.h"
  9. #include "../util/Grid.h"
  10. namespace algo
  11. {
  12. class Berclaz
  13. {
  14. private:
  15. const double VIRTUAL_EDGE_WEIGHT = 0.0;
  16. const double MAX_SCORE_VALUE = 0.999999;
  17. const double MIN_SCORE_VALUE = 0.000001;
  18. /**
  19. * Horizontal grid resolution
  20. */
  21. int h_res_;
  22. /**
  23. * Vertical grid resolution
  24. */
  25. int v_res_;
  26. /**
  27. * The number of cells a detection can move within one frame
  28. */
  29. int vicinity_size_;
  30. /**
  31. * Creates a graph from the given sequence.
  32. *
  33. * @param graph The graph to write into
  34. * @param source A reference to the source vertex
  35. * @param sink A reference to the sink vertex
  36. * @param grid The detection values as a grid
  37. */
  38. void CreateGraph(DirectedGraph& graph, Vertex& source, Vertex& sink,
  39. util::Grid& grid);
  40. /**
  41. * Extracts the final tracks from the given graph and predecessor map.
  42. *
  43. * @param graph The graph to read the values from
  44. * @param map The predecessor map to read the paths from
  45. * @param origin The vertex to start the reverse path traversal from
  46. * @param tracks The vector to fill with the extracted tracks
  47. */
  48. void ExtractTracks(DirectedGraph& graph,
  49. MultiPredecessorMap& map, Vertex origin,
  50. std::vector<core::TrackletPtr>& tracks);
  51. //TODO comment
  52. void ConnectTracks(std::vector<core::TrackletPtr>& tracks);
  53. public:
  54. /**
  55. * Instantiate with the given parameters.
  56. *
  57. * @param h_res The horizontal grid resolution
  58. * @param v_res The vertical grid resolution
  59. * @param vicinity_size The maximum number of cells a detection can skip
  60. * within one frame
  61. */
  62. Berclaz(int h_res, int v_res, int vicinity_size);
  63. /**
  64. * Runs the algorithm on the given sequence. Splits the sequence into
  65. * batches to allow faster processing.
  66. *
  67. * @param sequence The detection to use
  68. * @param batch_size The number of frames one batch will have at maximum
  69. * @param max_track_count The maximum number of tracks to extract
  70. * @param tracks The vector to store the found tracks into
  71. */
  72. void Run(core::DetectionSequence& sequence, size_t batch_size,
  73. size_t max_track_count, std::vector<core::TrackletPtr>& tracks);
  74. };
  75. }
  76. #endif //GBMOT_BERCLAZ_H