40 #include <visp3/tt_mi/vpTemplateTrackerMIESM.h>
42 #ifdef VISP_HAVE_OPENMP
48 :
vpTemplateTrackerMI(_warp), minimizationMethod(USE_NEWTON), CompoInitialised(false), HDirect(), HInverse(),
49 HdesireDirect(), HdesireInverse(), GDirect(), GInverse()
81 Warp->computeCoeff(
p);
82 for (
unsigned int point = 0; point <
templateSize; point++) {
94 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.
getHeight() - 1) && (j2 < I.
getWidth() - 1)) {
102 ct = ptTemplateSupp[point].ct;
103 et = ptTemplateSupp[point].et;
104 cr =
static_cast<int>((IW * (
Nc - 1)) / 255.);
105 er = (IW * (
Nc - 1)) / 255. - cr;
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;
190 ptTemplateSupp =
new vpTemplateTrackerPointSuppMIInv[
templateSize];
192 for (
unsigned int point = 0; point <
templateSize; point++) {
208 int ct =
static_cast<int>((Tij * (
Nc - 1)) / 255.);
209 double et = (Tij * (
Nc - 1)) / 255. - ct;
210 ptTemplateSupp[point].et = et;
211 ptTemplateSupp[point].ct = ct;
212 ptTemplateSupp[point].Bt =
new double[4];
213 ptTemplateSupp[point].dBt =
new double[4];
214 for (
char it = -1; it <= 2; it++) {
215 ptTemplateSupp[point].Bt[it + 1] = vpTemplateTrackerBSpline::Bspline4(-it + et);
216 ptTemplateSupp[point].dBt[it + 1] = vpTemplateTrackerMIBSpline::dBspline4(-it + et);
225 std::cout <<
"Compositionnal tracking not initialised.\nUse initCompInverse() function." << std::endl;
250 unsigned int iteration = 0;
261 Warp->computeCoeff(
p);
262 for (point = 0; point < static_cast<int>(
templateSize); point++) {
274 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.
getHeight() - 1) && (j2 < I.
getWidth() - 1)) {
282 ct = ptTemplateSupp[point].ct;
283 et = ptTemplateSupp[point].et;
284 cr =
static_cast<int>((IW * (
Nc - 1)) / 255.);
285 er = (IW * (
Nc - 1)) / 255. - cr;
315 Warp->computeCoeff(
p);
316 #ifdef VISP_HAVE_OPENMP
317 int nthreads = omp_get_num_procs();
320 omp_set_num_threads(nthreads);
321 #pragma omp parallel for private(i, j, i2, j2) default(shared)
323 for (point = 0; point < static_cast<int>(
templateSize); point++) {
333 if ((i2 >= 0) && (j2 >= 0) && (i2 < I.
getHeight() - 1) && (j2 < I.
getWidth() - 1)) {
344 ct =
static_cast<int>((IW * (
Nc - 1)) / 255.);
345 et = (IW * (
Nc - 1)) / 255. - ct;
346 cr = ptTemplateSupp[point].ct;
347 er = ptTemplateSupp[point].et;
350 for (
unsigned int it = 0; it <
nbParam; it++)
351 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 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)
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
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 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.