32 #include <Matcher2D/TrackerBaseSimple.hh>
33 #include <Base/Image/Image.hh>
34 #include <Base/ImageUtils/ImageDraw.hh>
35 #include <Base/Image/ImageIO.hh>
36 #include <Base/Image/ImageConvert.hh>
37 #include <Base/Geometry/HomgPoint2D.hh>
38 #include <Base/Debug/TimeMeasure.hh>
39 #include <Filter/GradientSobel3x3.hh>
40 #include <Filter/GradientGauss.hh>
41 #include <Filter/GradientGaussAsymmetric.hh>
42 #include <Filter/Binomial.hh>
52 #define StorageType float
62 BIASERR(
"error loading image "<<name);
67 BIASERR(
"error converting image "<<name);
73 BIASERR(
"error converting image to grey "<<name);
87 unsigned uip[2], radius=1;
88 unsigned char color[]={255,0,0};
95 BIASERR(
"error converting image to unsigned char "<<name);
102 BIASERR(
"error converting image to RGB "<<name);
107 uip[0]=(
unsigned int)rint(p[0]);
108 uip[1]=(
unsigned int)rint(p[1]);
114 double center[2], a[2], b[2], eva, evb;
120 cout << eva<<
", "<<evb<<
"\n";
121 a[0]=na[0]*eva*cov_scale;
122 a[1]=na[1]*eva*cov_scale;
123 b[0]=nb[0]*evb*cov_scale;
124 b[1]=nb[1]*evb*cov_scale;
126 Ellipse(dim, center, a, b, color);
131 cout <<
"wrote "<<name<<endl;
135 int main(
int argc,
char*argv[])
144 if (argc-argind<4 || argind<1)
146 cerr << argv[0] <<
" : <x-coo> <y-coo> <image> <image> ..."<< endl;
152 p[0][2] = p[1][2] = 1.0;
153 p[0][0] = atof(argv[argind]);
154 p[0][1] = atof(argv[argind+1]);
155 cout <<
"attempt to track point " << p[0] << endl;
159 if (LoadImage(argv[argind+2], im[0]) != 0)
161 BIASERR(
"error loading image " << argv[argind+2]);
169 for (
int counter = argind+3; counter < argc-1; counter++)
172 if (LoadImage(argv[counter], im[newim]) != 0)
174 BIASERR(
"Failed to load image " << argv[counter]);
195 tracker.
Init(im[oldim], im[newim],
196 fmLowpass, fmGradX, fmGradY);
199 KLT_TYPE error, residuumMAD, residuumMSD;
202 int result = tracker.
Track(p[oldim], p[oldim], p[newim],
203 error, iter, residuumMAD,
208 <<
"result: " << result <<
", "
209 << p[oldim] <<
" -> " << p[newim] <<
", "
210 <<
"residuumMAD: " << residuumMAD <<
", "
211 <<
"residuumMSD: " << residuumMSD << endl;
215 name <<
"track-"<<setw(4)<<setfill(
'0')<<counter-argind<<
".mip";
216 Draw(im[newim], p[newim], cov, name.str());
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
void Init(Image< StorageType > &im1, Image< StorageType > &im2, Image< StorageType > &gradx1, Image< StorageType > &grady1, Image< StorageType > &gradx2, Image< StorageType > &grady2)
Prepare for tracking with prefiltered images.
static int CircleCenterFilled(Image< StorageType > &im, unsigned int CenterX, unsigned int CenterY, unsigned int Radius, const StorageType Value[])
draws a filled circle using Value
int Track(HomgPoint2D &p1, HomgPoint2D &p2, HomgPoint2D &p2tracked, KLT_TYPE &error, int &iter, KLT_TYPE &residuumMAD, KLT_TYPE &residuumMSD, Matrix< KLT_TYPE > &cov, const Matrix2x2< KLT_TYPE > &AffinePred=Matrix2x2< KLT_TYPE >(MatrixIdentity), Matrix2x2< KLT_TYPE > *AffineResult=NULL)
Calculates correspondence from image1 to image2.
static int ConvertST(const BIAS::ImageBase &source, BIAS::ImageBase &dest, ImageBase::EStorageType targetST)
Function to convert the storage type of images e.g.
static int Ellipse(Image< StorageType > &im, double center[2], double a[2], double b[2], const StorageType Value[])
draws an ellipse at center with half axes a and b
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
color values, 3 channels, order: red,green,blue
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.
is a 'fixed size' quadratic matrix of dim.
int EigenvalueDecomposition(T &value1, Vector2< T > &vector1, T &value2, Vector2< T > &vector2) const
Eigenvalue decomposition.
enum EColorModel GetColorModel() const
matrix class with arbitrary size, indexing is row major.
static int Load(const std::string &FileName, ImageBase &img)
first tries a call to Read MIP image and if that fails, tries to Import Image with all other availabl...
(8bit) unsigned char image storage type
void SetMetaData(const MetaData &m)
A filter mask (or a kernel) used for convolution.
This is the base class for images in BIAS.
static int ToRGB(const Image< StorageType > &source, Image< StorageType > &dest)
Create a RGB converted copy of source image in this.
static int ToGrey(const ImageBase &source, ImageBase &dest)
wrapper for the templated function ToGrey