TwoStage.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // Created by wrede on 25.04.16.
  3. //
  4. #ifndef GBMOT_KOERNERTRACKING_H
  5. #define GBMOT_KOERNERTRACKING_H
  6. #include "Definitions.h"
  7. #include "../core/DetectionSequence.h"
  8. #include "../core/Tracklet.h"
  9. #include <boost/graph/dijkstra_shortest_paths.hpp>
  10. namespace algo
  11. {
  12. /**
  13. * Implementation if the two-staged graph-based multi-object tracker.
  14. */
  15. class TwoStage
  16. {
  17. private:
  18. /**
  19. * Maximum edge length to link object
  20. */
  21. size_t max_frame_skip_;
  22. /**
  23. * Edge value to link to source and sink
  24. */
  25. double penalty_value_;
  26. /*
  27. * Maximum dijkstra iterations / number of tracklets to create
  28. */
  29. size_t max_tracklet_count_;
  30. /*
  31. * The last created object graph
  32. */
  33. DirectedGraph obj_graph_;
  34. /*
  35. * The last created tracklet graph
  36. */
  37. DirectedGraph tlt_graph_;
  38. /**
  39. * The frame count of the last read sequence
  40. */
  41. size_t frame_count_;
  42. public:
  43. /**
  44. * Initializes the algorithm wih the given values.
  45. * @param max_frame_skip The maximum edge length to link objects
  46. * @param penalty_value The Edge value to link to source and sink
  47. * @param max_tracklet_count The maximum number of tracklets to create
  48. */
  49. TwoStage(size_t max_frame_skip, double penalty_value,
  50. size_t max_tracklet_count);
  51. /**
  52. * Creates a graph with vertices for every detected object
  53. * @param detections The objects to use for the graph
  54. * @return The created graph containing the object data
  55. */
  56. DirectedGraph CreateObjectGraph(core::DetectionSequence detections);
  57. /**
  58. * Reduces the object graph into linked tracklets.
  59. * The last created graph is used, as well as his frame count.
  60. *
  61. */
  62. DirectedGraph CreateTrackletGraph();
  63. /**
  64. * Reduces the object graph into linked tracklets.
  65. * @param obj_graph The object graph to reduce
  66. * @param frame_count The frame count of the object graph
  67. * @return The created graph containing the tracklet data
  68. */
  69. DirectedGraph CreateTrackletGraph(DirectedGraph obj_graph, size_t frame_count);
  70. /**
  71. * Extracts the finished tracks from the last created tracklet graph.
  72. * @return The vector of finished object tracks
  73. */
  74. std::vector<core::Tracklet> ExtractTracks();
  75. /**
  76. * Extracts the finished tracks from the given tracklet graph.
  77. * @param tlt_graph The tracklet graph to extract from
  78. * @return The vector of finished object tracks
  79. */
  80. std::vector<core::Tracklet> ExtractTracks(DirectedGraph tlt_graph);
  81. };
  82. }
  83. #endif //GBMOT_KOERNERTRACKING_H