|
@@ -22,44 +22,60 @@ LFonHSG::LFonHSG (const Config *conf, const string section)
|
|
this->lf = NULL;
|
|
this->lf = NULL;
|
|
|
|
|
|
/** get parameters for the grid **/
|
|
/** get parameters for the grid **/
|
|
- sampleScaling = conf->gI (section, "sample_scaling", 50);
|
|
|
|
- scales = conf->gS (section, "scales" , "1");
|
|
|
|
|
|
+ this->sampleScaling = conf->gI (section, "sample_scaling", 50);
|
|
|
|
+ this->scales = conf->gS (section, "scales" , "1");
|
|
// the scales are seperated by '+', like in the Van de Sande implementation
|
|
// the scales are seperated by '+', like in the Van de Sande implementation
|
|
char separator = '+';
|
|
char separator = '+';
|
|
|
|
|
|
/** get debuginformation **/
|
|
/** get debuginformation **/
|
|
- debug = conf->gB ("debug", "show_log_HSG", false);
|
|
|
|
|
|
+ this->debug = conf->gB ("debug", "show_log_HSG", false);
|
|
|
|
|
|
/** generate the descriptor-instanz **/
|
|
/** generate the descriptor-instanz **/
|
|
lf = GenericLocalFeatureSelection::selectLocalFeature (conf, section);
|
|
lf = GenericLocalFeatureSelection::selectLocalFeature (conf, section);
|
|
|
|
|
|
/** parse scales string **/
|
|
/** parse scales string **/
|
|
- debug && clog << "[log] LocalFeatureHSG::LocalFeatureHSG" << endl;
|
|
|
|
- debug && clog << "[log] try to parse the 'scales-string': " << scales << " -> ";
|
|
|
|
|
|
+ if ( this->debug )
|
|
|
|
+ {
|
|
|
|
+ clog << "[log] LocalFeatureHSG::LocalFeatureHSG" << std::endl;
|
|
|
|
+ clog << "[log] try to parse the 'scales-string': " << this->scales << " -> ";
|
|
|
|
+ }
|
|
|
|
|
|
#ifdef NICE_USELIB_BOOST
|
|
#ifdef NICE_USELIB_BOOST
|
|
typedef tokenizer<boost::char_separator<char> > tokenizer;
|
|
typedef tokenizer<boost::char_separator<char> > tokenizer;
|
|
char_separator<char> sep (separator);
|
|
char_separator<char> sep (separator);
|
|
tokenizer tokens (scales, sep); // parse the string into tokens
|
|
tokenizer tokens (scales, sep); // parse the string into tokens
|
|
- for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter) {
|
|
|
|
- debug && clog << *tok_iter << " ";
|
|
|
|
|
|
+ for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
|
|
|
+ {
|
|
|
|
+ if ( this->debug )
|
|
|
|
+ clog << *tok_iter << " ";
|
|
|
|
+
|
|
scalesV.push_back(StringTools::convert<float>(*tok_iter));
|
|
scalesV.push_back(StringTools::convert<float>(*tok_iter));
|
|
}
|
|
}
|
|
#else // standard
|
|
#else // standard
|
|
- vector<string> temp;
|
|
|
|
|
|
+ std::vector<std::string> temp;
|
|
StringTools::split (scales, separator, temp);
|
|
StringTools::split (scales, separator, temp);
|
|
- for (vector<string>::const_iterator it = temp.begin(); it != temp.end(); ++it) {
|
|
|
|
- debug && clog << *it << " ";
|
|
|
|
|
|
+ for ( std::vector<std::string>::const_iterator it = temp.begin(); it != temp.end(); ++it)
|
|
|
|
+ {
|
|
|
|
+ if ( this->debug )
|
|
|
|
+ clog << *it << " ";
|
|
|
|
+
|
|
scalesV.push_back(StringTools::convert<float>(*it));
|
|
scalesV.push_back(StringTools::convert<float>(*it));
|
|
- //scalesV.push_back (strToFloat (*it));
|
|
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
- debug && clog << endl;
|
|
|
|
|
|
+ if ( this->debug )
|
|
|
|
+ clog << std::endl;
|
|
}
|
|
}
|
|
|
|
|
|
LFonHSG::~LFonHSG()
|
|
LFonHSG::~LFonHSG()
|
|
{
|
|
{
|
|
/** free memory of descriptors **/
|
|
/** free memory of descriptors **/
|
|
|
|
+
|
|
|
|
+ // don't waste memory
|
|
|
|
+ if ( this->lf != NULL )
|
|
|
|
+ {
|
|
|
|
+ delete this->lf;
|
|
|
|
+ this->lf = NULL;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
int LFonHSG::getDescSize() const
|
|
int LFonHSG::getDescSize() const
|
|
@@ -69,22 +85,30 @@ int LFonHSG::getDescSize() const
|
|
|
|
|
|
void LFonHSG::getPositionsOnHSG (const unsigned int imageWidth, const unsigned int imageHeight, VVector& positions) const
|
|
void LFonHSG::getPositionsOnHSG (const unsigned int imageWidth, const unsigned int imageHeight, VVector& positions) const
|
|
{
|
|
{
|
|
- if (sampleScaling < 1) {
|
|
|
|
- cerr << "[err] sample-scaling (" << sampleScaling << ") musst be larger the 0!" << endl;
|
|
|
|
|
|
+ if (sampleScaling < 1)
|
|
|
|
+ {
|
|
|
|
+ std::cerr << "[err] sample-scaling (" << sampleScaling << ") musst be larger the 0!" << std::endl;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- debug && clog << "[log] LocalFeatureHSG::getPositionsOnHSG calculate ";
|
|
|
|
|
|
+ if ( this->debug )
|
|
|
|
+ clog << "[log] LocalFeatureHSG::getPositionsOnHSG calculate ";
|
|
|
|
|
|
bool oddRow = true;
|
|
bool oddRow = true;
|
|
NICE::Vector pos (4);
|
|
NICE::Vector pos (4);
|
|
|
|
|
|
/** we have to calculate the koo. for every different scale **/
|
|
/** we have to calculate the koo. for every different scale **/
|
|
- for (vector <float>::const_iterator it = scalesV.begin(); it != scalesV.end(); ++it) {
|
|
|
|
|
|
+ for ( std::vector<float>::const_iterator it = this->scalesV.begin(); it != this->scalesV.end(); ++it)
|
|
|
|
+ {
|
|
oddRow = true;
|
|
oddRow = true;
|
|
|
|
|
|
- for (unsigned int j = sampleScaling; j <= (imageHeight - sampleScaling); j += sampleScaling) {
|
|
|
|
- for (unsigned int i = (oddRow ? sampleScaling + sampleScaling / 2 : sampleScaling); i <= (imageWidth - sampleScaling); i += sampleScaling) {
|
|
|
|
|
|
+ for (unsigned int j = sampleScaling; j <= (imageHeight - sampleScaling); j += sampleScaling)
|
|
|
|
+ {
|
|
|
|
+ for ( unsigned int i = (oddRow ? sampleScaling + sampleScaling / 2 : sampleScaling);
|
|
|
|
+ i <= (imageWidth - sampleScaling);
|
|
|
|
+ i += sampleScaling
|
|
|
|
+ )
|
|
|
|
+ {
|
|
pos[ 0 ] = i;
|
|
pos[ 0 ] = i;
|
|
pos[ 1 ] = j;
|
|
pos[ 1 ] = j;
|
|
pos[ 2 ] = *it;
|
|
pos[ 2 ] = *it;
|
|
@@ -99,7 +123,7 @@ void LFonHSG::getPositionsOnHSG (const unsigned int imageWidth, const unsigned i
|
|
int LFonHSG::extractFeatures (const NICE::ColorImage & cimg, VVector & features, VVector & positions) const
|
|
int LFonHSG::extractFeatures (const NICE::ColorImage & cimg, VVector & features, VVector & positions) const
|
|
{
|
|
{
|
|
/** To get the keypoint descriptor, we need the positions of the keypoints. **/
|
|
/** To get the keypoint descriptor, we need the positions of the keypoints. **/
|
|
- getPositionsOnHSG (cimg.width(), cimg.height(), positions);
|
|
|
|
|
|
+ this->getPositionsOnHSG (cimg.width(), cimg.height(), positions);
|
|
|
|
|
|
/** calulate the descriptor-values **/
|
|
/** calulate the descriptor-values **/
|
|
return lf->getDescriptors (cimg, positions, features);
|
|
return lf->getDescriptors (cimg, positions, features);
|
|
@@ -109,7 +133,7 @@ int LFonHSG::extractFeatures (const NICE::ColorImage & cimg, VVector & features,
|
|
int LFonHSG::extractFeatures (const NICE::Image & img, VVector & features, VVector & positions) const
|
|
int LFonHSG::extractFeatures (const NICE::Image & img, VVector & features, VVector & positions) const
|
|
{
|
|
{
|
|
/** To get the keypoint descriptor, we need the positions of the keypoints. **/
|
|
/** To get the keypoint descriptor, we need the positions of the keypoints. **/
|
|
- getPositionsOnHSG (img.width(), img.height(), positions);
|
|
|
|
|
|
+ this->getPositionsOnHSG (img.width(), img.height(), positions);
|
|
|
|
|
|
/** calculate the descriptor-values **/
|
|
/** calculate the descriptor-values **/
|
|
return lf->getDescriptors (img, positions, features);
|
|
return lf->getDescriptors (img, positions, features);
|