TestGenericLocalFeatureSelectionPersistent.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * @file TestGenericLocalFeatureSelectionPersistent.cpp
  3. * @brief CppUnit-Testcase to create a LocalFeatureRepresentation object via GenericLocalFeatureSelection, to store it, and to restore it 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 "TestGenericLocalFeatureSelectionPersistent.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( TestGenericLocalFeatureSelectionPersistent );
  17. void TestGenericLocalFeatureSelectionPersistent::setUp() {
  18. }
  19. void TestGenericLocalFeatureSelectionPersistent::tearDown() {
  20. }
  21. void TestGenericLocalFeatureSelectionPersistent::testPersistentMethods()
  22. {
  23. if (verboseStartEnd)
  24. std::cerr << "================== TestGenericLocalFeatureSelectionPersistent::testPersistentMethods ===================== " << std::endl;
  25. NICE::Config conf;
  26. conf.sS( "GenericLocalFeatureSelection", "localfeature_type", "LocalFeatureSift" );
  27. OBJREC::LocalFeature * lf;
  28. lf = OBJREC::GenericLocalFeatureSelection::selectLocalFeature ( &conf, "GenericLocalFeatureSelection");
  29. // TEST STORING ABILITIES
  30. if ( verbose )
  31. std::cerr << " TEST STORING ABILITIES FOR STANDARD LOCALFEATURE" << std::endl;
  32. std::string s_destination_save ( "myLocalFeatureSelection.txt" );
  33. std::filebuf fbOut;
  34. fbOut.open ( s_destination_save.c_str(), ios::out );
  35. std::ostream os (&fbOut);
  36. //
  37. lf->store( os );
  38. //
  39. fbOut.close();
  40. // TEST RESTORING ABILITIES
  41. if ( verbose )
  42. std::cerr << " TEST RESTORING ABILITIES FOR STANDARD LOCALFEATURE" << std::endl;
  43. OBJREC::LocalFeature * lfRestore = NULL;
  44. std::string s_destination_load ( "myLocalFeatureSelection.txt" );
  45. std::filebuf fbIn;
  46. fbIn.open ( s_destination_load.c_str(), ios::in );
  47. std::istream is (&fbIn);
  48. //
  49. OBJREC::GenericLocalFeatureSelection::restoreLocalFeature ( lfRestore, is );
  50. //
  51. fbIn.close();
  52. // currently, we have no possibility to actually verify that the restore-operation was successfull, i.e.,
  53. // it returned an object identical to the stored one.
  54. // However, if we reached this point, at least something went right, so we should be happy...
  55. if (verboseStartEnd)
  56. std::cerr << "================== TestGenericLocalFeatureSelectionPersistent::testPersistentMethods done ===================== " << std::endl;
  57. }
  58. #endif