MTF
RIU.h
1 #ifndef MTF_RIU_H
2 #define MTF_RIU_H
3 
4 #include "AppearanceModel.h"
5 
6 _MTF_BEGIN_NAMESPACE
7 
8 struct RIUParams : AMParams{
9 
12  bool debug_mode;
14  RIUParams(const AMParams *am_params,
15  bool _debug_mode);
17  RIUParams(const RIUParams *params = nullptr);
18 };
19 
20 struct RIUDist : AMDist{
21  typedef double ElementType;
22  typedef double ResultType;
23  RIUDist(const string &_name, const bool _dist_from_likelihood,
24  const double _likelihood_alpha, const unsigned int _patch_size);
25  double operator()(const double* a, const double* b,
26  size_t size, double worst_dist = -1) const override;
27 private:
28  const bool dist_from_likelihood;
29  const double likelihood_alpha;
30  const unsigned int patch_size;
31 };
32 
34 class RIU : public AppearanceModel{
35 public:
36  typedef RIUParams ParamType;
37  typedef RIUDist DistType;
38 
39  RIU(const ParamType *riu_params = nullptr, const int _n_channels = 1);
40 
41  double getLikelihood() const override;
42 
43  bool isSymmetrical() const override{ return false; }
44 
45  //-------------------------------initialize functions------------------------------------//
46  void initializeSimilarity() override;
47  void initializeGrad() override;
48  void initializeHess() override{}
49 
50  //-------------------------------update functions------------------------------------//
51  void updateSimilarity(bool prereq_only = true) override;
52  void updateInitGrad() override;
53  void updateCurrGrad() override;
54 
55  //-------------------------------interfacing functions------------------------------------//
56  void cmptInitHessian(MatrixXd &init_hessian, const MatrixXd &init_pix_jacobian) override;
57  void cmptInitHessian(MatrixXd &init_hessian, const MatrixXd &init_pix_jacobian,
58  const MatrixXd &init_pix_hessian) override;
59  void cmptCurrHessian(MatrixXd &curr_hessian, const MatrixXd &curr_pix_jacobian) override;
60  void cmptCurrHessian(MatrixXd &curr_hessian, const MatrixXd &curr_pix_jacobian,
61  const MatrixXd &curr_pix_hessian) override;
62  void cmptSelfHessian(MatrixXd &self_hessian, const MatrixXd &curr_pix_jacobian) override;
63  void cmptSelfHessian(MatrixXd &self_hessian, const MatrixXd &curr_pix_jacobian,
64  const MatrixXd &curr_pix_hessian) override;
65 
66  // -------------------- distance feature functions -------------------- //
67  VectorXd curr_feat_vec;
68  const DistType* getDistFunc() override{
69  return new DistType(name, params.dist_from_likelihood,
70  params.likelihood_alpha, patch_size);
71  }
72  unsigned int getDistFeatSize() override{ return patch_size + 1; }
73  void initializeDistFeat() override{
74  curr_feat_vec.resize(patch_size + 1);
75  }
76  void updateDistFeat(double* feat_addr) override;
77  const double* getDistFeat() override{ return curr_feat_vec.data(); }
78  void updateDistFeat() override{
79  updateDistFeat(curr_feat_vec.data());
80  curr_feat_vec[0] = 1;
81  }
82 
83 protected:
84  ParamType params;
85 
86  double N_inv;
87  VectorXd r;
88  VectorXd r_cntr;
89  VectorXd df_dr;
90  VectorXd dr_dIt, dr_dI0;
91  double r_mean, r_var;
92  double r_mean_inv;
93 };
94 
95 _MTF_END_NAMESPACE
96 
97 #endif
Definition: RIU.h:8
bool dist_from_likelihood
use negative of likelihood as the distance measure
Definition: AMParams.h:17
void updateDistFeat() override
computes a "distance" vector using the current image patch such that, when the distance vectors corre...
Definition: RIU.h:78
double likelihood_alpha
multiplicative and additive factors for the exponent in the likelihood
Definition: AMParams.h:15
Definition: RIU.h:20
bool isSymmetrical() const override
return false if the similarity function f is not symmetrical, i.e.
Definition: RIU.h:43
Definition: AMParams.h:12
bool debug_mode
decides whether logging data will be printed for debugging purposes; only matters if logging is enabl...
Definition: RIU.h:12
Ratio Image Uniformity.
Definition: RIU.h:34
Distance functor for FLANN.
Definition: AppearanceModel.h:40
unsigned int getDistFeatSize() override
returns the size of the distance vector
Definition: RIU.h:72
RIUParams(const AMParams *am_params, bool _debug_mode)
value constructor
Similarity function that indicates how well a candidate warped patch matches the template.
Definition: AppearanceModel.h:63
void initializeHess() override
even though the Hessian of the error norm w.r.t.
Definition: RIU.h:48
void initializeDistFeat() override
to be called once during initialization if any of the distance feature functionality is to be used ...
Definition: RIU.h:73