41 #include <visp3/tt_mi/vpTemplateTrackerMIESM.h> 43 #ifdef VISP_HAVE_OPENMP 48 :
vpTemplateTrackerMI(_warp), minimizationMethod(USE_NEWTON), CompoInitialised(false), HDirect(), HInverse(),
49 HdesireDirect(), HdesireInverse(), GDirect(), GInverse()
55 "The selected warp function is not appropriate for the ESM algorithm..."));
82 Warp->computeCoeff(
p);
83 for (
unsigned int point = 0; point <
templateSize; point++) {
95 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.
getHeight() - 1) && (j2 < I.
getWidth() - 1)) {
103 ct = ptTemplateSupp[point].ct;
104 et = ptTemplateSupp[point].et;
105 cr =
static_cast<int>((IW*(
Nc-1))/255.);
106 er = (IW*(
Nc-1))/255.-cr;
108 vpTemplateTrackerMIBSpline::computeProbabilities(
PrtTout, cr, er, ct, et,
Nc,
ptTemplate[point].
dW,
nbParam,
bspline,
ApproxHessian,
false);
129 Warp->computeCoeff(
p);
130 for (
unsigned int point = 0; point <
templateSize; point++) {
153 cr = ptTemplateSupp[point].ct;
154 er = ptTemplateSupp[point].et;
155 ct =
static_cast<int>((IW*(
Nc-1))/255.);
156 et = (IW*(
Nc-1))/255.-ct;
160 for (
unsigned int it = 0; it <
nbParam; it++)
161 tptemp[it] = dW[0][it] * dx + dW[1][it] * dy;
163 vpTemplateTrackerMIBSpline::computeProbabilities(
PrtTout, cr, er, ct, et,
Nc, tptemp.
data, nbParam,
bspline,
ApproxHessian,
false);
189 ptTemplateSupp =
new vpTemplateTrackerPointSuppMIInv[
templateSize];
191 for (
unsigned int point = 0; point <
templateSize; point++) {
207 int ct =
static_cast<int>((Tij * (
Nc - 1)) / 255.);
208 double et = (Tij * (
Nc - 1)) / 255. - ct;
209 ptTemplateSupp[point].et = et;
210 ptTemplateSupp[point].ct = ct;
211 ptTemplateSupp[point].Bt =
new double[4];
212 ptTemplateSupp[point].dBt =
new double[4];
213 for (
char it = -1; it <= 2; it++) {
214 ptTemplateSupp[point].Bt[it + 1] = vpTemplateTrackerBSpline::Bspline4(-it + et);
215 ptTemplateSupp[point].dBt[it + 1] = vpTemplateTrackerMIBSpline::dBspline4(-it + et);
224 std::cout <<
"Compositionnal tracking not initialised.\nUse initCompInverse() function." << std::endl;
249 unsigned int iteration = 0;
260 Warp->computeCoeff(
p);
261 for (point = 0; point < static_cast<int>(
templateSize); point++) {
273 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.
getHeight() - 1) && (j2 < I.
getWidth() - 1)) {
281 ct = ptTemplateSupp[point].ct;
282 et = ptTemplateSupp[point].et;
283 cr =
static_cast<int>((IW*(
Nc-1))/255.);
284 er = (IW*(
Nc-1))/255.-cr;
286 vpTemplateTrackerMIBSpline::computeProbabilities(
PrtTout, cr, er, ct, et,
Nc,
ptTemplate[point].
dW,
nbParam,
bspline,
ApproxHessian,
hessianComputation==
USE_HESSIEN_DESIRE);
311 Warp->computeCoeff(
p);
312 #ifdef VISP_HAVE_OPENMP 313 int nthreads = omp_get_num_procs();
316 omp_set_num_threads(nthreads);
317 #pragma omp parallel for private(point, i, j, i2, j2) default(shared) 319 for (point = 0; point < static_cast<int>(
templateSize); point++) {
329 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.
getHeight() - 1) && (j2 < I.
getWidth() - 1)) {
340 ct =
static_cast<int>((IW*(
Nc-1))/255.);
341 et = (IW*(
Nc-1))/255.-ct;
342 cr = ptTemplateSupp[point].ct;
343 er = ptTemplateSupp[point].et;
346 for (
unsigned int it = 0; it <
nbParam; it++)
347 tptemp[it] = dW[0][it] * dx + dW[1][it] * dy;
349 vpTemplateTrackerMIBSpline::computeProbabilities(
PrtTout,cr, er, ct, et,
Nc, tptemp.
data, nbParam,
bspline,
ApproxHessian,
hessianComputation==
USE_HESSIEN_DESIRE);
virtual void warpX(const int &v1, const int &u1, double &v2, double &u2, const vpColVector &p)=0
Used to indicate that a value is not in the allowed range.
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
void computeHessien(vpMatrix &H)
unsigned int getWidth() const
static void getGradX(const vpImage< unsigned char > &I, vpImage< double > &dIx)
vpTemplateTrackerPoint * ptTemplate
static void getGradY(const vpImage< unsigned char > &I, vpImage< double > &dIy)
vpTemplateTrackerMIESM()
Default constructor.
void computeOptimalBrentGain(const vpImage< unsigned char > &I, vpColVector &tp, double tMI, vpColVector &direction, double &alpha)
virtual void dWarpCompo(const vpColVector &X1, const vpColVector &X2, const vpColVector &p, const double *dwdp0, vpMatrix &dM)=0
error that can be emited by ViSP classes.
Type * data
Address of the first element of the data array.
static void getGradYGauss2D(const vpImage< unsigned char > &I, vpImage< double > &dIy, const double *gaussianKernel, const double *gaussianDerivativeKernel, unsigned int size)
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
virtual void getdWdp0(const int &v, const int &u, double *dIdW)=0
unsigned int iterationMax
Type getValue(unsigned int i, unsigned int j) const
Error that can be emited by the vpTracker class and its derivates.
double getCost(const vpImage< unsigned char > &I, const vpColVector &tp)
void initHessienDesired(const vpImage< unsigned char > &I)
void computeMI(double &MI)
double cond(double svThreshold=1e-6) const
virtual bool isESMcompatible() const =0
virtual void getdW0(const int &v, const int &u, const double &dv, const double &du, double *dIdW)=0
void trackNoPyr(const vpImage< unsigned char > &I)
static void filter(const vpImage< double > &I, vpImage< double > &Iu, vpImage< double > &Iv, const vpMatrix &M, bool convolve=false)
vpMinimizationTypeMIESM minimizationMethod
vpMatrix HLMdesireInverse
void resize(unsigned int i, bool flagNullify=true)
vpTemplateTrackerPointCompo * ptTemplateCompo
Implementation of column vector and the associated operations.
vpMatrix inverseByLU() const
unsigned int getHeight() const
vpTemplateTrackerWarp * Warp
static void computeHLM(const vpMatrix &H, const double &alpha, vpMatrix &HLM)
void computeProba(int &nbpoint)
vpHessienType hessianComputation