MTF
CompositeBase.h
1 #ifndef MTF_COMPOSITE_BASE_H
2 #define MTF_COMPOSITE_BASE_H
3 
4 #include "mtf/TrackerBase.h"
5 #include "mtf/Macros/common.h"
6 
7 _MTF_BEGIN_NAMESPACE
8 
9 // base class for all composite trackers
10 class CompositeBase : public TrackerBase{
11 public:
12  const vector<TrackerBase*> trackers;
13  int n_trackers;
14  int input_type;
15  CompositeBase() : TrackerBase(), n_trackers(0), input_type(0){}
16  CompositeBase(const vector<TrackerBase*> _trackers):
17  TrackerBase(), trackers(_trackers) {
18  n_trackers = trackers.size();
19  input_type = trackers[0]->inputType();
20  for(int tracker_id = 1; tracker_id < n_trackers; tracker_id++){
21  if(input_type != trackers[tracker_id]->inputType()){
22  input_type = HETEROGENEOUS_INPUT;
23  }
24  break;
25  }
26  }
27  virtual ~CompositeBase(){}
28  void setImage(const cv::Mat &img) override{
29  for(int tracker_id = 0; tracker_id < n_trackers; ++tracker_id){
30  if(inputType() != HETEROGENEOUS_INPUT ||
31  img.type() == trackers[tracker_id]->inputType()){
32  trackers[tracker_id]->setImage(img);
33  }
34  }
35  }
36  int inputType() const override{ return input_type; }
37 };
38 _MTF_END_NAMESPACE
39 
40 #endif
Definition: CompositeBase.h:10