/** * @file TestGenericLFSelectionPersistent.cpp * @brief CppUnit-Testcase to create a LocalFeatureRepresentation object via GenericLFSelection, to store it, and to restore it again. * @author Alexander Freytag * @date 10-02-2014 ( dd-mm-yyyy ) */ #ifdef NICE_USELIB_CPPUNIT // STL includes // NICE-core includes // gp-hik-core includes #include "TestGenericLFSelectionPersistent.h" using namespace std; //C basics using namespace NICE; // nice-core const bool verboseStartEnd = true; const bool verbose = true; CPPUNIT_TEST_SUITE_REGISTRATION( TestGenericLFSelectionPersistent ); void TestGenericLFSelectionPersistent::setUp() { } void TestGenericLFSelectionPersistent::tearDown() { } void TestGenericLFSelectionPersistent::testPersistentMethods() { if (verboseStartEnd) std::cerr << "================== TestGenericLFSelectionPersistent::testPersistentMethods ===================== " << std::endl; NICE::Config conf; conf.sS( "GenericLFSelection", "localfeature_type", "sift" ); OBJREC::LocalFeatureRepresentation * lfrep; lfrep = OBJREC::GenericLFSelection::selectLocalFeatureRep ( &conf, "GenericLFSelection"); // TEST STORING ABILITIES if ( verbose ) std::cerr << " TEST STORING ABILITIES " << std::endl; std::string s_destination_save ( "myLFSelection.txt" ); std::filebuf fbOut; fbOut.open ( s_destination_save.c_str(), ios::out ); std::ostream os (&fbOut); // lfrep->store( os ); // fbOut.close(); // TEST RESTORING ABILITIES if ( verbose ) std::cerr << " TEST RESTORING ABILITIES " << std::endl; OBJREC::LocalFeatureRepresentation * lfrepRestore = NULL; std::string s_destination_load ( "myLFSelection.txt" ); std::filebuf fbIn; fbIn.open ( s_destination_load.c_str(), ios::in ); std::istream is (&fbIn); // OBJREC::GenericLFSelection::restoreLocalFeatureRep ( lfrepRestore, is ); // fbIn.close(); // currently, we have no possibility to actually verify that the restore-operation was successfull, i.e., // it returned an object identical to the stored one. // However, if we reached this point, at least something went right, so we should be happy... // final clean up -- don't waste memory if ( lfrep != NULL ) delete lfrep; if ( lfrepRestore != NULL ) delete lfrepRestore; if (verboseStartEnd) std::cerr << "================== TestGenericLFSelectionPersistent::testPersistentMethods done ===================== " << std::endl; } #endif