39#include <visp3/tt_mi/vpTemplateTrackerMIForwardCompositional.h>
48 ptTemplateSupp =
new vpTemplateTrackerPointSuppMIInv[
templateSize];
49 for (
unsigned int point = 0; point <
templateSize; point++) {
59 int ct = (int)((Tij * (
Nc - 1)) / 255.);
60 double et = (Tij * (
Nc - 1)) / 255. - ct;
61 ptTemplateSupp[point].et = et;
62 ptTemplateSupp[point].ct = ct;
63 ptTemplateSupp[point].Bt =
new double[4];
64 ptTemplateSupp[point].dBt =
new double[4];
65 for (
char it = -1; it <= 2; it++) {
66 ptTemplateSupp[point].Bt[it + 1] = vpTemplateTrackerBSpline::Bspline4(-it + et);
67 ptTemplateSupp[point].dBt[it + 1] = vpTemplateTrackerMIBSpline::dBspline4(-it + et);
93 Warp->computeCoeff(
p);
94 for (
unsigned int point = 0; point <
templateSize; point++) {
106 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.getHeight() - 1) && (j2 < I.getWidth() - 1)) {
109 IW = I.getValue(i2, j2);
111 IW =
BI.getValue(i2, j2);
113 dx =
dIx.getValue(i2, j2) * (
Nc - 1) / 255.;
114 dy =
dIy.getValue(i2, j2) * (
Nc - 1) / 255.;
116 cr = ptTemplateSupp[point].ct;
117 er = ptTemplateSupp[point].et;
118 ct = (int)((IW * (
Nc - 1)) / 255.);
119 et = ((double)IW * (
Nc - 1)) / 255. - ct;
123 double *tptemp =
new double[
nbParam];
124 for (
unsigned int it = 0; it <
nbParam; it++)
125 tptemp[it] =
dW[0][it] * dx +
dW[1][it] * dy;
146 std::cout <<
"Compositionnal tracking not initialised.\nUse initCompo() function." << std::endl;
157 double MI = 0, MIprec = -1000;
173 unsigned int iteration = 0;
175 double evolRMS_init = 0;
176 double evolRMS_prec = 0;
177 double evolRMS_delta;
186 Warp->computeCoeff(
p);
188 for (
unsigned int point = 0; point <
templateSize; point++) {
193 Warp->warpX(i, j, i2, j2,
p);
198 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.getHeight() - 1) && (j2 < I.getWidth() - 1)) {
201 IW = I.getValue(i2, j2);
203 IW =
BI.getValue(i2, j2);
205 dx =
dIx.getValue(i2, j2) * (
Nc - 1) / 255.;
206 dy =
dIy.getValue(i2, j2) * (
Nc - 1) / 255.;
208 ct = (int)((IW * (
Nc - 1)) / 255.);
209 et = ((double)IW * (
Nc - 1)) / 255. - ct;
210 cr = ptTemplateSupp[point].ct;
211 er = ptTemplateSupp[point].et;
215 double *tptemp =
new double[
nbParam];
216 for (
unsigned int it = 0; it <
nbParam; it++)
217 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 getGradYGauss2D(const vpImage< ImageType > &I, vpImage< FilterType > &dIy, const FilterType *gaussianKernel, const FilterType *gaussianDerivativeKernel, unsigned int size)
static void getGradXGauss2D(const vpImage< ImageType > &I, vpImage< FilterType > &dIx, const FilterType *gaussianKernel, const FilterType *gaussianDerivativeKernel, unsigned int size)
static void filter(const vpImage< unsigned char > &I, vpImage< FilterType > &If, const vpArray2D< FilterType > &M, bool convolve=false)
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)
vpTemplateTrackerMIForwardCompositional(vpTemplateTrackerWarp *_warp)
vpHessienApproximationType ApproxHessian
vpHessienType hessianComputation
void computeMI(double &MI)
void computeProba(int &nbpoint)
vpTemplateTrackerMI()
Default constructor.
void computeHessien(vpMatrix &H)
double getCost(const vpImage< unsigned char > &I, const vpColVector &tp)
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.