40 #include <visp3/tt_mi/vpTemplateTrackerMIForwardAdditional.h>
42 #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;
143 double MI = 0, MIprec = -1000;
149 unsigned int iteration = 0;
152 double evolRMS_init = 0;
153 double evolRMS_prec = 0;
154 double evolRMS_delta;
157 if (iteration % 5 == 0)
166 Warp->computeCoeff(
p);
167 #ifdef VISP_HAVE_OPENMP
168 int nthreads = omp_get_num_procs();
171 omp_set_num_threads(nthreads);
172 #pragma omp parallel for default(shared)
174 for (
int point = 0; point < (int)
templateSize; point++) {
186 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.
getHeight() - 1) && (j2 < I.
getWidth() - 1)) {
198 int ct = (int)((IW * (
Nc - 1)) / 255.);
199 int cr = (int)((Tij * (
Nc - 1)) / 255.);
200 double et = (IW * (
Nc - 1)) / 255. - ct;
201 double er = ((double)Tij * (
Nc - 1)) / 255. - cr;
205 double *tptemp =
new double[
nbParam];
206 for (
unsigned int it = 0; it <
nbParam; it++)
207 tptemp[it] = (
dW[0][it] * dx +
dW[1][it] * dy);
250 switch (minimizationMethod) {
254 p_test_LMA =
p - 100000.1 *
dp;
258 double MI_LMA = -
getCost(I, p_test_LMA);
282 double s_scal_y = s_quasi.
t() * y_quasi;
283 if (std::fabs(s_scal_y) > std::numeric_limits<double>::epsilon()) {
284 KQuasiNewton = KQuasiNewton + 0.001 * (s_quasi * s_quasi.
t() / s_scal_y -
285 KQuasiNewton * y_quasi * y_quasi.
t() * KQuasiNewton /
286 (y_quasi.
t() * KQuasiNewton * y_quasi));
289 dp = -KQuasiNewton *
G;
311 if (iteration == 0) {
317 evolRMS_delta = std::fabs(
evolRMS - evolRMS_prec);
320 }
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)
unsigned int getWidth() const
Type getValue(unsigned int i, unsigned int j) const
unsigned int getHeight() const
double cond(double svThreshold=1e-6) const
vpMatrix inverseByLU() const
static void computeHLM(const vpMatrix &H, const double &alpha, vpMatrix &HLM)
vpTemplateTrackerMIForwardAdditional()
Default constructor.
void initHessienDesired(const vpImage< unsigned char > &I)
void trackNoPyr(const vpImage< unsigned char > &I)
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)
virtual void dWarp(const vpColVector &X1, const vpColVector &X2, const vpColVector &p, vpMatrix &dM)=0
virtual void warpX(const int &v1, const int &u1, double &v2, double &u2, const vpColVector &p)=0
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 iterationGlobale
unsigned int templateSize
Error that can be emitted by the vpTracker class and its derivatives.
@ notEnoughPointError
Not enough point to track.