37#include <visp3/tt_mi/vpTemplateTrackerMIForwardCompositional.h>
46 ptTemplateSupp =
new vpTemplateTrackerPointSuppMIInv[
templateSize];
47 for (
unsigned int point = 0; point <
templateSize; point++) {
57 int ct =
static_cast<int>((Tij * (
Nc - 1)) / 255.);
58 double et = (Tij * (
Nc - 1)) / 255. - ct;
59 ptTemplateSupp[point].et = et;
60 ptTemplateSupp[point].ct = ct;
61 ptTemplateSupp[point].Bt =
new double[4];
62 ptTemplateSupp[point].dBt =
new double[4];
63 for (
char it = -1; it <= 2; it++) {
64 ptTemplateSupp[point].Bt[it + 1] = vpTemplateTrackerBSpline::Bspline4(-it + et);
65 ptTemplateSupp[point].dBt[it + 1] = vpTemplateTrackerMIBSpline::dBspline4(-it + et);
91 Warp->computeCoeff(
p);
92 for (
unsigned int point = 0; point <
templateSize; point++) {
104 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.getHeight() - 1) && (j2 < I.getWidth() - 1)) {
107 IW = I.getValue(i2, j2);
109 IW =
BI.getValue(i2, j2);
111 dx =
dIx.getValue(i2, j2) * (
Nc - 1) / 255.;
112 dy =
dIy.getValue(i2, j2) * (
Nc - 1) / 255.;
114 cr = ptTemplateSupp[point].ct;
115 er = ptTemplateSupp[point].et;
116 ct =
static_cast<int>((IW * (
Nc - 1)) / 255.);
117 et = (
static_cast<double>(IW) * (
Nc - 1)) / 255. - ct;
121 double *tptemp =
new double[
nbParam];
122 for (
unsigned int it = 0; it <
nbParam; it++)
123 tptemp[it] =
dW[0][it] * dx +
dW[1][it] * dy;
144 std::cout <<
"Compositionnal tracking not initialised.\nUse initCompo() function." << std::endl;
155 double MI = 0, MIprec = -1000;
171 unsigned int iteration = 0;
173 double evolRMS_init = 0;
174 double evolRMS_prec = 0;
175 double evolRMS_delta;
184 Warp->computeCoeff(
p);
186 for (
unsigned int point = 0; point <
templateSize; point++) {
191 Warp->warpX(i, j, i2, j2,
p);
196 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.getHeight() - 1) && (j2 < I.getWidth() - 1)) {
199 IW = I.getValue(i2, j2);
201 IW =
BI.getValue(i2, j2);
203 dx =
dIx.getValue(i2, j2) * (
Nc - 1) / 255.;
204 dy =
dIy.getValue(i2, j2) * (
Nc - 1) / 255.;
206 ct =
static_cast<int>((IW * (
Nc - 1)) / 255.);
207 et = (
static_cast<double>(IW) * (
Nc - 1)) / 255. - ct;
208 cr = ptTemplateSupp[point].ct;
209 er = ptTemplateSupp[point].et;
213 double *tptemp =
new double[
nbParam];
214 for (
unsigned int it = 0; it <
nbParam; it++)
215 tptemp[it] =
dW[0][it] * dx +
dW[1][it] * dy;
273 if (iteration == 0) {
279 evolRMS_delta = std::fabs(
evolRMS - evolRMS_prec);
282 }
while ((std::fabs(MI - MIprec) > std::fabs(MI) * std::numeric_limits<double>::epsilon()) &&
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
static void getGradXGauss2D(const vpImage< ImageType > &I, vpImage< FilterType > &dIx, const FilterType *gaussianKernel, const FilterType *gaussianDerivativeKernel, unsigned int size, const vpImage< bool > *p_mask=nullptr)
static void filter(const vpImage< ImageType > &I, vpImage< FilterType > &If, const vpArray2D< FilterType > &M, bool convolve=false, const vpImage< bool > *p_mask=nullptr)
static void getGradYGauss2D(const vpImage< ImageType > &I, vpImage< FilterType > &dIy, const FilterType *gaussianKernel, const FilterType *gaussianDerivativeKernel, unsigned int size, const vpImage< bool > *p_mask=nullptr)
Definition of the vpImage class member functions.
static void computeHLM(const vpMatrix &H, const double &alpha, vpMatrix &HLM)
void trackNoPyr(const vpImage< unsigned char > &I)
void initHessienDesired(const vpImage< unsigned char > &I)
VP_EXPLICIT vpTemplateTrackerMIForwardCompositional(vpTemplateTrackerWarp *_warp)
vpHessienApproximationType ApproxHessian
vpHessienType hessianComputation
double getCost(const vpImage< unsigned char > &I, const vpColVector &tp) VP_OVERRIDE
void computeMI(double &MI)
void computeProba(int &nbpoint)
void computeHessien(vpMatrix &H)
vpTemplateTrackerMI(const vpTemplateTrackerMI &)=delete
vpMatrix HLMdesireInverse
void computeEvalRMS(const vpColVector &p)
void computeOptimalBrentGain(const vpImage< unsigned char > &I, vpColVector &tp, double tMI, vpColVector &direction, double &alpha)
unsigned int iterationMax
void initPosEvalRMS(const vpColVector &p)
vpTemplateTrackerPoint * ptTemplate
vpTemplateTrackerWarp * Warp
unsigned int templateSize
Error that can be emitted by the vpTracker class and its derivatives.
@ notEnoughPointError
Not enough point to track.