25 #include "TrackerBaseAffine2.hh"
26 #include "MathAlgo/SVD.hh"
27 #include "Filter/Gauss.hh"
28 #include "Base/Math/Matrix3x3.hh"
29 #include "Base/Image/ImageIO.hh"
30 #include "Image/AffineMapping.hh"
31 #include "Base/Common/FileHandling.hh"
32 #include "MathAlgo/UnscentedTransform.hh"
33 #include "Base/Image/ImageIO.hh"
36 const double DEFAULT_MAX_AFFINECHANGE = 0.3;
91 BIASASSERT(src.
size()==6);
94 double tempx = A_[0][0] * dx_ + A_[0][1] * dy_;
95 double tempy = A_[1][0] * dx_ + A_[1][1] * dy_;
96 dst[0] = src[0] * tempx + src[1] * tempy + src[4];
97 dst[1] = src[2] * tempx + src[3] * tempy + src[5];
113 AffineBackTransform() {
123 BIASASSERT(src.
size()==6);
125 double tempx = src[0] * dx_ + src[1] * dy_ + src[4];
126 double tempy = src[2] * dx_ + src[3] * dy_ + src[5];
127 dst[0] = A_[0][0] * tempx + A_[0][1] * tempy + tx_;
128 dst[1] = A_[1][0] * tempx + A_[1][1] * tempy + ty_;
138 template <
class StorageType>
142 BIASASSERT(!only4params);
143 _MaxAffineChange = DEFAULT_MAX_AFFINECHANGE;
144 _SimilarityTransformOnly = only4params;
145 affineNormalization_ =
false;
146 initialCov_.newsize(6,6);
147 initialCov_.SetIdentity();
148 initialCov_ *= 0.001;
149 initialCov_[4][4] = 0.05;
150 initialCov_[5][5] = 0.05;
155 template <
class StorageType>
166 BIASERR(
"affine guess seems unitialized, set at least identity");
173 result.
GetData(), AffineResult,
174 error, iter, Cov_, residuumMAD_, residuumMSD_,
175 _SimilarityTransformOnly,
true);
194 double basesmooth = (backdirection)
195 ? sqrt(0.5*(1.0/S[0]+1.0/S[1]))
196 : sqrt(0.5*(S[0]+S[1]));
197 if (basesmooth<=1.0)
return 0;
198 else return(log2(basesmooth));
202 #define INVALID_PIXEL -1e10
204 template <
class StorageType>
213 cout<<
"basesmooth for image 1 is "<<basesmooth<<
" with apar "<<apar<<endl;
214 const double maxLayer = _pgradim2x.
size()-1;
216 AffineBackTransform AT;
225 #ifdef BIASASSERT_ISACTIVE
229 BIASASSERT(ires ==0);
231 cout<<
"inverted A is "<<H<<endl;
232 AT.A_[0][0] = H[0][0];
233 AT.A_[0][1] = H[0][1];
234 AT.A_[1][0] = H[1][0];
235 AT.A_[1][1] = H[1][1];
258 int x_floor = (int)floor(x);
259 int y_floor = (int)floor(y);
260 int x_floor_end = x_floor+hws+1;
261 int y_floor_end = y_floor+hws+1;
262 KLT_TYPE brdy = y - (KLT_TYPE)(y_floor);
263 KLT_TYPE brdx = x - (KLT_TYPE)(x_floor);
265 cout<<
"affine parameters "<<apar <<
"with predicted cov "<<Cov<<endl;
266 cout<<
"image 1 scales: "<<endl;
267 int rf, rc, cf, cc, r, c;
268 for (rf=y_floor-hws, rc=rf+1, r=0; rf<y_floor_end; rf++, rc++, r++) {
269 for (cf=x_floor-hws, cc=cf+1, c=0; cf<x_floor_end; cf++, cc++, c++) {
274 AT.Transform(apar,Cov, offset,dstcov);
276 double layer = log2(sqrt(dstcov.
Trace()));
277 cout<<fixed<<setprecision(2)<<setw(6)<<layer<<
" ";
278 if (layer<0.0) layer = 0;
279 if (layer>maxLayer) layer=maxLayer;
281 const double scale = 1.0/exp2(rint(layer));
283 const double myx = cf+brdx, myy = rf+brdy;
285 if (_pgradim1x[
int(rint(layer))]->IsInROI(scale*myx,scale*myy)) {
287 _pim1.GetTrilinearImageValue(myx, myy, layer, bl[r][c]);
288 BIASASSERT(!BIAS_ISINF( bl[r][c]));
289 BIASASSERT(bl[r][c]<1e10);
290 _pgradim1x.GetTrilinearImageValue(myx, myy, layer, gx[r][c]);
291 BIASASSERT(!BIAS_ISINF( gx[r][c]));
292 _pgradim1y.GetTrilinearImageValue(myx, myy, layer, gy[r][c]);
293 BIASASSERT(!BIAS_ISINF( gy[r][c]));
295 bl[r][c] = gx[r][c] = gy[r][c] = INVALID_PIXEL;
301 if (_AffineBrightnessInvariance) dev1_ = this->NormalizeRegion_(bl, gx, gy);
312 template <
class StorageType>
318 KLT_TYPE& mad, KLT_TYPE& msd,
324 static int featurecounter = 0;
328 KLT_TYPE p1[2]={op1[0],op1[1]};
329 KLT_TYPE p2[2]={op2[0],op2[1]};
331 KLT_TYPE result[2]={oresult[0], oresult[1]};
336 BIASDOUT(D_TRACKERB_AFFINE,
"Called Affine for "
337 <<p1[0]<<
";"<<p1[1]<<
", guess is "<<p2[0]<<
";"<<p2[1]
338 <<
" affine guess is "<< p2A);
339 cout<<
"window size is "<< _WinSize<<endl;
340 const int width = _WinSize;
341 const int height = _WinSize;
342 const int hw = width/2;
343 const int hh = height/2;
345 const KLT_TYPE fhw = hw;
346 const KLT_TYPE fhh = hh;
348 if (_minx1 >= p1[0] || _miny1 >= p1[1] || _maxx1 < p1[0] || _maxy1 < p1[1]){
349 BIASDOUT(D_TRACKERB_KLT,
"original point is too close to border: "
350 <<p1[0]<<
";"<<p1[1]);
355 const int max_iterations = _MaxIterations;
356 const KLT_TYPE maxerr = _MaxError;
357 const KLT_TYPE th_aff = _MaxAffineChange;
363 const unsigned int num_params = SimilarityTransformOnly?4:6;
375 KLT_TYPE *Axx = &(resultA[0][0]);
376 KLT_TYPE *Axy = &(resultA[0][1]);
377 KLT_TYPE *Ayx = &(resultA[1][0]);
378 KLT_TYPE *Ayy = &(resultA[1][1]);
383 bool convergence =
false;
387 KLT_TYPE *imgdiff =
new KLT_TYPE[width * height];
388 KLT_TYPE *gradx =
new KLT_TYPE[width * height];
389 KLT_TYPE *grady =
new KLT_TYPE[width * height];
397 int ps = int(rint(log2(
double(_im1->GetWidth()+_im1->GetHeight()))))-6;
405 if (affineNormalization_) {
415 R1_[1][0], R1_[1][1],
416 R1_[0][2], R1_[1][2]);
418 im1.
Init(10*hw, 10*hw);
419 ShapeNormalizer.
MapDirect( *this->_im1, im1);
420 gradim1x.
Init(10*hw, 10*hw);
421 ShapeNormalizer.
MapDirect( *this->_gradim1x, gradim1x);
422 gradim1y.
Init(10*hw, 10*hw);
423 ShapeNormalizer.
MapDirect( *this->_gradim1y, gradim1y);
428 result[0] = p1[0] = x1[0];
429 result[1] = p1[1] = x1[1];
441 A3x3[0][0] = resultA[0][0];
442 A3x3[0][1] = resultA[0][1];
443 A3x3[1][0] = resultA[1][0];
444 A3x3[1][1] = resultA[1][1];
450 #ifdef BIASASSERT_ISACTIVE
453 A3x3.GetInverse(A3x3I);
459 im2.
Init(10*hw, 10*hw);
461 gradim2x.
Init(10*hw, 10*hw);
462 ShapeNormalizer.
MapDirect( *_gradim2x, gradim2x);
463 gradim2y.
Init(10*hw, 10*hw);
464 ShapeNormalizer.
MapDirect( *_gradim2y, gradim2y);
487 gradim1x = *this->_gradim1x ;
488 gradim1y = *this->_gradim1y;
490 gradim2x = *this->_gradim2x;
491 gradim2y = *this->_gradim2y;
498 BIASWARN(
"Create image pyramids ...");
501 _pim1.SetLowPassFilter(theGauss);
503 _pgradim1x.SetLowPassFilter(theGauss);
505 _pgradim1y.SetLowPassFilter(theGauss);
507 _pim2.SetLowPassFilter(theGauss);
509 _pgradim2x.SetLowPassFilter(theGauss);
511 _pgradim2y.SetLowPassFilter(theGauss);
514 if (!_pim1.IsEmpty()) _pim1.Clear();
516 if (!this->_pgradim1x.IsEmpty()) this->_pgradim1x.Clear();
517 this->_pgradim1x.Init(gradim1x, ps);
518 if (!this->_pgradim1y.IsEmpty()) this->_pgradim1y.Clear();
519 this->_pgradim1y.Init(gradim1y, ps);
520 if (!_pim2.IsEmpty()) _pim2.Clear();
522 if (!_pgradim2x.IsEmpty()) _pgradim2x.Clear();
523 _pgradim2x.Init(gradim2x, ps);
524 if (!_pgradim2y.IsEmpty()) _pgradim2y.Clear();
525 _pgradim2y.Init(gradim2y, ps);
529 _pim1.WriteImages(
"pim1");
530 _pgradim1x.WriteImages(
"pgx1");
531 _pgradim1y.WriteImages(
"pgy1");
532 _pim2.WriteImages(
"pim2");
533 _pgradim2x.WriteImages(
"pgx2");
534 _pgradim2y.WriteImages(
"pgy2");
539 BIASASSERT(_pim1.GetPositionOffset()==0.0);
541 bool lastconvergence =
false;
550 BilinearRegion1_(p1[0], p1[1], hh, apar, Cov);
552 KLT_TYPE ul_x = result[0] + *Axy * fhh - *Axx * fhw;
553 KLT_TYPE ul_y = result[1] + *Ayy * fhh - *Ayx * fhw;
554 KLT_TYPE ll_x = result[0] - *Axx * fhw - *Axy * fhh;
555 KLT_TYPE ll_y = result[1] - *Ayx * fhw - *Ayy * fhh;
556 KLT_TYPE ur_x = result[0] + *Axx * fhw + *Axy * fhh;
557 KLT_TYPE ur_y = result[1] + *Ayx * fhw + *Ayy * fhh;
558 KLT_TYPE lr_x = result[0] + *Axx * fhw - *Axy * fhh;
559 KLT_TYPE lr_y = result[1] + *Ayx * fhw - *Ayy * fhh;
561 if ( ul_x < _minx2 || ul_x > _maxx2 ||
562 ll_x < _minx2 || ll_x > _maxx2 ||
563 ur_x < _minx2 || ur_x > _maxx2 ||
564 lr_x < _minx2 || lr_x > _maxx2 ||
565 ul_y < _miny2 || ul_y > _maxy2 ||
566 ll_y < _miny2 || ll_y > _maxy2 ||
567 ur_y < _miny2 || ur_y > _maxy2 ||
568 lr_y < _miny2 || lr_y > _maxy2) {
570 BIASDOUT( D_TRACKERB_KLT,
"out of image");
575 GetGradientWinAffine_(result[0], result[1],
576 *Axx, *Ayx , *Axy, *Ayy,
577 hw, hh, imgdiff, gradx, grady, Cov);
579 if (this->GetDebugLevel() & D_TRACKERB_AFFINE) {
581 ss<<
"Af2_"<<setw(3)<<setfill(
'0')<<int(featurecounter)<<
"-"
582 <<setw(4)<<setfill(
'0')<<int(iteration)<<
"-";
583 string imname = ss.str();
587 for (
int y=0; y<2*hh+1; y++) {
588 for (
int x=0; x<2*hw+1; x++) {
600 if (SimilarityTransformOnly){
612 result[0] += dx = a[2];
613 result[1] += dy = a[3];
626 const unsigned int wh = width*height;
627 register KLT_TYPE* fw = imgdiff;
628 for (
unsigned int h=0; h<wh ; h++) {
629 const KLT_TYPE cur = (KLT_TYPE)fabsf((
float) (*fw) );
642 BIASDOUT(D_TRACKERB_KLT,
"inhom. eq. system is "
643 <<setprecision(4)<<setw(6)<<T<<
" "<< a);
652 result[0] += dx = a[4];
653 result[1] += dy = a[5];
657 #define DATHRESH 0.05
658 for (
unsigned int i=0; i<4; i++) {
659 if (fabs(a[i])<DATHRESH) Cov[i][i] = 4.0*a[i]*a[i];
660 else Cov[i][i] = 4.0*DATHRESH*DATHRESH;
662 #define DXTHRESH 0.25
663 if (fabs(dx)<DXTHRESH) Cov[4][4] = 4.0*dx*dx;
664 else Cov[4][4]= 4.0*DXTHRESH*DXTHRESH;
665 if (fabs(dy)<DXTHRESH) Cov[5][5] = 4.0*dy*dy;
666 else Cov[5][5]= 4.0*DXTHRESH*DXTHRESH;
668 cout<<
"heuristic cov "<<Cov<<
" and last cov "<<Cov2<<endl;
670 for (
unsigned int i=0; i<6; i++) {
671 for (
unsigned int j=i; j<6; j++) {
672 Cov[i][j] = 0.25*(Cov[i][j]+Cov[j][i]+Cov2[i][j]+Cov2[j][i]);
675 for (
unsigned int i=1; i<6; i++) {
676 for (
unsigned int j=0; j<i; j++) {
677 Cov[i][j] = Cov[j][i];
682 cout<<endl<<
"Cov is now "<<Cov<<endl;
688 BIASDOUT(D_TRACKERB_KLT,
"parameter update a is : "<< a);
690 (*Axx + *Axy) * (*Axx + *Axy) + (*Ayx + *Ayy) * (*Ayx + *Ayy);
693 (*Axy - *Axx) * (*Axy - *Axx) + (*Ayy - *Ayx) * (*Ayy - *Ayx);
695 double ratio = (posdiag>negdiag) ? negdiag / posdiag : posdiag / negdiag;
700 BIASDOUT(D_TRACKERB_KLT,
"diag ratio is too big: "<< sqrt(ratio));
704 double scalex = (*Axx * *Axx) + (*Ayx * *Ayx);
705 double scaley = (*Ayy * *Ayy) + (*Axy * *Axy);
708 ratio = (scalex>scaley) ? scaley / scalex : scalex / scaley;
712 BIASDOUT(D_TRACKERB_KLT,
"axes ratio is too big: "<< sqrt(ratio));
718 ul_x -= result[0] - *Axx * fhw + *Axy * fhh;
719 ul_y -= result[1] - *Ayx * fhw + *Ayy * fhh;
721 ll_x -= result[0] - *Axx * fhw - *Axy * fhh;
722 ll_y -= result[1] - *Ayx * fhw - *Ayy * fhh;
724 ur_x -= result[0] + *Axx * fhw + *Axy * fhh;
725 ur_y -= result[1] + *Ayx * fhw + *Ayy * fhh;
727 lr_x -= result[0] + *Axx * fhw - *Axy * fhh;
728 lr_y -= result[1] + *Ayx * fhw - *Ayy * fhh;
730 convergence = (fabs(dx) < maxerr && fabs(dy) < maxerr &&
731 fabs(ul_x) < th_aff && fabs(ul_y) < th_aff &&
732 fabs(ll_x) < th_aff && fabs(ll_y) < th_aff &&
733 fabs(ur_x) < th_aff && fabs(ur_y) < th_aff &&
734 fabs(lr_x) < th_aff && fabs(lr_y) < th_aff);
736 if (!lastconvergence) {
740 lastconvergence =
true;
743 for (
int i=0; i<Cov.
num_rows(); i++) {
748 }
else lastconvergence =
false;
751 BIASDOUT( D_TRACKERB_KLT,
"no structure for tracking");
755 }
while ( !convergence && iteration < max_iterations);
756 if (iteration >= max_iterations) {
758 BIASDOUT( D_TRACKERB_KLT,
"too many iter: "<<iteration
759 <<
" maxiter="<<max_iterations);
767 const unsigned int wh = width*height;
768 register KLT_TYPE* fw = imgdiff;
769 for (
unsigned int h=0; h<wh ; h++) {
770 const KLT_TYPE cur = (KLT_TYPE)fabsf((
float) (*fw) );
776 mad /= double(wh)*dev1_;
778 double sigma = msd / (double)(wh - SimilarityTransformOnly?4:6);
781 if (ComputeCovariance) {
782 if (SimilarityTransformOnly)
787 Cov = covsvd.
Invert() * sigma;
791 if (SimilarityTransformOnly) {
801 error = (fabs(dx)>fabs(dy))?fabs(dx):fabs(dy);
804 if (result[0]<_minx2 || result[0] > _maxx2 ||
805 result[1]<_miny2 || result[1] > _maxy2)
814 BIASDOUT( D_TRACKERB_KLT,
"status at end is "<<status);
819 if (affineNormalization_) {
823 #ifdef BIASASSERT_ISACTIVE
828 hresult = R2i * hresult;
829 oresult[0] = hresult[0];
830 oresult[1] = hresult[1];
833 hresultA[0][0] = resultA[0][0];
834 hresultA[0][1] = resultA[0][1];
835 hresultA[1][0] = resultA[1][0];
836 hresultA[1][1] = resultA[1][1];
840 hresultA = R2i * hresultA;
843 oresultA[0][0] = hresultA[0][0];
844 oresultA[0][1] = hresultA[0][1];
845 oresultA[1][0] = hresultA[1][0];
846 oresultA[1][1] = hresultA[1][1];
848 BIASWARN(
"Covariance is not yet adapted to coordinate system transform!");
853 oresult[0] = result[0];
854 oresult[1] = result[1];
866 template <
class StorageType>
870 if (_SimilarityTransformOnly) {
897 template <
class StorageType>
900 const KLT_TYPE& Axx,
const KLT_TYPE& Ayx,
901 const KLT_TYPE& Axy,
const KLT_TYPE& Ayy,
902 const int hw,
const int hh,
907 BIASASSERT(!_ComputeFilteredImages);
908 const double maxLayer = _pgradim2x.size()-1;
926 #ifdef BIASASSERT_ISACTIVE
932 AT.A_[0][0] = H[0][0];
933 AT.A_[0][1] = H[0][1];
934 AT.A_[1][0] = H[1][0];
935 AT.A_[1][1] = H[1][1];
938 cout<<
"inverted A is "<<H<<endl;
945 cout<<
"basesmooth for image 2 is "<<basesmooth<<
" with apar "<<apar<<endl;
949 KLT_TYPE* imgdifforig = imgdiff;
952 BIASASSERT(_bl1.num_rows()==_bl1.num_cols());
953 BIASASSERT(_bl1.num_rows()==2*hw+1);
955 KLT_TYPE *pbl1 = _bl1.GetData();
956 KLT_TYPE *pbl2 = _bl2.GetData();
957 cout<<
"image 2 scales for apar "<<apar<<endl;
958 for (j = -hh ; j <= hh ; j++) {
959 for (i = -hw ; i <= hw ; i++) {
963 pt[0][0] = pt[1][2] = i;
964 pt[0][1] = pt[1][3] = j;
965 pt[0][4] = pt[1][5] = 1.0;
975 if (fabs(
float(i+j))==hh+hw) {
976 cout<<apar<<
" with cov "<<Cov<<
" maps "<<i<<
";"
977 <<j<<
" with cov "<<dstcov<<endl;
980 double layer = log2(sqrt(dstcov.
Trace()));
981 cout<<fixed<<setprecision(2)<<setw(6)<< layer <<
" ";
982 if (layer<=0.0) layer = basesmooth;
983 else layer += basesmooth;
984 if (layer>maxLayer) layer=maxLayer;
986 const double scale = 1.0/exp2(rint(layer));
989 mi = x + Axx * i + Axy * j;
990 mj = y + Ayx * i + Ayy * j;
993 if (_pim2[
int(rint(layer))]->IsInROI(scale*mi, scale*mj) &&
994 (this->_bl1[hh+j][hw+i]>INVALID_PIXEL)) {
996 _pim2.GetTrilinearImageValue(mi, mj, layer, *pbl2);
998 BIASASSERT(!BIAS_ISINF(*pbl2));
999 *imgdiff = *pbl1++ - *pbl2++;
1002 *pbl2++ = INVALID_PIXEL;
1012 if (_AffineBrightnessInvariance) {
1013 pbl2 = _bl2.GetData();
1014 const KLT_TYPE thearea = (2*hh+1)*(2*hw+1);
1018 for (j = -hh ; j <= hh ; j++)
1019 for (i = -hw ; i <= hw ; i++) {
1020 diff = (*pbl2++ -= mean2_);
1021 dev2_ += diff * diff;
1023 if (fabs(dev2_)>1e-10) dev2_ = sqrt(thearea / dev2_);
1025 imgdiff = imgdifforig;
1026 pbl1 = _bl1.GetData();
1027 pbl2 = _bl2.GetData();
1028 for (j = -hh ; j <= hh ; j++) {
1029 for (i = -hw ; i <= hw ; i++) {
1030 *imgdiff++ =(*pbl1++) - (*pbl2++ *= dev2_);
1038 if (_AffineBrightnessInvariance) {
1039 BIASWARN(
"no smoothing yet!");
1041 for (j = -hh ; j <= hh ; j++) {
1042 for (i = -hw ; i <= hw ; i++) {
1043 mi = Axx * i + Axy * j;
1044 mj = Ayx * i + Ayy * j;
1047 *out_gradx++ = _gradim2x->FastBilinearInterpolationGrey(x+mi,
1049 *out_grady++ = _gradim2y->FastBilinearInterpolationGrey(x+mi,
1054 cout<<
"Image 2 accesses: "<<endl;
1055 for (j = -hh ; j <= hh ; j++) {
1056 for (i = -hw ; i <= hw ; i++) {
1061 AT.Transform(apar,Cov, offset,dstcov);
1063 double layer = log2(sqrt(dstcov.
Trace()))+basesmooth;
1066 if (layer<=0.0) layer = 0;
1067 if (layer>maxLayer) layer=maxLayer;
1069 const double scale = 1.0/exp2(layer);
1072 mi = x + Axx * i + Axy * j;
1073 mj = y + Ayx * i + Ayy * j;
1075 if (_pgradim2x[
int(rint(layer))]->IsInROI(scale*mi, scale*mj) &&
1076 (this->_bl1[hh+j][hw+i]>INVALID_PIXEL)) {
1078 _pgradim2x.GetTrilinearImageValue(mi,mj, layer, tmp);
1079 *out_gradx = scale * tmp;
1080 _pgradim2y.GetTrilinearImageValue(mi,mj, layer, tmp);
1081 *out_grady = scale * tmp;
1108 #ifdef BUILD_IMAGE_INT
1111 #ifdef BUILD_IMAGE_CHAR
1114 #ifdef BUILD_IMAGE_SHORT
1117 #ifdef BUILD_IMAGE_USHORT
devel version of antialiased affine tracker
void SetIdentity()
set the elements of this matrix to the identity matrix
void Compute4by4GradientMatrix(KLT_TYPE *gradx, KLT_TYPE *grady, const int hw, const int hh, BIAS::Matrix< KLT_TYPE > &T)
void Compute6by6GradientMatrix(KLT_TYPE *gradx, KLT_TYPE *grady, const int hw, const int hh, BIAS::Matrix< KLT_TYPE > &T)
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
computes and holds the singular value decomposition of a rectangular (not necessarily quadratic) Matr...
virtual int Track_(Vector2< KLT_TYPE > &p1, Vector2< KLT_TYPE > &p2, Vector2< KLT_TYPE > &result, KLT_TYPE &error, int &iter, const Matrix2x2< KLT_TYPE > &AffinePred, Matrix2x2< KLT_TYPE > &AffineResult)
Interface of all tracking algorithms implemented in derived classes.
Matrix< T > Transpose() const
transpose function, storing data destination matrix
double GetBaseLevel(const Vector< double > &apar, bool backdirection)
int TrackAffine_(KLT_TYPE p1[2], KLT_TYPE p2[2], const Matrix2x2< KLT_TYPE > &p2A, KLT_TYPE result[2], Matrix2x2< KLT_TYPE > &resultA, KLT_TYPE &error, int &iter, Matrix< KLT_TYPE > &Cov, KLT_TYPE &mad, KLT_TYPE &msd, bool SimilarityTransformOnly=false, bool ComputeCovariance=true)
track using affine warp
Matrix< T > & newsize(Subscript M, Subscript N)
void GetGradientWinAffine_(const KLT_TYPE &x, const KLT_TYPE &y, const KLT_TYPE &Axx, const KLT_TYPE &Ayx, const KLT_TYPE &Axy, const KLT_TYPE &Ayy, const int halfwidth, const int halfheight, KLT_TYPE *imgdiff, KLT_TYPE *out_gradx, KLT_TYPE *out_grady, const Matrix< double > &Cov)
const T * GetData() const
get the data pointer the member function itself is const (before {..}) because it doesn't change the ...
long int ComputeCovariance(long int NumErrors, long int NumParams, double *Jac, int *Permutation, double &SumOfSquaredErrors, Matrix< double > &Cov)
Compute covariance matrix from Levenberg-Marquardt resulting Jacobian matrix J(x) and permutation mat...
void BilinearRegion1_(KLT_TYPE x, KLT_TYPE y, int hws, const Vector< double > &par, const Matrix< double > &Cov)
Vector< T > & newsize(Subscript N)
success (error < maxerror)
void SetZero()
Sets all values to zero.
no spatial structure is present
int GetInverse(Matrix3x3< T > &inv) const
Matrix inversion: inverts this and stores resulty in argument inv.
affine warp seems degenerated
virtual void EvaluateResult_(KLT_TYPE &mad, KLT_TYPE &msd, Matrix< KLT_TYPE > &cov)
fill in computed residui from Track_
void SetSigma(const double si)
int GaussJordanElimination(BIAS::Matrix< KLT_TYPE > &a, BIAS::Vector< KLT_TYPE > &b)
Maps image src to image sink with affine transformation.
const Vector< double > & GetS() const
return S which is a vector of the singular values of A in descending order.
The image template class for specific storage types.
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
int MapDirect(const Image< InputStorageType > &src, Image< OutputStorageType > &sink)
direct, fast implementation of affine backward mapping with anisotropic filtering, one channel grey only
static std::string toString(const T thenumber, int numzeros=DEFAULT_LEADING_ZEROS)
Converts number to string with leading zeros.
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
void Compute4by1ErrorVector(KLT_TYPE *imgdiff, KLT_TYPE *gradx, KLT_TYPE *grady, const int hw, const int hh, BIAS::Vector< KLT_TYPE > &e)
void Compute6by1ErrorVector(KLT_TYPE *imgdiff, KLT_TYPE *gradx, KLT_TYPE *grady, const int hw, const int hh, BIAS::Vector< KLT_TYPE > &e)
Matrix< double > Invert()
returns pseudoinverse of A = U * S * V^T A^+ = V * S^+ * U^T
Subscript num_rows() const
double NormFrobenius() const
Return Frobenius norm = sqrt(trace(A^t * A)).
void SetAffineTransformation(const double &a11, const double &a12, const double &a21, const double &a22, const double &dx, const double &dy)
set A (source = A * sink) before calling Map()
void GetSystemMatrix(Matrix< T > &dest) const
compute square system matrix dest = A^T * A
TrackerBaseAffine2(bool only4params=false)
void SetZero()
zeroes the image
maxiter is reached and error is above maxerror
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase