MTF
IALK2.h
1 #ifndef MTF_IALK2_H
2 #define MTF_IALK2_H
3 
4 #include "SearchMethod.h"
5 
6 #define IALK2_MAX_ITERS 10
7 #define IALK2_EPSILON 0.01
8 #define IALK2_HESS_TYPE 0
9 #define IALK2_SEC_ORD_HESS false
10 #define IALK2_DEBUG_MODE false
11 
12 _MTF_BEGIN_NAMESPACE
13 
14 struct IALK2Params{
15  enum class HessType{ InitialSelf, CurrentSelf, Std };
16 
17  int max_iters;
18  double epsilon;
19  HessType hess_type;
20  bool sec_ord_hess;
21  bool debug_mode;
22 
24  IALK2Params(int _max_iters, double _epsilon,
25  HessType _hess_type, bool _sec_ord_hess,
26  bool _debug_mode
27  ){
28  max_iters = _max_iters;
29  epsilon = _epsilon;
30  hess_type = _hess_type;
31  sec_ord_hess = _sec_ord_hess;
32  debug_mode = _debug_mode;
33  }
34  IALK2Params(IALK2Params *params = nullptr) :
35  max_iters(IALK2_MAX_ITERS),
36  epsilon(IALK2_EPSILON),
37  hess_type(static_cast<HessType>(IALK2_HESS_TYPE)),
38  sec_ord_hess(IALK2_SEC_ORD_HESS),
39  debug_mode(IALK2_DEBUG_MODE){
40  if(params){
41  max_iters = params->max_iters;
42  epsilon = params->epsilon;
43  hess_type = params->hess_type;
44  sec_ord_hess = params->sec_ord_hess;
45  debug_mode = params->debug_mode;
46  }
47  }
48 };
49 
50 template<class AM, class SSM>
51 class IALK2 : public SearchMethod < AM, SSM > {
52 
53 public:
54  typedef IALK2Params ParamType;
55  typedef typename ParamType::HessType HessType;
56 
57  using SearchMethod<AM, SSM> ::am;
58  using SearchMethod<AM, SSM> ::ssm;
59  using typename SearchMethod<AM, SSM> ::AMParams;
60  using typename SearchMethod<AM, SSM> ::SSMParams;
61  using SearchMethod<AM, SSM> ::cv_corners_mat;
62  using SearchMethod<AM, SSM> ::name;
63 
64  using SearchMethod<AM, SSM> ::initialize;
65  using SearchMethod<AM, SSM> ::update;
66 
67  IALK2(const ParamType *iclk_params = NULL,
68  const AMParams *am_params = NULL, const SSMParams *ssm_params = NULL);
69 
70  void initialize(const cv::Mat &corners) override;
71  void update() override;
72 
73 private:
74  ParamType params;
75 
76  // Let S = size of SSM state vector and N = resx * resy = no. of pixels in the object patch
78  RowVectorXd jacobian;
80  MatrixXd hessian;
82  MatrixXd init_pix_jacobian, curr_pix_jacobian;
84  MatrixXd init_pix_hessian, curr_pix_hessian;
85 
86  Matrix24d prev_corners;
87  VectorXd ssm_update, inv_update;
88  int frame_id;
89  ClockType start_time, end_time;
90  std::vector<double> proc_times;
91  std::vector<char*> proc_labels;
92  char *log_fname;
93  char *time_fname;
94  void updatePixJacobian();
95  void updatePixHessian();
96 
97 };
98 _MTF_END_NAMESPACE
99 
100 #endif
101 
double epsilon
maximum iterations of the IALK2 algorithm to run for each frame
Definition: IALK2.h:18
Definition: StateSpaceModel.h:35
Definition: IALK2.h:14
HessType hess_type
maximum L1 norm of the state update vector at which to stop the iterations
Definition: IALK2.h:19
Definition: AMParams.h:12
IALK2Params(int _max_iters, double _epsilon, HessType _hess_type, bool _sec_ord_hess, bool _debug_mode)
decides whether logging data will be printed for debugging purposes;
Definition: IALK2.h:24
Definition: SearchMethod.h:10
Definition: IALK2.h:51