1 #include <FeatureDetector/CornerDetectorKLT.hh>
2 #include <Matcher2D/RegionMatcher.hh>
3 #include <Base/Image/Image.hh>
4 #include <Base/Image/ImageIO.hh>
5 #include <Base/Image/ImageConvert.hh>
6 #include <Base/ImageUtils/ImageDraw.hh>
16 int main(
int argc,
char *argv[])
20 cerr << argv[0] <<
" <img 1> <img 2>\n";
24 vector<vector<HomgPoint2D> > p(2);
25 vector<vector<QUAL> > qual(2);
31 for (
int i=0; i<2; i++){
34 cerr <<
"error loading image \""<<argv[1+i]<<
"\"\n";
39 cerr <<
"error converting image \""<<argv[1+i]<<
"\"\n";
42 res = cd.
Detect(grey[i], p[i], qual[i]);
44 cerr <<
"error detecting corners in image \""<<argv[1+i]<<
"\"\n";
50 int height = max(img[0].GetHeight(), img[1].GetHeight());
53 result.
Init(width, height, img[0].GetChannelCount());
58 result.
GetROI()->
SetCorners(img[0].GetWidth(), 0, width, img[1].GetHeight());
62 unsigned p0[2], p1[2], p1s[2];
69 const double min_ncc_val = 0.95;
71 const unsigned char **ida0 =
72 (
const unsigned char **) grey[0].GetImageDataArray();
73 const unsigned char **ida1 =
74 (
const unsigned char **) grey[1].GetImageDataArray();
75 for (
int idx0=0; idx0<(int)p[0].size(); idx0++){
76 p0[0] = (unsigned)rint(p[0][idx0][0]);
77 p0[1] = (unsigned)rint(p[0][idx0][1]);
78 if (p0[0]<hws || p0[0]+hws>=width0 ||
79 p0[1]<hws || p0[1]+hws>=height0){
83 unsigned char col[] = { 255, 255, 255};
87 for (
int idx1=0; idx1<(int)p[1].size(); idx1++){
88 p1[0] = (unsigned)rint(p[1][idx1][0]);
89 p1[1] = (unsigned)rint(p[1][idx1][1]);
90 if (p1[0]<hws || p1[0]+hws>=width1 ||
91 p1[1]<hws || p1[1]+hws>=height1){
96 p1[1]+offset[1], radius, col);
98 int search_region = 1;
99 for (
int y=-search_region; y<=search_region; y++){
100 p1s[1] = (int)(p1[1]) + y;
101 for (
int x=-search_region; x<=search_region; x++){
102 p1s[0] = (int)(p1[0]) + x;
103 if (p1s[0]<hws || p1s[0]+hws>=width1 ||
104 p1s[1]<hws || p1s[1]+hws>=height1){
107 rm.
NCC(p0, p1s, ida0, ida1, hws, ncc_val);
109 if (ncc_val>min_ncc_val){
110 unsigned p1offs[2] = { p1[0]+offset[0], p1[1]+offset[1] };
void SetMinDistance(int mindist)
sets the min distance of features (simple parameter access function - does nothing else) ...
int SetCorners(unsigned UpperLeftX, unsigned UpperLeftY, unsigned LowerRightX, unsigned LowerRightY)
Sets a rectangular region of interest.
void SetMaxNumFeatures(const int maxnum)
void SetColorModel(EColorModel Model)
unsigned int GetWidth() const
virtual void SetMinCornerness(double min_cornerness)
sets minimum cornernes of detectable features
static int CircleCenter(Image< StorageType > &im, unsigned int CenterX, unsigned int CenterY, unsigned int Radius, const StorageType Value[]=NULL)
draws a circular line, either using Value or a good contrast value
ROI * GetROI()
Returns a pointer to the roi object.
static int Line(Image< StorageType > &im, const unsigned int start[2], const unsigned int end[2], const StorageType value[])
lines
unsigned int GetHeight() const
Computes the cornerness as the smaller eigenvalue of the structure tensor matrix. ...
void FillImageWithConstValue(StorageType Value)
fill grey images
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.
Basic functions for CornerMatcher.
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
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...
static int Convert(BIAS::ImageBase &source, BIAS::ImageBase &dest, enum BIAS::ImageBase::EColorModel targetColorModel, bool bPlanar=false)
main general conversion function, calls desired specialized functions, always initializes the destIma...
int Paste2ROI(const ImageBase &Image)
paste Image to current ROI
void NCC(const unsigned int p1[2], const unsigned int p2[2], const StorageType **ida1, const StorageType **ida2, const unsigned int halfwinsize, double &result) const
fast ncc between p1 and p2 without boundary checking Faster specialisation for unsigned char exists b...
virtual int Detect(const Image< StorageType > &image, std::vector< HomgPoint2D > &p, std::vector< QUAL > &quality, std::vector< Matrix2x2< double > > *cov=NULL)
detect corners in a grey image