12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- /**
- * @file LFReadCache.cpp
- * @brief read local features from file
- * @author Erik Rodner
- * @date 02/14/2008
- */
- #include <iostream>
- #include <fstream>
- #include "vislearning/baselib/Globals.h"
- #include "core/basics/StringTools.h"
- #include "core/basics/FileMgt.h"
- #include "vislearning/features/localfeatures/LFReadCache.h"
- using namespace OBJREC;
- using namespace std;
- using namespace NICE;
- LFReadCache::LFReadCache ( const Config *conf,
- const LocalFeatureRepresentation *_lfrep,
- int _numFeatures,
- const std::string & _section ) : lfrep ( _lfrep )
- {
- //srand(time(NULL));
- numFeatures = _numFeatures;
- cachedir = conf->gS ( _section, "root" );
- cachemode = Globals::getCacheMode ( conf->gS ( _section, "mode", "cat" ) );
- std::string descFormat_s = conf->gS ( _section, "descriptor_format", "binary_double" );
- if ( descFormat_s == "binary_double" )
- descFormat = VVector::FILEFORMAT_BINARY_DOUBLE;
- else if ( descFormat_s == "binary_uchar" )
- descFormat = VVector::FILEFORMAT_BINARY_CHAR;
- else if ( descFormat_s == "text_line" )
- descFormat = VVector::FILEFORMAT_LINE;
- else if ( ( descFormat_s == "text_nice" ) || ( descFormat_s == "text_ice" ) )
- descFormat = VVector::FILEFORMAT_NICE;
- else
- fthrow ( Exception, "Format " << descFormat_s << " is unknown." );
- }
- LFReadCache::~LFReadCache()
- {
- }
- int LFReadCache::getDescSize () const
- {
- if ( lfrep == NULL ) {
- fthrow ( Exception, "Unable to get descriptor size! (cache mode)" );
- return -1;
- } else {
- return lfrep->getDescSize();
- }
- }
- int LFReadCache::extractFeatures ( const NICE::ColorImage & img,
- VVector & features,
- VVector & positions ) const
- {
- return extractFeaturesTemplate<NICE::ColorImage> ( img, features, positions );
- }
- int LFReadCache::extractFeatures ( const NICE::Image & img,
- VVector & features,
- VVector & positions ) const
- {
- return extractFeaturesTemplate<NICE::Image> ( img, features, positions );
- }
- void LFReadCache::visualize ( NICE::Image & img,
- const NICE::Vector & feature ) const
- {
- lfrep->visualize ( img, feature );
- }
- void LFReadCache::visualizeFeatures ( NICE::Image & mark,
- const VVector & positions,
- size_t color ) const
- {
- lfrep->visualizeFeatures ( mark, positions, color );
- }
|