MTF
LRSCV.h
1 #ifndef MTF_LRSCV_H
2 #define MTF_LRSCV_H
3 
4 #include "SSDBase.h"
5 
6 #define LRSCV_N_BINS 256
7 #define LRSCV_PRE_SEED 0
8 #define LRSCV_WEIGHTED_MAPPING 0
9 #define LRSCV_DEBUG_MODE 0
10 #define LRSCV_SUB_REGIONS 3
11 #define LRSCV_SPACING 10
12 #define LRSCV_AFFINE_MAPPING 0
13 #define LRSCV_ONCE_PER_FRAME 0
14 #define LRSCV_SHOW_SUBREGIONS 0
15 
16 _MTF_BEGIN_NAMESPACE
17 
19 
21  int sub_regions_x, sub_regions_y;
23  int spacing_x, spacing_y;
24  // use affine or linear mapping instead of the standard one
25  bool affine_mapping;
26  // update the template only once per frame, i.e. when new_frame is set to true
27  bool once_per_frame;
28 
30  int n_bins;
33  double pre_seed;
34 
39 
40  // show the locations of the subregions
41  bool show_subregions;
42 
45  bool debug_mode;
46 
48  LRSCVParams(const AMParams *am_params,
49  int _sub_regions_x, int _sub_regions_y,
50  int _spacing_x, int _spacing_y,
51  bool _affine_mapping, bool _once_per_frame,
52  int _n_bins, double _pre_seed, bool _weighted_mapping,
53  bool _show_subregions, bool _debug_mode);
55  LRSCVParams(const LRSCVParams *params = nullptr);
56 };
57 
59 class LRSCV : public SSDBase{
60 
61 public:
62 
63  typedef LRSCVParams ParamType;
64 
65  LRSCV(const ParamType *lrscv_params = nullptr);
66  void initializePixVals(const Matrix2Xd& init_pts) override;
67  void updatePixVals(const Matrix2Xd& curr_pts) override;
68 
69 private:
70 
71  ParamType params;
72 
73  int mapping_type;
74  double hist_pre_seed;
75  int patch_size_x, patch_size_y;
76  int sub_region_size_x, sub_region_size_y;
77  int n_sub_regions;
78 
79  VectorXd intensity_map;
80 
83  MatrixXd curr_joint_hist;
84  VectorXd init_hist, curr_hist;
85 
86  ColPivHouseholderQR<MatrixX2d> intensity_vals_dec;
87  MatrixXdMr init_patch, curr_patch;
88  MatrixX2i sub_region_x, sub_region_y;
89  MatrixX2d sub_region_centers;
90  vector<VectorXd> mapped_pix_vals;
91  MatrixX2d intensity_vals;
92  Vector2d affine_params;
93  MatrixXd sub_region_wts;
94 
96  MatrixX2i _std_bspl_ids, _init_bspl_ids, _curr_bspl_ids;
97  EigImgMat _init_img;
99  MatrixXi _subregion_idx;
101  MatrixXi _pts_idx;
102 
103  cv::Mat patch_img, patch_img_uchar;
104 
105  char *patch_win_name;
106  int sub_region_id;
107  char *log_fname;
108 
109  void showSubRegions(const EigImgT& img, const Matrix2Xd& pts);
110  void updateIntensityMap();
111  void updateMappedPixVals(int index);
112 };
113 
114 _MTF_END_NAMESPACE
115 
116 #endif
Definition: SSDBase.h:45
Locally adaptive Reversed Sum of Conditional Variance.
Definition: LRSCV.h:59
int n_bins
no. of bins in the histograms
Definition: LRSCV.h:30
Definition: AMParams.h:12
LRSCVParams(const AMParams *am_params, int _sub_regions_x, int _sub_regions_y, int _spacing_x, int _spacing_y, bool _affine_mapping, bool _once_per_frame, int _n_bins, double _pre_seed, bool _weighted_mapping, bool _show_subregions, bool _debug_mode)
value constructor
bool weighted_mapping
enable this to map each intensity to the weighted average of the two entries of the intensity map cor...
Definition: LRSCV.h:38
int spacing_x
spacing in pixels between adjacent sub regions
Definition: LRSCV.h:23
double pre_seed
initial value with which each bin of the joint histogram is pre-seeded to avoid numerical instabiliti...
Definition: LRSCV.h:33
bool debug_mode
decides whether logging data will be printed for debugging purposes; only matters if logging option i...
Definition: LRSCV.h:45
Definition: LRSCV.h:18
int sub_regions_x
no. of sub regions in horizontal and vertical directions
Definition: LRSCV.h:21