1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /**
- * @file LFReadCache.cpp
- * @brief read local features from file
- * @author Erik Rodner
- * @date 02/14/2008
- */
- #include <vislearning/nice.h>
- #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 ) : lfrep(_lfrep)
- {
- //srand(time(NULL));
- numFeatures = _numFeatures;
- cachedir = conf->gS("cache", "root");
- cachemode = Globals::getCacheMode ( conf->gS("cache", "mode", "cat") );
-
- std::string descFormat_s = conf->gS("cache", "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 );
- }
|