本文整理汇总了C++中mrpt::format方法的典型用法代码示例。如果您正苦于以下问题:C++ mrpt::format方法的具体用法?C++ mrpt::format怎么用?C++ mrpt::format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mrpt
的用法示例。
在下文中一共展示了mrpt::format方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestExtractFeaturesTile
// ------------------------------------------------------
// TestCapture
// ------------------------------------------------------
void TestExtractFeaturesTile()
{
CDisplayWindow wind1,wind2;
CFeatureExtraction fExt;
CFeatureList featsHarris;
CImage img;
string the_img = myDataDir+string("test_image.jpg");
if (!img.loadFromFile(the_img ))
{
cerr << "Cannot load " << the_img << endl;
return;
}
cout << "Loaded test image: " << the_img << endl;
CTicTac tictac;
cout << "Extracting Harris features (tiled)... [f_harris_tiled.txt]";
fExt.options.featsType = featHarris;
fExt.options.harrisOptions.tile_image = true;
tictac.Tic();
fExt.detectFeatures( img, featsHarris );
cout << format(" %.03fms",tictac.Tac()*1000) << endl;
cout << "Detected " << featsHarris.size() << " features in " << endl;
featsHarris.saveToTextFile("f_harris_tiled.txt");
wind1.setWindowTitle("Harris detected features (Tiled image)");
wind1.showTiledImageAndPoints( img, featsHarris );
cout << "Extracting Harris features... [f_harris.txt]";
fExt.options.harrisOptions.tile_image = false;
tictac.Tic();
fExt.detectFeatures( img, featsHarris );
cout << format(" %.03fms",tictac.Tac()*1000) << endl;
featsHarris.saveToTextFile("f_harris.txt");
wind2.setWindowTitle("Harris detected features");
wind2.showTiledImageAndPoints( img, featsHarris );
mrpt::system::pause();
return;
}
示例2: read_int
/*---------------------------------------------------------------
read_int
---------------------------------------------------------------*/
int CConfigFileBase::read_int(
const std::string& section, const std::string& name, int defaultValue,
bool failIfNotFound) const
{
return atoi(
readString(section, name, format("%i", defaultValue), failIfNotFound)
.c_str());
}
示例3: read_float
/*---------------------------------------------------------------
read_float
---------------------------------------------------------------*/
float CConfigFileBase::read_float(
const std::string& section, const std::string& name, float defaultValue,
bool failIfNotFound) const
{
return (float)atof(
readString(section, name, format("%.10e", defaultValue), failIfNotFound)
.c_str());
}
示例4: read_double
/*---------------------------------------------------------------
read_double
---------------------------------------------------------------*/
double CConfigFileBase::read_double(
const std::string& section, const std::string& name, double defaultValue,
bool failIfNotFound) const
{
return atof(
readString(section, name, format("%.16e", defaultValue), failIfNotFound)
.c_str());
}
示例5: readString
/*---------------------------------------------------------------
read_uint64_t
---------------------------------------------------------------*/
uint64_t CConfigFileBase::read_uint64_t(
const std::string& section, const std::string& name, uint64_t defaultValue,
bool failIfNotFound) const
{
string s = readString(
section, name, format("%lu", (long unsigned int)defaultValue),
failIfNotFound);
return mrpt::system::os::_strtoull(s.c_str(), nullptr, 0);
}
示例6: write
void CConfigFileBase::write(
const std::string& section, const std::string& name, double value,
const int name_padding_width, const int value_padding_width,
const std::string& comment)
{
writeString(
section, name,
format(
((std::abs(value) > 1e-4 && std::abs(value) < 1e4) || value == .0)
? "%f"
: "%e",
value),
name_padding_width, value_padding_width, comment);
}
示例7: read_string_first_word
/*---------------------------------------------------------------
read_string_first_word
---------------------------------------------------------------*/
std::string CConfigFileBase::read_string_first_word(
const std::string& section, const std::string& name,
const std::string& defaultValue, bool failIfNotFound) const
{
string s = readString(section, name, defaultValue, failIfNotFound);
std::vector<std::string> auxStrs;
mrpt::system::tokenize(s, "[], \t", auxStrs);
if (auxStrs.empty())
{
if (failIfNotFound)
{
THROW_EXCEPTION(format(
"Value '%s' seems to be present in section '%s' but, are "
"all whitespaces??",
name.c_str(), section.c_str()));
}
else
return "";
}
else
return auxStrs[0];
}
示例8: TestMatchingComparative
//.........这里部分代码省略.........
int px = 80;
double minsad = 1.0, maxncc = 0.0;
float minsiftd = 1.0f, minsurfd = 1.0f;
int idxsad = 0, idxncc = 0, idxsiftd = 0, idxsurfd = 0;
for( it2 = list2.begin(); it2 != list2.end(); ++it2 )
{
if( fabs((*it1)->y-(*it2)->y) <= 1.0 && (*it1)->x > (*it2)->x )
{
// Compute matching with SAD and Correlation and SIFT/SURF?
// Use epipolar constraints
// Compute SAD
double sad = mrpt::vision::computeSAD( (*it1)->patch, (*it2)->patch );
if( sad < minsad )
{
minsad = sad;
idxsad = cnt;
}
// Compute Correlation
double ncc;
size_t u, v;
mrpt::vision::openCV_cross_correlation( (*it1)->patch, (*it2)->patch, u, v, ncc );
if( ncc > maxncc )
{
maxncc = ncc;
idxncc = cnt;
}
// Compute distance between descriptors SIFT
float siftd = (*it1)->descriptorSIFTDistanceTo( *(*it2) );
if( siftd < minsiftd )
{
minsiftd = siftd;
idxsiftd = cnt;
}
// Compute distance between descriptors SIFT
float surfd = (*it1)->descriptorSURFDistanceTo( *(*it2) );
if( surfd < minsurfd )
{
minsurfd = surfd;
idxsurfd = cnt;
}
// Plot images + features + each candidate + difference score
if( firstMatch )
{
copyjoinimage.line( (*it1)->x+imW, 0, (*it1)->x+imW, imH, TColor::green ); // Limit line (only the first time)
firstMatch = false;
} // end-if
copyjoinimage.drawCircle( (*it2)->x+imW, (*it2)->y, 4, TColor::blue, 2 ); // Keypoint
double rx0, rx1, ry0, ry1, tx, ty;
rx0 = (*it2)->x+imW-15;
rx1 = (*it2)->x+imW;
tx = (*it2)->x+imW-13;
if( cnt % 2 )
{
ry0 = (*it2)->y-20;
ry1 = (*it2)->y-10;
ty = (*it2)->y-22;
}
else
{
ry0 = (*it2)->y+10;
ry1 = (*it2)->y+20;
ty = (*it2)->y+8;
}
copyjoinimage.filledRectangle( rx0, ry0, rx1, ry1, TColor(150,150,150) );
copyjoinimage.textOut( tx, ty, format("%d", cnt), TColor::blue );
px = 80+cnt*50;
if( px + fExt.options.patchSize > imW2 )
continue;
copyInfoImage.update_patch( (*it2)->patch, px, 30 );
copyInfoImage.textOut( px, imH2-70, format("%d", cnt), TColor::blue );
copyInfoImage.textOut( px, imH2-53, format("%.2f", sad), TColor::blue );
copyInfoImage.textOut( px, imH2-41, format("%.2f", ncc), TColor::blue );
copyInfoImage.textOut( px, imH2-29, format("%.2f", siftd), TColor::blue );
copyInfoImage.textOut( px, imH2-17, format("%.2f", surfd), TColor::blue );
cnt++;
} // end if
} // end for it2
copyInfoImage.textOut( 80+idxsad*50, imH2-53, format("%.2f", minsad), TColor::green );
copyInfoImage.textOut( 80+idxncc*50, imH2-41, format("%.2f", maxncc), TColor::green );
copyInfoImage.textOut( 80+idxsiftd*50, imH2-29, format("%.2f", minsiftd), TColor::green );
copyInfoImage.textOut( 80+idxsurfd*50, imH2-17, format("%.2f", minsurfd), TColor::green );
win.showImage( copyjoinimage );
win2.showImage( copyInfoImage );
mrpt::system::pause();
} // end for it1
// Save to file
// Check number of good features
} // end TestMatchingComparative
示例9: TestExtractFeatures
// ------------------------------------------------------
// TestExtractFeatures
// ------------------------------------------------------
void TestExtractFeatures()
{
CDisplayWindow wind1,wind2,wind3,wind4,wind5;
CFeatureExtraction fExt;
CFeatureList featsHarris, featsKLT, featsSIFT_Hess, featsSIFT_Lowe, featsSIFT_Vedaldi, featsSURF, featsFAST;
CImage img;
if (!img.loadFromFile(the_img_for_extract_feats ))
{
cerr << "Cannot load " << the_img_for_extract_feats << endl;
return;
}
cout << "Loaded test image: " << endl << the_img_for_extract_feats << endl;
cout << "--------------------------------------------------------------------------" << endl << endl;
CTicTac tictac;
fExt.options.patchSize = 0;
cout << "Detect Harris features... [f_harris.txt]" << endl;
tictac.Tic();
fExt.options.featsType = featHarris;
fExt.detectFeatures( img, featsHarris );
cout << "Detected " << featsHarris.size() << " features in ";
cout << format(" %.03fms",tictac.Tac()*1000) << endl << endl;
featsHarris.saveToTextFile("f_harris.txt");
wind1.setWindowTitle("Harris detected features");
wind1.showImageAndPoints(img, featsHarris);
cout << "Detect FAST features... [f_fast.txt]" << endl;
tictac.Tic();
fExt.options.featsType = featFAST;
fExt.options.FASTOptions.threshold = 15; //150;
fExt.options.FASTOptions.min_distance = 4;
fExt.options.FASTOptions.use_KLT_response = true;
fExt.detectFeatures( img, featsFAST, 0, 500 /* max num feats */ );
cout << "Detected " << featsFAST.size() << " features in ";
cout << format(" %.03fms",tictac.Tac()*1000) << endl << endl;
featsFAST.saveToTextFile("f_fast.txt");
wind5.setWindowTitle("FAST detected features");
wind5.showImageAndPoints( img, featsFAST );
cout << "Computing SIFT descriptors only ... [f_harris+sift.txt]" << endl;
tictac.Tic();
fExt.options.SIFTOptions.implementation = CFeatureExtraction::Hess;
fExt.computeDescriptors( img, featsHarris, descSIFT );
cout << format(" %.03fms",tictac.Tac()*1000) << endl << endl;
featsHarris.saveToTextFile("f_harris+sift.txt");
cout << "Extracting KLT features... [f_klt.txt]" << endl;
tictac.Tic();
fExt.options.featsType = featKLT;
fExt.options.KLTOptions.threshold = 0.05f;
fExt.options.KLTOptions.radius = 5;
fExt.detectFeatures( img, featsKLT, 0, 10 );
cout << "Detected " << featsKLT.size() << " features in ";
cout << format(" %.03fms",tictac.Tac()*1000) << endl << endl;
featsKLT.saveToTextFile("f_klt.txt");
wind2.setWindowTitle("KLT detected features");
wind2.showImageAndPoints( img, featsKLT );
cout << "Extracting SIFT features... [f_sift_hess.txt]" << endl;
tictac.Tic();
fExt.options.featsType = featSIFT;
fExt.options.SIFTOptions.implementation = CFeatureExtraction::Hess;
fExt.detectFeatures( img, featsSIFT_Hess );
cout << "Detected " << featsSIFT_Hess.size() << " features in ";
cout << format(" %.03fms",tictac.Tac()*1000) << endl << endl;
featsSIFT_Hess.saveToTextFile("f_sift_hess.txt");
wind3.setWindowTitle("SIFT Hess detected features");
wind3.showImageAndPoints( img, featsSIFT_Hess );
cout << "Extracting SURF features... [f_surf.txt]" << endl;
tictac.Tic();
fExt.options.featsType = featSURF;
fExt.detectFeatures( img, featsSURF );
cout << "Detected " << featsSURF.size() << " features in ";
cout << format(" %.03fms",tictac.Tac()*1000) << endl << endl;
featsSURF.saveToTextFile("f_surf.txt");
wind4.setWindowTitle("SURF detected features");
wind4.showImageAndPoints( img, featsSURF );
cout << "Computing spin images descriptors only ... [f_harris+spinimgs.txt]" << endl;
tictac.Tic();
fExt.options.SpinImagesOptions.radius = 13;
fExt.options.SpinImagesOptions.hist_size_distance = 10;
fExt.options.SpinImagesOptions.hist_size_intensity = 10;
fExt.computeDescriptors( img, featsHarris, descSpinImages );
cout << format(" %.03fms",tictac.Tac()*1000) << endl << endl;
featsHarris.saveToTextFile("f_harris+spinimgs.txt");
mrpt::system::pause();
return;
}