41 #include <visp3/tt_mi/vpTemplateTrackerMIForwardAdditional.h> 43 #ifdef VISP_HAVE_OPENMP 48 :
vpTemplateTrackerMI(_warp), minimizationMethod(USE_NEWTON), p_prec(), G_prec(), KQuasiNewton()
72 Warp->computeCoeff(
p);
73 for (
unsigned int point = 0; point <
templateSize; point++) {
87 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.
getHeight() - 1) && (j2 < I.
getWidth() - 1)) {
98 ct =
static_cast<int>((IW * (
Nc - 1)) / 255.);
99 cr =
static_cast<int>((Tij * (
Nc - 1)) / 255.);
100 et = (IW * (
Nc - 1)) / 255. - ct;
101 er = (
static_cast<double>(Tij) * (
Nc - 1)) / 255. - cr;
104 double *tptemp =
new double[
nbParam];
105 for (
unsigned int it = 0; it <
nbParam; it++)
106 tptemp[it] =
dW[0][it] * dx +
dW[1][it] * dy;
109 vpTemplateTrackerMIBSpline::PutTotPVBsplineNoSecond(
PrtTout, cr, er, ct, et,
Nc, tptemp, nbParam,
bspline);
111 vpTemplateTrackerMIBSpline::PutTotPVBspline(
PrtTout, cr, er, ct, et,
Nc, tptemp, nbParam,
bspline);
142 double MI = 0, MIprec = -1000;
148 unsigned int iteration = 0;
151 double evolRMS_init = 0;
152 double evolRMS_prec = 0;
153 double evolRMS_delta;
156 if (iteration % 5 == 0)
165 Warp->computeCoeff(
p);
166 #ifdef VISP_HAVE_OPENMP 167 int nthreads = omp_get_num_procs();
170 omp_set_num_threads(nthreads);
171 #pragma omp parallel for default(shared) 173 for (
int point = 0; point < (int)
templateSize; point++) {
185 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.
getHeight() - 1) && (j2 < I.
getWidth() - 1)) {
197 int ct = (int)((IW * (
Nc - 1)) / 255.);
198 int cr = (int)((Tij * (
Nc - 1)) / 255.);
199 double et = (IW * (
Nc - 1)) / 255. - ct;
200 double er = ((double)Tij * (
Nc - 1)) / 255. - cr;
204 double *tptemp =
new double[
nbParam];
205 for (
unsigned int it = 0; it <
nbParam; it++)
206 tptemp[it] = (
dW[0][it] * dx +
dW[1][it] * dy);
208 vpTemplateTrackerMIBSpline::PutTotPVBsplineNoSecond(
PrtTout, cr, er, ct, et,
Nc, tptemp, nbParam,
bspline);
210 vpTemplateTrackerMIBSpline::PutTotPVBspline(
PrtTout, cr, er, ct, et,
Nc, tptemp, nbParam,
bspline);
247 switch (minimizationMethod) {
251 p_test_LMA =
p - 100000.1 *
dp;
255 double MI_LMA = -
getCost(I, p_test_LMA);
278 double s_scal_y = s_quasi.
t() * y_quasi;
279 if (std::fabs(s_scal_y) > std::numeric_limits<double>::epsilon()) {
280 KQuasiNewton = KQuasiNewton + 0.001 * (s_quasi * s_quasi.
t() / s_scal_y -
281 KQuasiNewton * y_quasi * y_quasi.
t() * KQuasiNewton /
282 (y_quasi.
t() * KQuasiNewton * y_quasi));
285 dp = -KQuasiNewton *
G;
307 if (iteration == 0) {
313 evolRMS_delta = std::fabs(
evolRMS - evolRMS_prec);
316 }
while ((std::fabs(MI - MIprec) > std::fabs(MI) * std::numeric_limits<double>::epsilon()) &&
virtual void warpX(const int &v1, const int &u1, double &v2, double &u2, const vpColVector &p)=0
void computeHessien(vpMatrix &H)
void trackNoPyr(const vpImage< unsigned char > &I)
Type getValue(unsigned int i, unsigned int j) const
vpTemplateTrackerPoint * ptTemplate
vpMatrix inverseByLU() const
void computeOptimalBrentGain(const vpImage< unsigned char > &I, vpColVector &tp, double tMI, vpColVector &direction, double &alpha)
error that can be emited by ViSP classes.
void initPosEvalRMS(const vpColVector &p)
static void getGradYGauss2D(const vpImage< unsigned char > &I, vpImage< double > &dIy, const double *gaussianKernel, const double *gaussianDerivativeKernel, unsigned int size)
void computeEvalRMS(const vpColVector &p)
static void getGradXGauss2D(const vpImage< unsigned char > &I, vpImage< double > &dIx, const double *gaussianKernel, const double *gaussianDerivativeKernel, unsigned int size)
vpHessienApproximationType ApproxHessian
unsigned int templateSize
double cond(double svThreshold=1e-6) const
unsigned int iterationMax
Error that can be emited by the vpTracker class and its derivates.
double getCost(const vpImage< unsigned char > &I, const vpColVector &tp)
void computeMI(double &MI)
unsigned int iterationGlobale
static void filter(const vpImage< double > &I, vpImage< double > &Iu, vpImage< double > &Iv, const vpMatrix &M, bool convolve=false)
vpMatrix HLMdesireInverse
unsigned int getHeight() const
Implementation of column vector and the associated operations.
vpTemplateTrackerMIForwardAdditional()
Default constructor.
void initHessienDesired(const vpImage< unsigned char > &I)
virtual void dWarp(const vpColVector &X1, const vpColVector &X2, const vpColVector &p, vpMatrix &dM)=0
vpTemplateTrackerWarp * Warp
static void computeHLM(const vpMatrix &H, const double &alpha, vpMatrix &HLM)
unsigned int getWidth() const
void computeProba(int &nbpoint)
vpHessienType hessianComputation