MTF
PCA.h
1 #ifndef MTF_PCA_H
2 #define MTF_PCA_H
3 
4 #include "SSDBase.h"
5 
6 _MTF_BEGIN_NAMESPACE
7 
8 struct PCAParams : AMParams{
14  double f_factor;
16  bool show_basis;
18  PCAParams(const AMParams *am_params,
19  int _n_eigenvec,
20  int _batch_size,
21  double _f_factor,
22  bool _show_basis);
24  PCAParams(const PCAParams *params = nullptr);
25 };
26 
27 class PCA : public SSDBase{
28 public:
29 
30  typedef PCAParams ParamType;
31 
32  PCA(const ParamType *pca_params = nullptr, const int _n_channels = 1);
33 
34  // Returns a normalized version of the similarity that lies between 0 and 1
35  double getLikelihood() const override;
36 
37  // Initialize the features
38  void initializeSimilarity() override;
39 
40  // Update the similarity
41  void updateSimilarity(bool prereq_only = true) override;
42  void updateModel(const Matrix2Xd& curr_pts) override;
43 
44  // Defined in Appearance Model,
45  // It is called before performing the first iteration on a new image
46  // to indicate that the image has changed since the last time the
47  // update functions were called
48  void setFirstIter() override;
49 
50  // It is called after performing the last iteration on a new image
51  void clearFirstIter() override;
52 
53 protected:
54 
55  ParamType params;
56 
57  // *****************************
59  MatrixXd addi_patches;
67  unsigned int batch_size;
68 
70  MatrixXd U;
72  VectorXd sigma;
75 
76  int cv_img_type_uchar, cv_img_type_float;
77 
78  // update the basis U and eigen values sigma
79  void updateBasis();
80 
81  // One step of incremental PCA
82  void incrementalPCA();
83 
84  // the core algorithm in ivt tracker:
85  // sklm(Sequential Karhunen-Loeve Transform with Mean update)
86  void sklm(MatrixXd &U, VectorXd &sigma, VectorXd &mu_A,
87  MatrixXd &B, int &n, double ff, int max_n_eig);
88 
89  // display the basis and the reconstructed image
90  void display_images(const VectorXd &curr_image,
91  const VectorXdM &error_image);
92  void display_basis();
93 
94 };
95 
96 _MTF_END_NAMESPACE
97 
98 #endif
int batch_size
batch size for the eigen basis update
Definition: PCA.h:12
bool show_basis
show all patches in the eigen basis
Definition: PCA.h:16
Definition: SSDBase.h:45
bool U_available
flag to indicate whether the basis U is available
Definition: PCA.h:74
Definition: PCA.h:27
VectorXd sigma
Sigma.
Definition: PCA.h:72
Definition: AMParams.h:12
MatrixXd addi_patches
additional patches B, d x m
Definition: PCA.h:59
int n_prev_patches
number of prev patches, n
Definition: PCA.h:65
double f_factor
forgetting factor
Definition: PCA.h:14
PCAParams(const AMParams *am_params, int _n_eigenvec, int _batch_size, double _f_factor, bool _show_basis)
value constructor
MatrixXd U
eigen basis U, initialized to be empty
Definition: PCA.h:70
int n_eigenvec
The number of eigen basis.
Definition: PCA.h:10
unsigned int batch_size
number of additional patches, m. constant in this case
Definition: PCA.h:67
Definition: PCA.h:8
VectorXd max_patch_eachframe
the patch in max similarity of particle each frame
Definition: PCA.h:63
VectorXd mean_prev_patches
mean of prev patches, miu_A
Definition: PCA.h:61