NStage.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // Created by wrede on 25.04.16.
  3. //
  4. #ifndef GBMOT_NSTAGE_H
  5. #define GBMOT_NSTAGE_H
  6. #include "../core/DetectionSequence.h"
  7. #include "../core/Tracklet.h"
  8. #include "../graph/Definitions.h"
  9. namespace algo
  10. {
  11. /**
  12. * Implementation of the two-staged graph-based multi-object tracker.
  13. * Extended to allow N stages.
  14. */
  15. class NStage
  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. std::vector<double> penalty_values_;
  26. /**
  27. * Maximum dijkstra iterations / number of tracklets to create
  28. */
  29. std::vector<size_t> max_tracklet_counts_;
  30. /**
  31. * Number of iterations
  32. */
  33. size_t iterations_;
  34. /**
  35. * Creates a graph with vertices for every detected object
  36. * @param graph The graph to write into
  37. * @param detections The objects to use for the graph
  38. */
  39. void CreateObjectGraph(DirectedGraph& graph,
  40. const core::DetectionSequence& detections);
  41. /**
  42. * Reduces the object graph into linked tracklets.
  43. * @param obj_graph The object graph to reduce
  44. * @param tlt_graph The graph to write the tracklets in
  45. * @param frame_count The frame count of the object graph
  46. * @param iteration The current iteration
  47. */
  48. void CreateTrackletGraph(DirectedGraph& obj_graph,
  49. DirectedGraph& tlt_graph,
  50. size_t frame_count,
  51. size_t iteration);
  52. /**
  53. * Extracts the finished tracks from the given tracklet graph.
  54. * @param tlt_graph The tracklet graph to extract from
  55. * @param depth The depth to flatten the tracklets to
  56. * @param tracks The vector to write the extracted tracks in
  57. */
  58. void ExtractTracks(DirectedGraph& tlt_graph,
  59. size_t depth,
  60. std::vector<core::TrackletPtr>& tracks);
  61. public:
  62. /**
  63. * Initializes the algorithm wih the given values.
  64. * The number of stages is determined by the size of the given
  65. * vectors.
  66. * @param max_frame_skip The maximum edge length to link objects
  67. * @param penalty_value The edge value to link to source and sink
  68. * @param max_tracklet_count The maximum number of tracklets to create
  69. */
  70. NStage(size_t max_frame_skip, std::vector<double> penalty_value,
  71. std::vector<size_t> max_tracklet_count);
  72. void Run(const core::DetectionSequence& sequence,
  73. std::vector<core::TrackletPtr>& tracks);
  74. };
  75. }
  76. #endif //GBMOT_NSTAGE_H