testSift.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * @file testSift.cpp
  3. * @brief test sift implementation
  4. * @author Björn Fröhlich
  5. * @date 06/08/2010
  6. */
  7. #include "objrec/nice.h"
  8. #include "objrec/baselib/Config.h"
  9. #include "objrec/features/localfeatures/LocalFeatureSift.h"
  10. #include "objrec/features/localfeatures/LocalFeatureOpponnentSift.h"
  11. #include "objrec/features/localfeatures/LocalFeatureRGBSift.h"
  12. #include "objrec/features/localfeatures/LFColorSande.h"
  13. #include "objrec/features/localfeatures/LocalFeatureLFInterface.h"
  14. #include "objrec/baselib/Globals.h"
  15. using namespace OBJREC;
  16. using namespace NICE;
  17. using namespace std;
  18. int main (int argc, char **argv)
  19. {
  20. if(argc < 1)
  21. {
  22. cerr << "Bitte Bild angeben" << endl;
  23. return -1;
  24. }
  25. string filename;
  26. filename += argv[1];
  27. Image img(filename);
  28. ColorImage cimg(filename);
  29. Globals::setCurrentImgFN ( filename );
  30. Config *conf = new Config();
  31. string section = "SIFT";
  32. conf->sS(section, "scales", "1");
  33. conf->sI(section, "descriptor_size", 128);
  34. conf->sI(section, "grid", 100);
  35. conf->sB(section, "usegrid", true);
  36. conf->sS(section, "params", "--descriptor sift");
  37. LocalFeatureRepresentation *cSIFT = new LFColorSande ( conf, section );
  38. LocalFeature *lSIFT = new LocalFeatureLFInterface(conf, cSIFT);
  39. //LocalFeature *oSIFT = new LocalFeatureSift (conf);
  40. LocalFeatureOpponnentSift *oSIFT = new LocalFeatureOpponnentSift (conf);
  41. VVector features1;
  42. VVector features2;
  43. VVector positions;
  44. //cSIFT->extractFeatures ( cimg, features1, positions );
  45. lSIFT->getDescriptors( img, positions, features1 );
  46. //showImage(cimg);
  47. oSIFT->getDescriptors( img, positions, features2 );
  48. cout << "f1.size: " << features1.size() << " f2.size: " << features2.size() << " p.size() " << positions.size() << endl;
  49. double max[2] = {0.0,0.0};
  50. int feat = 1;
  51. for(int i = 0; i < (int)features1[feat].size(); i++)
  52. {
  53. max[0] = std::max(max[0], features1[feat][i]);
  54. max[1] = std::max(max[1], features2[feat][i]);
  55. cout << features1[feat][i] << "\t" << features2[feat][i] << endl;
  56. }
  57. cout << "max: " << max[0] << "\t" << max[1] << endl;
  58. return 0;
  59. }