40 #include <visp3/tt_mi/vpTemplateTrackerMIForwardAdditional.h>
42 #ifdef VISP_HAVE_OPENMP
47 :
vpTemplateTrackerMI(_warp), minimizationMethod(USE_NEWTON), p_prec(), G_prec(), KQuasiNewton()
71 Warp->computeCoeff(
p);
72 for (
unsigned int point = 0; point <
templateSize; point++) {
86 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.
getHeight() - 1) && (j2 < I.
getWidth() - 1)) {
97 ct =
static_cast<int>((IW * (
Nc - 1)) / 255.);
98 cr =
static_cast<int>((Tij * (
Nc - 1)) / 255.);
99 et = (IW * (
Nc - 1)) / 255. - ct;
100 er = (
static_cast<double>(Tij) * (
Nc - 1)) / 255. - cr;
103 double *tptemp =
new double[
nbParam];
104 for (
unsigned int it = 0; it <
nbParam; it++)
105 tptemp[it] =
dW[0][it] * dx +
dW[1][it] * dy;
141 double MI = 0, MIprec = -1000;
147 unsigned int iteration = 0;
150 double evolRMS_init = 0;
151 double evolRMS_prec = 0;
152 double evolRMS_delta;
155 if (iteration % 5 == 0)
164 Warp->computeCoeff(
p);
165 #ifdef VISP_HAVE_OPENMP
166 int nthreads = omp_get_num_procs();
169 omp_set_num_threads(nthreads);
170 #pragma omp parallel for default(shared)
172 for (
int point = 0; point < (int)
templateSize; point++) {
184 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.
getHeight() - 1) && (j2 < I.
getWidth() - 1)) {
196 int ct = (int)((IW * (
Nc - 1)) / 255.);
197 int cr = (int)((Tij * (
Nc - 1)) / 255.);
198 double et = (IW * (
Nc - 1)) / 255. - ct;
199 double er = ((double)Tij * (
Nc - 1)) / 255. - cr;
203 double *tptemp =
new double[
nbParam];
204 for (
unsigned int it = 0; it <
nbParam; it++)
205 tptemp[it] = (
dW[0][it] * dx +
dW[1][it] * dy);
246 switch (minimizationMethod) {
250 p_test_LMA =
p - 100000.1 *
dp;
254 double MI_LMA = -
getCost(I, p_test_LMA);
277 double s_scal_y = s_quasi.
t() * y_quasi;
278 if (std::fabs(s_scal_y) > std::numeric_limits<double>::epsilon()) {
279 KQuasiNewton = KQuasiNewton + 0.001 * (s_quasi * s_quasi.
t() / s_scal_y -
280 KQuasiNewton * y_quasi * y_quasi.
t() * KQuasiNewton /
281 (y_quasi.
t() * KQuasiNewton * y_quasi));
284 dp = -KQuasiNewton *
G;
306 if (iteration == 0) {
312 evolRMS_delta = std::fabs(
evolRMS - evolRMS_prec);
315 }
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
void computeMI(double &MI)
void computeProba(int &nbpoint)
double getCost(const vpImage< unsigned char > &I, const vpColVector &tp) vp_override
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.