MTF
|
Normalized Gradient Fields. More...
#include <NGF.h>
Public Types | |
typedef NGFParams | ParamType |
typedef NGFDist | DistType |
typedef SparseMatrix< double > | SpMat |
typedef Triplet< double > | SpTr |
![]() | |
enum | InputType { MTF_32FC1 = CV_32FC1, MTF_32FC3 = CV_32FC3, MTF_8UC1 = CV_8UC1, MTF_8UC3 = CV_8UC3 } |
supported input image types | |
typedef EigImgT | ImageT |
convenience type if floating point grayscale image is used as input by the AM | |
Public Member Functions | |
NGF (const ParamType *ngf_params=nullptr, const int _n_channels=1) | |
double | getLikelihood () const override |
returns a normalized version of the similarity that lies between 0 and 1 and can be interpreted as the likelihood that the current patch represents the same object as the initial patch | |
void | initializePixVals (const Matrix2Xd &init_pts) override |
initialization methods - to be called once when the tracker is initialized | |
void | initializeSimilarity () override |
methods to initialize the state variables - to be called once when the tracker is initialized. More... | |
void | initializeGrad () override |
void | initializeHess () override |
even though the Hessian of the error norm w.r.t. More... | |
void | updatePixVals (const Matrix2Xd &curr_pts) override |
void | updateSimilarity (bool prereq_only=true) override |
functions for updating state variables when a new image arrives More... | |
void | updateInitGrad () override |
void | updateCurrGrad () override |
void | cmptSelfHessian (MatrixXd &self_hessian, const MatrixXd &curr_pix_jacobian) override |
void | cmptSelfHessian (MatrixXd &self_hessian, const MatrixXd &curr_pix_jacobian, const MatrixXd &curr_pix_hessian) override |
const DistType * | getDistFunc () override |
unsigned int | getDistFeatSize () override |
returns the size of the distance vector | |
void | initializeDistFeat () override |
to be called once during initialization if any of the distance feature functionality is to be used | |
void | updateDistFeat (double *feat_addr) override |
overloaded version to write the distance feature directly to a row (or column) of a matrix storing the distance features corresponding to several patches; | |
const double * | getDistFeat () override |
void | updateDistFeat () override |
computes a "distance" vector using the current image patch such that, when the distance vectors corresponding to two patches are passed to the distance operator above, it uses these to compute a scalar that measures the distance or dissimilarity between the two patches; this distance vector should be designed so as to offload as much computation as possible from the distance operator, i.e. More... | |
![]() | |
AppearanceModel (const AMParams *params=nullptr, const int _n_channels=1) | |
default and value constructor | |
virtual | ~AppearanceModel () |
destructor | |
virtual int | getStateSize () const |
accessor methods | |
virtual double | getSimilarity () const |
virtual const VectorXd & | getState () |
virtual const RowVectorXd & | getInitGrad () const |
virtual const RowVectorXd & | getCurrGrad () const |
virtual void | setSimilarity (double _similarity) |
modifier methods | |
virtual void | setInitGrad (const RowVectorXd &df_dI) |
virtual void | setCurrGrad (const RowVectorXd &df_dI) |
virtual void | reinitialize () |
virtual void | updateState (const VectorXd &state_update) |
virtual void | invertState (VectorXd &inv_p, const VectorXd &p) |
virtual void | updateParamGrad () |
virtual void | cmptInitJacobian (RowVectorXd &df_dp, const MatrixXd &dI0_dpssm) |
–— interfacing functions that take pixel jacobians/Hessians w.r.t. More... | |
virtual void | cmptCurrJacobian (RowVectorXd &df_dp, const MatrixXd &dIt_dpssm) |
virtual void | cmptDifferenceOfJacobians (RowVectorXd &df_dp_diff, const MatrixXd &dI0_dpssm, const MatrixXd &dIt_dpssm) |
multiplies the gradients of the current error norm w.r.t. More... | |
virtual void | cmptInitHessian (MatrixXd &d2f_dp2, const MatrixXd &dI0_dpssm) |
compute the S x S Hessian of the error norm using the supplied N x S Jacobian of pixel values w.r.t. More... | |
virtual void | cmptCurrHessian (MatrixXd &d2f_dp2, const MatrixXd &dIt_dpssm) |
virtual void | cmptInitHessian (MatrixXd &d2f_dp2, const MatrixXd &dI0_dpssm, const MatrixXd &d2I0_dpssm2) |
compute the exact Hessian by considering the second order terms too | |
virtual void | cmptCurrHessian (MatrixXd &d2f_dp2, const MatrixXd &dIt_dpssm, const MatrixXd &d2It_dpssm2) |
virtual void | cmptSumOfHessians (MatrixXd &d2f_dp2_sum, const MatrixXd &dI0_dpssm, const MatrixXd &dIt_dpssm) |
analogous to cmptDifferenceOfJacobians except for computing the mean of the current and initial Hessians | |
virtual void | cmptSumOfHessians (MatrixXd &d2f_dp2_sum, const MatrixXd &dI0_dpssm, const MatrixXd &dIt_dpssm, const MatrixXd &d2I0_dpssm2, const MatrixXd &d2It_dpssm2) |
virtual void | estimateOpticalFlow (std::vector< cv::Point2f > &curr_pts, const cv::Mat &prev_img, const std::vector< cv::Point2f > &prev_pts, const cv::Size &win_size, unsigned int n_pts, int max_iters, double term_eps, bool const_grad=true) const |
virtual void | setSPIMask (const bool *_spi_mask) |
virtual const bool * | getSPIMask () const |
virtual void | clearSPIMask () |
virtual bool | supportsSPI () const |
should be overridden by an implementing class once it implements SPI functionality for all functions where it makes logical sense | |
virtual void | setFirstIter () |
should be called before performing the first iteration on a new image to indicate that the image has changed since the last time the update funcvtions were called | |
virtual void | clearFirstIter () |
should be called after the first iteration on a new frame is done | |
ImgStatus * | isInitialized () override |
virtual void | setInitStatus () |
virtual void | clearInitStatus () |
virtual bool | isSymmetrical () const |
return false if the similarity function f is not symmetrical, i.e. More... | |
virtual void | updateModel (const PtsT &curr_pts) |
optional function to incorporate online learning or adaptation of the model used to represent the appearance of the object being tracked this should be called with the final location of the object (obtained by the search process) in each frame | |
virtual void | initializeSampler (const VectorXd &state_sigma, const VectorXd &state_mean) |
virtual void | setSampler (const VectorXd &state_sigma, const VectorXd &state_mean) |
virtual void | setSamplerMean (const VectorXd &mean) |
virtual void | setSamplerSigma (const VectorXd &std) |
virtual void | getSamplerMean (VectorXd &mean) |
virtual void | getSamplerSigma (VectorXd &std) |
virtual void | generatePerturbation (VectorXd &perturbation) |
![]() | |
ImageBase (const ImgParams *img_params=nullptr, const int _n_channels=1) | |
virtual int | inputType () const |
return the type of OpenCV Mat image the AM requires as input; typically either CV_32FC3 or CV_32FC1 | |
virtual const cv::Mat & | getCurrImg () const |
accessor methods; these are not defined as 'const' since an appearance model may like to make some last moment changes to the variable being accessed before returning it to can avoid any unnecessary computations concerning the variable (e.g. More... | |
virtual unsigned int | getImgHeight () const |
virtual unsigned int | getImgWidth () const |
virtual unsigned int | getResX () const |
virtual unsigned int | getResY () const |
virtual unsigned int | getNPix () const |
virtual unsigned int | getNChannels () const |
virtual unsigned int | getPatchSize () const |
virtual double | getGradOffset () const |
virtual double | getHessOffset () const |
virtual const PixValT & | getInitPixVals () const |
virtual const PixGradT & | getInitPixGrad () const |
virtual const PixHessT & | getInitPixHess () const |
virtual const PixValT & | getCurrPixVals () const |
virtual const PixGradT & | getCurrPixGrad () const |
virtual const PixHessT & | getCurrPixHess () const |
virtual void | setCurrImg (const cv::Mat &cv_img) |
modifier methods; | |
virtual void | setInitPixVals (const PixValT &pix_vals) |
virtual void | setInitPixGrad (const PixGradT &pix_grad) |
virtual void | setInitPixHess (const PixHessT &pix_hess) |
virtual void | setCurrPixVals (const PixValT &pix_vals) |
virtual void | setCurrPixGrad (const PixGradT &pix_grad) |
virtual void | setCurrPixHess (const PixHessT &pix_hess) |
virtual void | initializePixGrad (const GradPtsT &warped_offset_pts) |
functions to compute image differentials (gradient and hessian) are overloaded since there are two ways to define them: More... | |
virtual void | initializePixGrad (const PtsT &init_pts) |
virtual void | initializePixHess (const PtsT &init_pts, const HessPtsT &warped_offset_pts) |
virtual void | initializePixHess (const PtsT &init_pts) |
virtual void | updatePixGrad (const GradPtsT &warped_offset_pts) |
virtual void | updatePixGrad (const PtsT &curr_pts) |
virtual void | updatePixHess (const PtsT &curr_pts) |
virtual void | updatePixHess (const PtsT &curr_pts, const HessPtsT &warped_offset_pts) |
virtual void | extractPatch (VectorXd &pix_vals, const PtsT &curr_pts) |
general utility function to extract raw pixel values from the current image at the specified points; might be useful for visualization purposes as the curr_pix_vals might not have raw pixel values; | |
virtual VectorXd | getPatch (const PtsT &curr_pts) |
returning variant | |
Public Attributes | |
int | feat_size |
VectorXd | curr_feat_vec |
![]() | |
string | name |
name of the appearance model | |
Protected Attributes | |
ParamType | params |
double | epsilon |
PixGradT | norm_dI0_dx |
PixGradT | norm_dIt_dx |
Matrix2Xd | _init_pts |
Matrix2Xd | _curr_pts |
VectorXd | fac_t |
VectorXd | fac_0 |
VectorXd | rc |
SpMat | dr_dIt |
SpMat | dr_dI0 |
VectorXd | grad_I0_x |
VectorXd | grad_I0_y |
VectorXd | grad_It_x |
VectorXd | grad_It_y |
VectorXd | grad_I0_norm |
VectorXd | grad_It_norm |
VectorXd | grad_I0_squared_norm |
VectorXd | grad_It_squared_norm |
![]() | |
double | f |
f(I_0, I_t, p_am): R(N) x R(N) x R(K) -> R measures the similarity between the current (I_t) and initial (I_0) patches using the photometric parameters (p_am) this is the quantity to be maximized by the optimization process | |
RowVectorXd | df_dI0 |
1 x N gradients of the similarity w.r.t. More... | |
RowVectorXd | df_dIt |
VectorXd | p_am |
parameters of the photomtric model | |
int | state_size |
size of p_am, i.e. More... | |
RowVectorXd | df_dpam |
1 x K Jacobian of the similarity function w.r.t. More... | |
MatrixXd | d2f_dpam2 |
K x K Hessian of the similarity w.r.t. More... | |
RowVectorXd | df_dg0 |
1 x N gradient of the similarity w.r.t. More... | |
RowVectorXd | df_dgt |
MatrixXd | d2f_dpam_dIt |
K x N cross Hessian of the similarity w.r.t. More... | |
MatrixXd | d2f_dI02 |
these NxN Hessians of the similarity wrt pixel values are usually not stored or computed explicitly because: More... | |
MatrixXd | d2f_dIt2 |
bool | first_iter |
indicator variable that can be set by iterative search methods to indicate if the initial or first iteration is being run on the current image; can be used to perform some costly operations/updates only once per frame rather than at every iteration | |
const bool * | spi_mask |
pixels corresponding to false entries in the mask will be ignored in all respective computations where pixel values are used; it is up to the AM to do this in a way that makes sense; since none of the state variables are actually being resized they will still have entries corresponding to these ignored pixels but the AM s at liberty to put anything there assuming that the SM will not use these entries in its own computations; this is why all of these have default implementations that simply ignore the mask; these can be used by the AM when the non masked entries of the computed variable do not depend on the masked pixels; | |
AMStatus | is_initialized |
indicator variables used to keep track of which state variables have been initialized; | |
![]() | |
const unsigned int | resx |
horizontal and vertical sampling resolutions for the object patch | |
const unsigned int | resy |
const unsigned int | n_pix |
no. of pixels in the sampled image patch to be tracked | |
const unsigned int | n_channels |
no. More... | |
const unsigned int | patch_size |
size of the vector that represents the object patch in the image, typically n_pix*n_channels | |
const double | grad_eps |
offsets to use for computing the numerical image gradient and hessian | |
const double | hess_eps |
const InputType | input_type |
EigImgT | curr_img |
Eigen structure shaing memory with the OpenCV image used by default with grayscale inputs. | |
cv::Mat | curr_img_cv |
OpenCV image used by default with multi channel inputs. | |
unsigned int | img_height |
height and width of the input images | |
unsigned int | img_width |
PixValT | I0 |
let N = n_pix = no. More... | |
PixValT | It |
PixGradT | dI0_dx |
(N*C) x 2 jacobian of pixel values in the warped image w.r.t. More... | |
PixGradT | dIt_dx |
PixHessT | d2I0_dx2 |
4 x (N*C) Hessian of pixel values in the warped image w.r.t. More... | |
PixHessT | d2It_dx2 |
double | pix_norm_add |
additive and multiplicative factors for normalizing pixel values | |
double | pix_norm_mult |
unsigned int | frame_count |
incremented once during initialization and thereafter everytime the template is updated | |
Normalized Gradient Fields.
|
inlineoverridevirtual |
even though the Hessian of the error norm w.r.t.
pixel values is not a state variable (since it does not need to be computed separately to get the Hessian w.r.t SSM), this function is provided as a place to perform any one-time computations that may help to decrease the runtime cost of the interfacing function that computes this Hessian
Reimplemented from AppearanceModel.
|
overridevirtual |
methods to initialize the state variables - to be called once when the tracker is initialized.
if any of these are reimplemented, there should be a statement there copying the computed value in the "init" variable to the corresponding "curr" variable so the two have the same value after this function is called;
Note for the SM: the "initialize" function for any state variable whose "update" function will be called later should be called once from the SM's own initialize function even if the initial value of that variable will not be used later; this is because updating the state variable may involve some computations which need to be performed only once and the AM is free to delegate any such computations to the respective "initialize" function to avoid repeating them in the "update" function which can have a negative impact on performance; thus if this function is not called, the results of these computations that are needed by the "update" function will remain uncomputed leading to undefined behavior;
also the initialize functions have a boolean indicator parameter called "is_initialized" which defaults to true but should be set to false if they are called only to update the internal state to take into account any changes to the initial template, i.e. if they are called again after the first call to initialize the state (when it should be left to true)
Reimplemented from AppearanceModel.
|
inlineoverridevirtual |
computes a "distance" vector using the current image patch such that, when the distance vectors corresponding to two patches are passed to the distance operator above, it uses these to compute a scalar that measures the distance or dissimilarity between the two patches; this distance vector should be designed so as to offload as much computation as possible from the distance operator, i.e.
every computation that depends only on the current patch should be performed here and the results should be stored, suitably coded, in the distannce vector where they will be decoded and used to compute the distance measure
Reimplemented from AppearanceModel.
|
overridevirtual |
functions for updating state variables when a new image arrives
prereq_only should be left to true if update is only called to compute the prerequisites for the two gradient functions and the actual value of similarity is not needed
Reimplemented from AppearanceModel.