|
@@ -1,4 +1,4 @@
|
|
|
-/**
|
|
|
+/**
|
|
|
* @file LFWriteCache.cpp
|
|
|
* @brief read local features from file
|
|
|
* @author Erik Rodner
|
|
@@ -28,21 +28,21 @@ using namespace NICE;
|
|
|
|
|
|
|
|
|
|
|
|
-LFWriteCache::LFWriteCache( const Config *conf,
|
|
|
- const LocalFeatureRepresentation *_lfrep) : lfrep(_lfrep)
|
|
|
+LFWriteCache::LFWriteCache ( const Config *conf,
|
|
|
+ const LocalFeatureRepresentation *_lfrep ) : lfrep ( _lfrep )
|
|
|
{
|
|
|
- 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_ice" )
|
|
|
- descFormat = VVector::FILEFORMAT_NICE;
|
|
|
+ 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_ice" )
|
|
|
+ descFormat = VVector::FILEFORMAT_NICE;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -52,76 +52,76 @@ LFWriteCache::~LFWriteCache()
|
|
|
|
|
|
int LFWriteCache::getDescSize () const
|
|
|
{
|
|
|
- return lfrep->getDescSize();
|
|
|
+ return lfrep->getDescSize();
|
|
|
}
|
|
|
|
|
|
-int LFWriteCache::extractFeatures ( const NICE::Image & img,
|
|
|
- VVector & features,
|
|
|
- VVector & positions) const
|
|
|
+int LFWriteCache::extractFeatures ( const NICE::Image & img,
|
|
|
+ VVector & features,
|
|
|
+ VVector & positions ) const
|
|
|
{
|
|
|
- std::string filename = Globals::getCacheFilename( cachedir, cachemode );
|
|
|
-
|
|
|
- int ret = lfrep->extractFeatures ( img, features, positions );
|
|
|
- std::string filename_desc = filename + ".desc";
|
|
|
- std::string filename_pos = filename + ".key";
|
|
|
-
|
|
|
- struct stat dummy;
|
|
|
- if ( stat ( filename_desc.c_str(), &dummy ) < 0 )
|
|
|
- {
|
|
|
- fprintf (stderr, "features: %d, positions: %d\n", (int)features.size(),
|
|
|
- (int)positions.size() );
|
|
|
- if ( features.size() > 0 )
|
|
|
- fprintf (stderr, "feature dimension: %d %d\n", features[0].size(), lfrep->getDescSize() );
|
|
|
- features.save ( filename_desc, descFormat );
|
|
|
- positions.save ( filename_pos, VVector::FILEFORMAT_LINE );
|
|
|
- } else {
|
|
|
- fprintf (stderr, "description file %s exists !\n", filename_desc.c_str());
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- return ret;
|
|
|
+ std::string filename = Globals::getCacheFilename ( cachedir, cachemode );
|
|
|
+
|
|
|
+ int ret = lfrep->extractFeatures ( img, features, positions );
|
|
|
+ std::string filename_desc = filename + ".desc";
|
|
|
+ std::string filename_pos = filename + ".key";
|
|
|
+
|
|
|
+ struct stat dummy;
|
|
|
+ if ( stat ( filename_desc.c_str(), &dummy ) < 0 )
|
|
|
+ {
|
|
|
+ fprintf ( stderr, "features: %d, positions: %d\n", ( int ) features.size(),
|
|
|
+ ( int ) positions.size() );
|
|
|
+ if ( features.size() > 0 )
|
|
|
+ fprintf ( stderr, "feature dimension: %d %d\n", features[0].size(), lfrep->getDescSize() );
|
|
|
+ features.save ( filename_desc, descFormat );
|
|
|
+ positions.save ( filename_pos, VVector::FILEFORMAT_LINE );
|
|
|
+ } else {
|
|
|
+ fprintf ( stderr, "description file %s exists !\n", filename_desc.c_str() );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
-int LFWriteCache::extractFeatures ( const NICE::ColorImage & img,
|
|
|
- VVector & features,
|
|
|
- VVector & positions) const
|
|
|
+int LFWriteCache::extractFeatures ( const NICE::ColorImage & img,
|
|
|
+ VVector & features,
|
|
|
+ VVector & positions ) const
|
|
|
{
|
|
|
- std::string filename = Globals::getCacheFilename( cachedir, cachemode );
|
|
|
-
|
|
|
- int ret = lfrep->extractFeatures ( img, features, positions );
|
|
|
- std::string filename_desc = filename + ".desc";
|
|
|
- std::string filename_pos = filename + ".key";
|
|
|
-
|
|
|
- struct stat dummy;
|
|
|
-
|
|
|
- if ( stat ( filename_desc.c_str(), &dummy ) < 0 )
|
|
|
- {
|
|
|
- fprintf (stderr, "features: %d, positions: %d\n", (int)features.size(),
|
|
|
- (int)positions.size() );
|
|
|
- if ( features.size() > 0 )
|
|
|
- fprintf (stderr, "feature dimension: %d %d\n", features[0].size(), lfrep->getDescSize() );
|
|
|
- features.save ( filename_desc, descFormat );
|
|
|
- positions.save ( filename_pos, VVector::FILEFORMAT_LINE );
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- fprintf (stderr, "description file %s exists !\n", filename_desc.c_str());
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- return ret;
|
|
|
+ std::string filename = Globals::getCacheFilename ( cachedir, cachemode );
|
|
|
+
|
|
|
+ int ret = lfrep->extractFeatures ( img, features, positions );
|
|
|
+ std::string filename_desc = filename + ".desc";
|
|
|
+ std::string filename_pos = filename + ".key";
|
|
|
+
|
|
|
+ struct stat dummy;
|
|
|
+
|
|
|
+ if ( stat ( filename_desc.c_str(), &dummy ) < 0 )
|
|
|
+ {
|
|
|
+ fprintf ( stderr, "features: %d, positions: %d\n", ( int ) features.size(),
|
|
|
+ ( int ) positions.size() );
|
|
|
+ if ( features.size() > 0 )
|
|
|
+ fprintf ( stderr, "feature dimension: %d %d\n", features[0].size(), lfrep->getDescSize() );
|
|
|
+ features.save ( filename_desc, descFormat );
|
|
|
+ positions.save ( filename_pos, VVector::FILEFORMAT_LINE );
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ fprintf ( stderr, "description file %s exists !\n", filename_desc.c_str() );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
-void LFWriteCache::visualize ( NICE::Image & img,
|
|
|
- const NICE::Vector & feature ) const
|
|
|
+void LFWriteCache::visualize ( NICE::Image & img,
|
|
|
+ const NICE::Vector & feature ) const
|
|
|
{
|
|
|
- lfrep->visualize ( img, feature );
|
|
|
+ lfrep->visualize ( img, feature );
|
|
|
}
|
|
|
|
|
|
void LFWriteCache::visualizeFeatures ( NICE::Image & mark,
|
|
|
- const VVector & positions,
|
|
|
- size_t color ) const
|
|
|
+ const VVector & positions,
|
|
|
+ size_t color ) const
|
|
|
{
|
|
|
- lfrep->visualizeFeatures ( mark, positions, color );
|
|
|
+ lfrep->visualizeFeatures ( mark, positions, color );
|
|
|
}
|
|
|
|