TestLFonHSGPersistent.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * @file TestLFonHSGPersistent.cpp
  3. * @brief CppUnit-Testcase to create a LFonHSG-Wrapper around an LocalFeature-object. Checks whether this is storable and restorable again.
  4. * @author Alexander Freytag
  5. * @date 12-02-2014 ( dd-mm-yyyy )
  6. */
  7. #ifdef NICE_USELIB_CPPUNIT
  8. // STL includes
  9. // NICE-core includes
  10. // gp-hik-core includes
  11. #include "TestLFonHSGPersistent.h"
  12. using namespace std; //C basics
  13. using namespace NICE; // nice-core
  14. const bool verboseStartEnd = true;
  15. const bool verbose = true;
  16. CPPUNIT_TEST_SUITE_REGISTRATION( TestLFonHSGPersistent );
  17. void TestLFonHSGPersistent::setUp() {
  18. }
  19. void TestLFonHSGPersistent::tearDown() {
  20. }
  21. void TestLFonHSGPersistent::testPersistentMethodsForLFonHSG()
  22. {
  23. if (verboseStartEnd)
  24. std::cerr << "================== TestLFonHSGPersistent::testPersistentMethodsForLFonHSG ===================== " << std::endl;
  25. NICE::Config conf;
  26. conf.sS( "GenericLFSelection", "localfeature_type", "LFonHSG" );
  27. conf.sS( "LFonHSG", "localfeature_type", "LocalFeatureSift" );
  28. OBJREC::LocalFeatureRepresentation * lfrep;
  29. lfrep = OBJREC::GenericLFSelection::selectLocalFeatureRep ( &conf, "GenericLFSelection");
  30. // TEST STORING ABILITIES
  31. if ( verbose )
  32. std::cerr << " TEST STORING ABILITIES FOR LFonHSG Wrapper" << std::endl;
  33. std::string s_destination_save ( "myLFonHSG.txt" );
  34. std::filebuf fbOut;
  35. fbOut.open ( s_destination_save.c_str(), ios::out );
  36. std::ostream os (&fbOut);
  37. //
  38. lfrep->store( os );
  39. //
  40. fbOut.close();
  41. // TEST RESTORING ABILITIES
  42. if ( verbose )
  43. std::cerr << " TEST RESTORING ABILITIES FOR LFonHSG Wrapper" << std::endl;
  44. OBJREC::LocalFeatureRepresentation * lfrepRestore = NULL;
  45. std::string s_destination_load ( "myLFonHSG.txt" );
  46. std::filebuf fbIn;
  47. fbIn.open ( s_destination_load.c_str(), ios::in );
  48. std::istream is (&fbIn);
  49. //
  50. OBJREC::GenericLFSelection::restoreLocalFeatureRep ( lfrepRestore, is );
  51. //
  52. fbIn.close();
  53. // currently, we have no possibility to actually verify that the restore-operation was successfull, i.e.,
  54. // it returned an object identical to the stored one.
  55. // However, if we reached this point, at least something went right, so we should be happy...
  56. if (verboseStartEnd)
  57. std::cerr << "================== TestLFonHSGPersistent::testPersistentMethodsForLFonHSG done ===================== " << std::endl;
  58. }
  59. #endif