Berclaz.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. /**
  13. * Algorithm for tracking multiple object in a frame sequence.
  14. * The algorithm needs the location of detections.
  15. */
  16. class Berclaz
  17. {
  18. private:
  19. const double VIRTUAL_EDGE_WEIGHT = 0.0;
  20. const double MAX_SCORE_VALUE = 0.999999;
  21. const double MIN_SCORE_VALUE = 0.000001;
  22. /**
  23. * Horizontal grid resolution
  24. */
  25. int h_res_;
  26. /**
  27. * Vertical grid resolution
  28. */
  29. int v_res_;
  30. /**
  31. * The number of cells a detection can move within one frame
  32. */
  33. int vicinity_size_;
  34. /**
  35. * Creates a graph from the given sequence.
  36. *
  37. * @param graph The graph to write into
  38. * @param source A reference to the source vertex
  39. * @param sink A reference to the sink vertex
  40. * @param grid The detection values as a grid
  41. */
  42. void CreateGraph(DirectedGraph& graph, Vertex& source, Vertex& sink,
  43. util::Grid& grid);
  44. /**
  45. * Extracts the final tracks from the given graph and predecessor map.
  46. *
  47. * @param graph The graph to read the values from
  48. * @param map The predecessor map to read the paths from
  49. * @param origin The vertex to start the reverse path traversal from
  50. * @param tracks The vector to fill with the extracted tracks
  51. */
  52. void ExtractTracks(DirectedGraph& graph,
  53. MultiPredecessorMap& map, Vertex origin,
  54. std::vector<core::TrackletPtr> & tracks);
  55. //TODO comment
  56. void ConnectTracks(std::vector<core::TrackletPtr> & tracks);
  57. public:
  58. /**
  59. * Instantiate with the given parameters.
  60. *
  61. * @param h_res The horizontal grid resolution
  62. * @param v_res The vertical grid resolution
  63. * @param vicinity_size The maximum number of cells a detection can skip
  64. * within one frame
  65. */
  66. Berclaz(int h_res, int v_res, int vicinity_size);
  67. /**
  68. * Runs the algorithm on the given sequence. Splits the sequence into
  69. * batches to allow faster processing.
  70. *
  71. * @param sequence The detection to use
  72. * @param batch_size The number of frames one batch will have at maximum
  73. * @param max_track_count The maximum number of tracks to extract
  74. * @param tracks The vector to store the found tracks into
  75. * @param filter The filter used to convolve the detections in the grid
  76. */
  77. void Run(core::DetectionSequence & sequence, size_t batch_size,
  78. size_t max_track_count, std::vector<core::TrackletPtr> & tracks,
  79. util::Filter2D & filter);
  80. };
  81. }
  82. #endif //GBMOT_BERCLAZ_H