From: <ste...@us...> - 2007-08-11 10:25:43
|
Revision: 2370 http://hugin.svn.sourceforge.net/hugin/?rev=2370&view=rev Author: stereo_sl Date: 2007-08-11 03:25:40 -0700 (Sat, 11 Aug 2007) Log Message: ----------- - improved matching of descriptors using second nearest neighbour ratio Modified Paths: -------------- gsoc07_featuredetection/HessianDetector.cpp gsoc07_featuredetection/main.cpp Modified: gsoc07_featuredetection/HessianDetector.cpp =================================================================== --- gsoc07_featuredetection/HessianDetector.cpp 2007-08-10 12:06:27 UTC (rev 2369) +++ gsoc07_featuredetection/HessianDetector.cpp 2007-08-11 10:25:40 UTC (rev 2370) @@ -21,6 +21,7 @@ #include <iostream> #include <stdlib.h> #include <math.h> +#include <limits> #include "HessianDetector.h" using namespace std; @@ -38,12 +39,13 @@ determinants.resize(this->image->getHeightBW()); maximas.resize(this->image->getHeightBW()); + const int iMax=std::numeric_limits<int>::max(); for(int i=0;i<this->image->getHeightBW();i++) { maximas[i].resize(this->image->getWidthBW()); determinants[i].resize(this->image->getWidthBW()); for(int j=0; j<this->image->getWidthBW();j++) { maximas[i][j] =0 ; - determinants[i][j]=-99999; + determinants[i][j]=iMax; } } } @@ -224,6 +226,8 @@ int height = this->image->getHeightBW()-1; int width = this->image->getWidthBW()-1; + const int iMax=std::numeric_limits<int>::max(); + int xEnd=height-60; int yEnd=width-60; @@ -233,7 +237,7 @@ //calculate the determinants around the pixel, because of non-maxima suppression for(int k=-1;k<2;k++) { for(int l=-1; l<2;l++) { - if(determinants[i+k][j+l]==-99999) { //if determinant for that pixel hasn't been set + if(determinants[i+k][j+l]==iMax) { //if determinant for that pixel hasn't been set _calculateMaxDet(i+k,j+l); //calculate it } } Modified: gsoc07_featuredetection/main.cpp =================================================================== --- gsoc07_featuredetection/main.cpp 2007-08-10 12:06:27 UTC (rev 2369) +++ gsoc07_featuredetection/main.cpp 2007-08-11 10:25:40 UTC (rev 2370) @@ -36,6 +36,7 @@ #include "Image.h" #include "HessianDetector.h" #include "Descriptor.h" +#include <limits> using namespace std; @@ -115,41 +116,47 @@ vector<vector<double> >* descriptors1=d1.getDescriptors(); vector<vector<double> >::iterator iter1 = (*descriptors1).begin(); - vector<vector<double> >* descriptors2=d2.getDescriptors(); int pointCount=0; + int max; + int maxId; //position int the vector of the nearest neighbour while( iter1 != (*descriptors1).end()) { - vector<double> current1 = *iter1; vector<vector<double> >::iterator iter2 =(*descriptors2).begin(); - int max=1; - int maxId=0; + max=1; + maxId=0; + vector<double> current2 = *iter2; double distance=getDistance(¤t1,¤t2); iter2++; - double diff=distance; + double diff=distance; //nearest neighbour + double diff2=std::numeric_limits<double>::max(); //second nearest neighbour while( iter2 != (*descriptors2).end()) { current2 = *iter2; distance=getDistance(¤t1,¤t2); + if(distance<diff) { + diff2=diff; diff=distance; maxId=max; + } else if(distance<diff2) { + //set the new second nearest neighbour + diff2=distance; } max++; - iter2++; } - cout << diff<< "\n"; - if(diff<5000000) { //print corresponding points - im1.drawCircle((*interestPoints1)[pointCount][1],(*interestPoints1)[pointCount][0],10); - im2.drawCircle((*interestPoints2)[maxId][1],(*interestPoints2)[maxId][0],10); + if(diff<(0.5*diff2)) { + im1.drawCircle((*interestPoints1)[pointCount][1],(*interestPoints1)[pointCount][0],10); + im2.drawCircle((*interestPoints2)[maxId][1],(*interestPoints2)[maxId][0],10); } + iter1++; pointCount++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |