40 #include <visp3/tt_mi/vpTemplateTrackerMIESM.h>
42 #ifdef VISP_HAVE_OPENMP
47 :
vpTemplateTrackerMI(_warp), minimizationMethod(USE_NEWTON), CompoInitialised(false), HDirect(), HInverse(),
48 HdesireDirect(), HdesireInverse(), GDirect(), GInverse()
80 Warp->computeCoeff(
p);
81 for (
unsigned int point = 0; point <
templateSize; point++) {
93 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.
getHeight() - 1) && (j2 < I.
getWidth() - 1)) {
101 ct = ptTemplateSupp[point].ct;
102 et = ptTemplateSupp[point].et;
103 cr =
static_cast<int>((IW * (
Nc - 1)) / 255.);
104 er = (IW * (
Nc - 1)) / 255. - cr;
128 Warp->computeCoeff(
p);
129 for (
unsigned int point = 0; point <
templateSize; point++) {
152 cr = ptTemplateSupp[point].ct;
153 er = ptTemplateSupp[point].et;
154 ct =
static_cast<int>((IW * (
Nc - 1)) / 255.);
155 et = (IW * (
Nc - 1)) / 255. - ct;
159 for (
unsigned int it = 0; it <
nbParam; it++)
160 tptemp[it] =
dW[0][it] * dx +
dW[1][it] * dy;
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;
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++) {
331 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.
getHeight() - 1) && (j2 < I.
getWidth() - 1)) {
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.
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
Implementation of column vector and the associated operations.
void resize(unsigned int i, bool flagNullify=true)
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
static void getGradYGauss2D(const vpImage< ImageType > &I, vpImage< FilterType > &dIy, const FilterType *gaussianKernel, const FilterType *gaussianDerivativeKernel, unsigned int size)
static void getGradXGauss2D(const vpImage< ImageType > &I, vpImage< FilterType > &dIx, const FilterType *gaussianKernel, const FilterType *gaussianDerivativeKernel, unsigned int size)
static void getGradX(const vpImage< unsigned char > &I, vpImage< FilterType > &dIx)
static void filter(const vpImage< unsigned char > &I, vpImage< FilterType > &If, const vpArray2D< FilterType > &M, bool convolve=false)
static void getGradY(const vpImage< unsigned char > &I, vpImage< FilterType > &dIy)
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)
void trackNoPyr(const vpImage< unsigned char > &I)
void initHessienDesired(const vpImage< unsigned char > &I)
vpMinimizationTypeMIESM minimizationMethod
vpTemplateTrackerMIESM()
Default constructor.
vpHessienApproximationType ApproxHessian
vpHessienType hessianComputation
void computeMI(double &MI)
void computeProba(int &nbpoint)
void computeHessien(vpMatrix &H)
double getCost(const vpImage< unsigned char > &I, const vpColVector &tp)
virtual void dWarpCompo(const vpColVector &X1, const vpColVector &X2, const vpColVector &p, const double *dwdp0, vpMatrix &dM)=0
virtual bool isESMcompatible() const =0
virtual void getdW0(const int &v, const int &u, const double &dv, const double &du, double *dIdW)=0
virtual void getdWdp0(const int &v, const int &u, double *dIdW)=0
virtual void warpX(const int &v1, const int &u1, double &v2, double &u2, const vpColVector &p)=0
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.