See TestData/affine in cvs for generating test images. , GradientGaussAsymmetric
#include <Matcher2D/TrackerBaseSimple.hh>
#include <Base/Image/Image.hh>
#include <Base/ImageUtils/ImageDraw.hh>
#include <Base/Image/ImageIO.hh>
#include <Base/Image/ImageConvert.hh>
#include <Base/Geometry/HomgPoint2D.hh>
#include <Base/Debug/TimeMeasure.hh>
#include <Filter/GradientSobel3x3.hh>
#include <Filter/GradientGauss.hh>
#include <Filter/GradientGaussAsymmetric.hh>
#include <Filter/Binomial.hh>
#include <iostream>
#include <iomanip>
using namespace BIAS;
using namespace std;
#define StorageType float
{
BIASERR("error loading image "<<name);
return -1;
}
BIASERR("error converting image "<<name);
return -2;
}
BIASERR("error converting image to grey "<<name);
return -3;
}
}
return 0;
}
const string& name)
{
unsigned uip[2], radius=1;
unsigned char color[]={255,0,0};
float cov_scale=1e5;
bool draw_cov=true;
BIASERR("error converting image to unsigned char "<<name);
BIASABORT;
}
BIASERR("error converting image to RGB "<<name);
BIASABORT;
}
}
uip[0]=(unsigned int)rint(p[0]);
uip[1]=(unsigned int)rint(p[1]);
if (draw_cov){
double center[2], a[2], b[2], eva, evb;
center[0]=p[0];
center[1]=p[1];
cout << eva<<", "<<evb<<"\n";
a[0]=na[0]*eva*cov_scale;
a[1]=na[1]*eva*cov_scale;
b[0]=nb[0]*evb*cov_scale;
b[1]=nb[1]*evb*cov_scale;
}
cout << "wrote "<<name<<endl;
}
int main(int argc, char*argv[])
{
int argind = 1;
if (argc-argind<4 || argind<1)
{
cerr << argv[0] << " : <x-coo> <y-coo> <image> <image> ..."<< endl;
return -1;
}
p[0][2] = p[1][2] = 1.0;
p[0][0] = atof(argv[argind]);
p[0][1] = atof(argv[argind+1]);
cout << "attempt to track point " << p[0] << endl;
if (LoadImage(argv[argind+2], im[0]) != 0)
{
BIASERR("error loading image " << argv[argind+2]);
return -1;
}
int oldim = 0;
int newim = 1;
for (int counter = argind+3; counter < argc-1; counter++)
{
if (LoadImage(argv[counter], im[newim]) != 0)
{
BIASERR("Failed to load image " << argv[counter]);
return -1;
}
2, 4, 2,
1, 2, 1);
-2, 0, 2,
-1, 0, 1);
0, 0, 0,
1, 2, 1);
tracker.
Init(im[oldim], im[newim],
fmLowpass, fmGradX, fmGradY);
KLT_TYPE error, residuumMAD, residuumMSD;
int iter;
int result = tracker.
Track(p[oldim], p[oldim], p[newim],
error, iter, residuumMAD,
residuumMSD, cov);
cout << setw(3)
<< counter-3 << ": "
<< "result: " << result << ", "
<< p[oldim] << " -> " << p[newim] << ", "
<< "residuumMAD: " << residuumMAD << ", "
<< "residuumMSD: " << residuumMSD << endl;
ostringstream name;
name << "track-"<<setw(4)<<setfill('0')<<counter-argind<<".mip";
Draw(im[newim], p[newim], cov, name.str());
swap(newim, oldim);
}
return 0;
}