38#include <visp3/tt_mi/vpTemplateTrackerMIESM.h>
40#ifdef VISP_HAVE_OPENMP
51 if (!
Warp->isESMcompatible()) {
52 throw(vpException(vpException::badValue,
"The selected warp function is not appropriate for the ESM algorithm..."));
79 Warp->computeCoeff(
p);
80 for (
unsigned int point = 0; point <
templateSize; point++) {
92 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.getHeight() - 1) && (j2 < I.getWidth() - 1)) {
96 IW =
BI.getValue(i2, j2);
98 IW = I.getValue(i2, j2);
100 ct = ptTemplateSupp[point].ct;
101 et = ptTemplateSupp[point].et;
102 cr =
static_cast<int>((IW * (
Nc - 1)) / 255.);
103 er = (IW * (
Nc - 1)) / 255. - cr;
127 Warp->computeCoeff(
p);
128 for (
unsigned int point = 0; point <
templateSize; point++) {
140 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.getHeight()) && (j2 < I.getWidth())) {
144 IW = I.getValue(i2, j2);
146 IW =
BI.getValue(i2, j2);
148 dx =
dIx.getValue(i2, j2) * (
Nc - 1) / 255.;
149 dy =
dIy.getValue(i2, j2) * (
Nc - 1) / 255.;
151 cr = ptTemplateSupp[point].ct;
152 er = ptTemplateSupp[point].et;
153 ct =
static_cast<int>((IW * (
Nc - 1)) / 255.);
154 et = (IW * (
Nc - 1)) / 255. - ct;
158 for (
unsigned int it = 0; it <
nbParam; it++)
159 tptemp[it] =
dW[0][it] * dx +
dW[1][it] * dy;
188 ptTemplateSupp =
new vpTemplateTrackerPointSuppMIInv[
templateSize];
190 for (
unsigned int point = 0; point <
templateSize; point++) {
206 int ct =
static_cast<int>((Tij * (
Nc - 1)) / 255.);
207 double et = (Tij * (
Nc - 1)) / 255. - ct;
208 ptTemplateSupp[point].et = et;
209 ptTemplateSupp[point].ct = ct;
210 ptTemplateSupp[point].Bt =
new double[4];
211 ptTemplateSupp[point].dBt =
new double[4];
212 for (
char it = -1; it <= 2; it++) {
213 ptTemplateSupp[point].Bt[it + 1] = vpTemplateTrackerBSpline::Bspline4(-it + et);
214 ptTemplateSupp[point].dBt[it + 1] = vpTemplateTrackerMIBSpline::dBspline4(-it + et);
223 std::cout <<
"Compositionnal tracking not initialised.\nUse initCompInverse() function." << std::endl;
248 unsigned int iteration = 0;
259 Warp->computeCoeff(
p);
260 for (point = 0; point < static_cast<int>(
templateSize); point++) {
272 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.getHeight() - 1) && (j2 < I.getWidth() - 1)) {
276 IW = I.getValue(i2, j2);
278 IW =
BI.getValue(i2, j2);
280 ct = ptTemplateSupp[point].ct;
281 et = ptTemplateSupp[point].et;
282 cr =
static_cast<int>((IW * (
Nc - 1)) / 255.);
283 er = (IW * (
Nc - 1)) / 255. - cr;
313 Warp->computeCoeff(
p);
314#ifdef VISP_HAVE_OPENMP
315 int nthreads = omp_get_num_procs();
318 omp_set_num_threads(nthreads);
319#pragma omp parallel for private(i, j, i2, j2) default(shared)
321 for (point = 0; point < static_cast<int>(
templateSize); point++) {
327 Warp->warpX(i, j, i2, j2,
p);
331 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.getHeight() - 1) && (j2 < I.getWidth() - 1)) {
335 IW = I.getValue(i2, j2);
337 IW =
BI.getValue(i2, j2);
339 double dx =
dIx.getValue(i2, j2) * (
Nc - 1) / 255.;
340 double dy =
dIy.getValue(i2, j2) * (
Nc - 1) / 255.;
342 ct =
static_cast<int>((IW * (
Nc - 1)) / 255.);
343 et = (IW * (
Nc - 1)) / 255. - ct;
344 cr = ptTemplateSupp[point].ct;
345 er = ptTemplateSupp[point].et;
348 for (
unsigned int it = 0; it <
nbParam; it++)
349 tptemp[it] =
dW[0][it] * dx +
dW[1][it] * dy;
Type * data
Address of the first element of the data array.
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
static void getGradX(const vpImage< unsigned char > &I, vpImage< FilterType > &dIx, const vpImage< bool > *p_mask=nullptr)
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)
static void getGradY(const vpImage< unsigned char > &I, vpImage< FilterType > &dIy, 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)
vpMinimizationTypeMIESM minimizationMethod
vpTemplateTrackerMIESM()
Default constructor.
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 computeOptimalBrentGain(const vpImage< unsigned char > &I, vpColVector &tp, double tMI, vpColVector &direction, double &alpha)
unsigned int iterationMax
vpTemplateTrackerPoint * ptTemplate
vpTemplateTrackerWarp * Warp
unsigned int templateSize
vpTemplateTrackerPointCompo * ptTemplateCompo
Error that can be emitted by the vpTracker class and its derivatives.
@ notEnoughPointError
Not enough point to track.