MTF
CompositeSM.h
1 #ifndef MTF_COMPOSITE_SM_H
2 #define MTF_COMPOSITE_SM_H
3 
4 #include "SearchMethod.h"
5 #include "mtf/Macros/common.h"
6 
7 _MTF_BEGIN_NAMESPACE
8 
10 template<class AM, class SSM>
11 class CompositeSM : public TrackerBase{
12 public:
13  typedef SearchMethod<AM, SSM> SM;
14 
15  CompositeSM() : TrackerBase(), n_trackers(0), input_type(0){}
16  CompositeSM(const vector<SM*> _trackers) :
17  TrackerBase(), trackers(_trackers) {
18  n_trackers = trackers.size();
20  input_type = trackers[0]->inputType();
21  }
22  virtual ~CompositeSM(){}
23  void setImage(const cv::Mat &img) override{
24  for(int tracker_id = 0; tracker_id < n_trackers; ++tracker_id){
25  if(inputType() != HETEROGENEOUS_INPUT ||
26  img.type() == trackers[tracker_id]->inputType()){
27  trackers[tracker_id]->setImage(img);
28  }
29  }
30  }
31 
32  int inputType() const override{ return input_type; }
33 
34  void setRegion(const cv::Mat& corners) override {
35  for(int tracker_id = 1; tracker_id < n_trackers; ++tracker_id) {
36  trackers[tracker_id]->setRegion(corners);
37  }
38  }
39  virtual void setSPIMask(const bool *_spi_mask) {
40  for(int tracker_id = 0; tracker_id < n_trackers; ++tracker_id){
41  trackers[tracker_id]->setSPIMask(_spi_mask);
42  }
43  }
44  virtual void clearSPIMask() {
45  for(int tracker_id = 0; tracker_id < n_trackers; ++tracker_id){
46  trackers[tracker_id]->clearSPIMask();
47  }
48  }
49  virtual void setInitStatus() {
50  for(int tracker_id = 0; tracker_id < n_trackers; ++tracker_id){
51  trackers[tracker_id]->setInitStatus();
52  }
53  }
54  virtual void clearInitStatus() {
55  for(int tracker_id = 0; tracker_id < n_trackers; ++tracker_id){
56  trackers[tracker_id]->clearInitStatus();
57  }
58  }
59  virtual bool supportsSPI() {
60  for(int tracker_id = 0; tracker_id < n_trackers; ++tracker_id){
61  if(!trackers[tracker_id]->supportsSPI())
62  return false;
63  }
64  return true;
65  }
66 
67  virtual AM& getAM() { return trackers.back()->getAM(); }
68  virtual SSM& getSSM() { return trackers.back()->getSSM(); }
69 
70  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
71 
72 protected:
73  const vector<SM*> trackers;
74  int n_trackers;
75  int input_type;
76 
77 };
78 _MTF_END_NAMESPACE
79 
80 #endif
base class for all composite search methods
Definition: CompositeSM.h:11
Definition: SearchMethod.h:10
CompositeSM(const vector< SM * > _trackers)
Definition: CompositeSM.h:16