4 #include "AppearanceModel.h" 19 typedef bool is_kdtree_distance;
20 typedef double ElementType;
21 typedef double ResultType;
22 NCCDist(
const string &_name,
const unsigned int _patch_size) :
23 AMDist(_name), patch_size(_patch_size){}
24 double operator()(
const double* a,
const double* b,
25 size_t size,
double worst_dist = -1)
const override;
26 double accum_dist(
const double& a,
const double& b,
int)
const{
return -a*b; }
28 const unsigned int patch_size;
37 NCC(
const ParamType *ncc_params =
nullptr,
const int _n_channels = 1);
39 double getLikelihood()
const override;
41 void initializeSimilarity()
override;
42 void initializeGrad()
override;
46 void updateSimilarity(
bool prereq_only =
true)
override;
47 void updateInitGrad()
override;
49 void updateCurrGrad()
override;
51 void cmptInitJacobian(RowVectorXd &df_dp,
const MatrixXd &dI0_dp)
override;
52 void cmptCurrJacobian(RowVectorXd &df_dp,
const MatrixXd &dIt_dp)
override;
53 void cmptDifferenceOfJacobians(RowVectorXd &df_dp_diff,
54 const MatrixXd &dI0_dpssm,
const MatrixXd &dIt_dpssm)
override;
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;
60 void cmptCurrHessian(MatrixXd &curr_hessian,
const MatrixXd &curr_pix_jacobian)
override;
61 void cmptCurrHessian(MatrixXd &curr_hessian,
const MatrixXd &curr_pix_jacobian,
62 const MatrixXd &curr_pix_hessian)
override;
64 void cmptSelfHessian(MatrixXd &self_hessian,
const MatrixXd &curr_pix_jacobian)
override;
65 void cmptSelfHessian(MatrixXd &self_hessian,
const MatrixXd &curr_pix_jacobian,
66 const MatrixXd &curr_pix_hessian)
override{
67 cmptSelfHessian(self_hessian, curr_pix_jacobian);
70 void estimateOpticalFlow(std::vector<cv::Point2f> &curr_pts,
71 const cv::Mat &prev_img,
const std::vector<cv::Point2f> &prev_pts,
72 const cv::Size &win_size,
unsigned int n_pts,
int max_iters,
73 double term_eps,
bool const_grad=
true)
const override;
74 void updateModel(
const Matrix2Xd& curr_pts)
override;
77 VectorXd curr_feat_vec;
78 const DistType* getDistFunc()
override{
79 return new DistType(name, patch_size);
81 void updateDistFeat(
double* feat_addr)
override;
83 updateDistFeat(curr_feat_vec.data());
87 curr_feat_vec.resize(getDistFeatSize());
89 const double* getDistFeat()
override{
return curr_feat_vec.data(); }
99 double I0_mean, It_mean;
103 VectorXd I0_cntr, It_cntr;
104 VectorXd I0_cntr_c, It_cntr_b;
105 VectorXd df_dI0_ncntr, df_dIt_ncntr;
106 double df_dI0_ncntr_mean, df_dIt_ncntr_mean;
107 bool use_running_avg;
Normalized Cross Correlation.
Definition: NCC.h:32
void initializeDistFeat() override
to be called once during initialization if any of the distance feature functionality is to be used ...
Definition: NCC.h:86
void updateDistFeat() override
computes a "distance" vector using the current image patch such that, when the distance vectors corre...
Definition: NCC.h:82
bool supportsSPI() const override
should be overridden by an implementing class once it implements SPI functionality for all functions ...
Definition: NCC.h:92
void initializeHess() override
even though the Hessian of the error norm w.r.t.
Definition: NCC.h:43
Definition: AMParams.h:12
NCCParams(const AMParams *am_params, bool _fast_hess)
value constructor
Distance functor for FLANN.
Definition: AppearanceModel.h:40
unsigned int getDistFeatSize() override
returns the size of the distance vector
Definition: NCC.h:85
Similarity function that indicates how well a candidate warped patch matches the template.
Definition: AppearanceModel.h:63