33 #include <Matcher2D/CornerMatcher.hh>
34 #include <Base/Image/Image.hh>
35 #include <Base/ImageUtils/ImageDraw.hh>
36 #include <Base/Image/ImageIO.hh>
37 #include <Base/Geometry/HomgPoint2D.hh>
38 #include <Base/Debug/TimeMeasure.hh>
39 #include <Filter/Gradient.hh>
47 int main(
int argc,
char*argv[])
52 double correlation, mincorrelation=1.0, error, errorsum=0.0;
53 unsigned int halfsearchwinsize=2;
54 unsigned int uip[2], rectsize=7;
55 unsigned int halfnccwinsize=3;
56 unsigned int newim, oldim, res;
61 bool UseLeastSquaresParabola=
false;
77 cerr << argv[0] <<
" : <x-coo> <y-coo> <image> <image> ..."<< endl;
81 p[0][0]=atof(argv[1]);
82 p[0][1]=atof(argv[2]);
86 BIASERR(
"error loading image "<<argv[3]);
92 while (counter < argc-1){
94 newim=(newim==0)?(1):(0);
95 oldim=(newim==0)?(1):(0);
98 BIASERR(
"error loading image "<<argv[counter]);
102 cout <<
"--------------- newim: " << argv[counter]
103 <<
" --- oldim: " << argv[counter-1] << endl;
107 if (debug) cerr << appdata.
stag <<
" : "<<appdata.
sdata<<endl;
108 sscanf(appdata.
sdata.c_str(),
"[ %lf %lf %lf ]",
109 &realpoint[0], &realpoint[1], &realpoint[2]);
113 if (debug) cerr <<
"realpoint is at "<<realpoint<<endl;
115 BIASERR(
"cannot find HomgPoint2D in meta data");
119 if (p[oldim][0]<=halfnccwinsize+3 ||
120 p[oldim][1]<=halfnccwinsize+3 ||
121 p[oldim][0]+halfnccwinsize+3>=im[oldim].GetWidth()-1 ||
122 p[oldim][1]+halfnccwinsize+3>=im[oldim].GetHeight()-1){
123 cout <<
"point ("<<p[oldim][0]<<
", "<<p[oldim][1]<<
") too close to "
124 <<
"image border, stopping"<<endl;
130 if ((res=matcher.
NCCSearch(p[oldim], p[oldim], im[oldim], im[newim],
131 halfnccwinsize, halfsearchwinsize, p[newim],
132 mincorrelation, correlation))!=0){
133 BIASERR(
"error in NCCSearch");
137 BIASERR(
"error matching");
142 cerr << p[oldim] <<
" NCC -> " << p[newim]
143 <<
" ("<<correlation<<
") Parabola -> ";
145 if (UseLeastSquaresParabola){
146 if ((res=matcher.
ParabolaNCC5(p[oldim], p[newim], im[oldim], im[newim],
147 halfnccwinsize, p[newim]))!=0){
148 BIASERR(
"error in ParabolaNCC");
152 if ((res=matcher.
ParabolaNCC(p[oldim], p[newim], im[oldim], im[newim],
153 halfnccwinsize, p[newim]))!=0){
154 BIASERR(
"error in ParabolaNCC");
165 cerr << p[newim] << endl;
168 BIASERR(
"error matching");
175 cout << setw(2) << counter-3 <<
" : (" << p[oldim][0]<<
", "<<p[oldim][1]
176 <<
") -> ("<< p[newim][0]<<
", "<<p[newim][1]<<
") corr: "<<correlation
177 <<
" real: ("<<realpoint[0]<<
", "<<realpoint[1]
178 <<
") error: "<<error<<endl;
181 uip[0]=(
unsigned int)rint(p[newim][0]);
182 uip[1]=(
unsigned int)rint(p[newim][1]);
193 cerr <<
"errorsum over "<<counter-3<<
" images: "<<errorsum<<endl
194 <<
" mean error "<<errorsum/(double)(counter-3)<<endl;
196 cerr <<
"Parabola approximation over "<<argc-3<<
" images took "
198 <<
"\n this is equal to "<<timer.
GetUserTime()/double(argc-3)
199 <<
" ms per image and corner" << endl;
void Print(std::ostream &os=std::cout) const
std::string stag
the tag as given in ascii meta data
const T * GetData() const
get the data pointer the member function itself is const (before {..}) because it doesn't change the ...
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
HOMGPOINT2D_TYPE Distance(const HomgPoint2D &point) const
int length
number of bytes used by the data block
std::string sdata
the data as given in ascii meta data
int GetDebugLevel() const
char * data
pointer to block of data
int NCCSearch(const HomgPoint2D &p1, const HomgPoint2D &p2, const Image< StorageType > &im1, const Image< StorageType > &im2, const unsigned int halfnccwinsizeconst, const unsigned int halfsearchwinsize, HomgPoint2D &resultpoint, const double mincorrelation, double &result)
wrapper for RegionMatcher::NCCSearchOdd/NCCSearchEven, does boundary checks and casts ...
void SetDebugLevel(const long int lv)
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.
enum TAppData tag
The tag defines the type of data, e.g.
static int RectangleCenter(Image< StorageType > &im, const int x, const int y, const int size, const StorageType value[])
Draws the rectangle around X, Y with Size and Value[i] in channel i.
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...
int ParabolaNCC(const HomgPoint2D &p1, const HomgPoint2D &p2, const Image< StorageType > &im1, const Image< StorageType > &im2, const unsigned int halfwinsize, HomgPoint2D &result) const
wrapper with range checking for RegionMatcher::KLT for a description see RegionMatcher::KLT gradientb...
int ParabolaNCC5(const HomgPoint2D &p1, const HomgPoint2D &p2, const Image< StorageType > &im1, const Image< StorageType > &im2, const unsigned int halfwinsize, HomgPoint2D &result) const
wrapper for RegionMatcher::ParabolaNCC5
class with various functions to detect corresponding image points.
double GetUserTime() const
return user time (=system usage time) in msec JW For Win32: user-time is the sum over all processes o...
class TimeMeasure contains functions for timing real time and cpu time.
this is a chunk of metadata, also see MetaData