4 #include "AppearanceModel.h" 6 #include <boost/random/linear_congruential.hpp> 7 #include <boost/random/normal_distribution.hpp> 17 typedef bool is_kdtree_distance;
18 typedef double ElementType;
19 typedef double ResultType;
33 double operator()(
const double* a,
const double* b,
34 size_t size,
double worst_dist = -1)
const override;
41 double accum_dist(
const double& a,
const double& b,
int)
const{
42 return (a - b)*(a - b);
49 typedef IlluminationModel::PixHessType ILMPixHessT;
52 const int _n_channels = 1);
54 void initializeSimilarity()
override;
55 void initializeGrad()
override;
58 d2f_dpam2.resize(state_size, state_size);
59 d2f_dpam_dIt.resize(state_size, patch_size);
70 ilm->cmptPixJacobian(df_dI0.data(), df_dg0.data(), I0.data(), p_am.data());
73 double getLikelihood()
const override;
77 void updateSimilarity(
bool prereq_only =
true)
override;
78 void updateState(
const VectorXd& state_update)
override;
79 void invertState(VectorXd& inv_p,
const VectorXd& p)
override;
80 void updateCurrGrad()
override;
81 void cmptInitJacobian(RowVectorXd &df_dp,
82 const MatrixXd &dI0_dpssm)
override;
83 void cmptCurrJacobian(RowVectorXd &df_dp,
84 const MatrixXd &dIt_dpssm)
override;
85 void cmptDifferenceOfJacobians(RowVectorXd &diff_of_jacobians,
86 const MatrixXd &dI0_dpssm,
const MatrixXd &dIt_dpssm)
override;
87 void cmptInitHessian(MatrixXd &init_hessian,
88 const MatrixXd &init_pix_jacobian)
override;
89 void cmptCurrHessian(MatrixXd &curr_hessian,
90 const MatrixXd &curr_pix_jacobian)
override;
91 void cmptSelfHessian(MatrixXd &self_hessian,
92 const MatrixXd &curr_pix_jacobian)
override{
93 cmptCurrHessian(self_hessian, curr_pix_jacobian);
95 void cmptSelfHessian(MatrixXd &self_hessian,
const MatrixXd &curr_pix_jacobian,
96 const MatrixXd &curr_pix_hessian)
override{
97 cmptSelfHessian(self_hessian, curr_pix_jacobian);
99 void cmptSumOfHessians(MatrixXd &sum_of_hessians,
100 const MatrixXd &init_pix_jacobian,
101 const MatrixXd &curr_pix_jacobian)
override;
102 void cmptInitHessian(MatrixXd &init_hessian,
const MatrixXd &init_pix_jacobian,
103 const MatrixXd &init_pix_hessian)
override;
104 void cmptCurrHessian(MatrixXd &curr_hessian,
const MatrixXd &curr_pix_jacobian,
105 const MatrixXd &curr_pix_hessian)
override;
106 void cmptSumOfHessians(MatrixXd &sum_of_hessians,
107 const MatrixXd &init_pix_jacobian,
const MatrixXd &curr_pix_jacobian,
108 const MatrixXd &init_pix_hessian,
const MatrixXd &curr_pix_hessian)
override;
114 return new DistType(name);
117 unsigned int feat_size = getDistFeatSize();
118 for(
size_t pix = 0; pix < feat_size; ++pix) {
119 *feat_addr++ = It(pix);
124 const double* getDistFeat()
override{
return getCurrPixVals().data(); }
131 typedef boost::minstd_rand SampleGenT;
132 typedef boost::normal_distribution<double> SampleDistT;
133 typedef SampleDistT::param_type DistParamT;
135 std::vector<SampleGenT> rand_gen;
136 std::vector<SampleDistT> rand_dist;
137 VectorXd state_perturbation;
139 void initializeSampler(
const VectorXd &state_sigma,
140 const VectorXd &state_mean)
override;
141 void setSampler(
const VectorXd &state_sigma,
142 const VectorXd &state_mean)
override;
143 void setSamplerMean(
const VectorXd &mean)
override;
144 void setSamplerSigma(
const VectorXd &
std)
override;
145 void getSamplerMean(VectorXd &mean)
override;
146 void getSamplerSigma(VectorXd &std)
override;
147 void generatePerturbation(VectorXd &perturbation)
override;
167 ILMPixHessT ilm_d2f_dIt_type;
169 void cmptILMHessian(MatrixXd &d2f_dp2,
const MatrixXd &dI_dpssm,
170 const double* I,
const double* df_dg =
nullptr);
172 virtual void getJacobian(RowVectorXd &jacobian,
const bool *pix_mask,
173 const RowVectorXd &curr_grad,
const MatrixXd &pix_jacobian);
174 virtual void getHessian(MatrixXd &hessian,
const bool *pix_mask,
const MatrixXd &pix_jacobian);
175 virtual void getDifferenceOfJacobians(RowVectorXd &diff_of_jacobians,
const bool *pix_mask,
176 const MatrixXd &init_pix_jacobian,
const MatrixXd &curr_pix_jacobian);
177 virtual void getSumOfHessians(MatrixXd &sum_of_hessians,
const bool *pix_mask,
178 const MatrixXd &init_pix_jacobian,
const MatrixXd &curr_pix_jacobian);
double likelihood_alpha
multiplicative factor for the exponent in the likelihood
Definition: SSDBase.h:163
double operator()(const double *a, const double *b, size_t size, double worst_dist=-1) const override
Squared Euclidean distance functor, optimized version.
bool supportsSPI() const override
should be overridden by an implementing class once it implements SPI functionality for all functions ...
Definition: SSDBase.h:150
void initializeDistFeat() override
to be called once during initialization if any of the distance feature functionality is to be used ...
Definition: SSDBase.h:122
const DistType * getDistFunc() override
Support for FLANN library.
Definition: SSDBase.h:113
void initializeHess() override
even though the Hessian of the error norm w.r.t.
Definition: SSDBase.h:56
AMParams::ILM ilm
optional pointer to an illumination model if such a one is to be used as a photometric function ...
Definition: SSDBase.h:158
void updateInitGrad() override
nothing is done here since init_grad is same as and shares memory with curr_pix_diff that is updated ...
Definition: SSDBase.h:67
Definition: AMParams.h:12
base class for appearance models that use the negative sum of squared differences ("SSD") or L2 norm ...
Definition: SSDBase.h:16
int getStateSize() const override
accessor methods
Definition: SSDBase.h:53
Distance functor for FLANN.
Definition: AppearanceModel.h:40
void updateDistFeat(double *feat_addr) override
overloaded version to write the distance feature directly to a row (or column) of a matrix storing th...
Definition: SSDBase.h:116
double accum_dist(const double &a, const double &b, int) const
Partial euclidean distance, using just one dimension.
Definition: SSDBase.h:41
void updateDistFeat() override
computes a "distance" vector using the current image patch such that, when the distance vectors corre...
Definition: SSDBase.h:123
unsigned int getDistFeatSize() override
returns the size of the distance vector
Definition: SSDBase.h:125
Similarity function that indicates how well a candidate warped patch matches the template.
Definition: AppearanceModel.h:63