本文整理汇总了C++中ArgumentParser::addArgument方法的典型用法代码示例。如果您正苦于以下问题:C++ ArgumentParser::addArgument方法的具体用法?C++ ArgumentParser::addArgument怎么用?C++ ArgumentParser::addArgument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArgumentParser
的用法示例。
在下文中一共展示了ArgumentParser::addArgument方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
CVMArgumentParser::CVMArgumentParser(int argc, const char** argv, bool requireCalib, bool requireOutputPath, bool requireInputPath, bool requireSize){
// make a new ArgumentParser
ArgumentParser parser;
parser.addArgument("-c", "--calib_file", 1, !requireCalib);
parser.addArgument("-d", "--devices", 1, true);
parser.addArgument("-h", "--height", 1, !requireSize);
parser.addArgument("-w", "--width", 1, !requireSize);
parser.addArgument("-o", "--output", 1, !requireOutputPath);
parser.addArgument("-i", "--input", 1, !requireInputPath);
parser.addArgument("-s", "--saveData", 1, true);
parser.addArgument("-v", "--saveVideo", 1, true);
parser.addArgument("-t", "--debugTiming", 1, true);
parser.addArgument("-q", "--quiet", 1, true);
parser.parse(argc, argv);
outputpath = parser.retrieve<string>("o");
inputpath = parser.retrieve<string>("i");
calib_file_path = parser.retrieve<string>("c");
cout << calib_file_path << endl;
deviceID = "/dev/video0";
string devicestring = parser.retrieve<string>("d");
if (devicestring.length() != 0)
deviceID = devicestring;
height = 960;
string heightstring = parser.retrieve<string>("h");
if (heightstring.length() != 0)
height =stoi(heightstring);
width = 1280;
string widthstring = parser.retrieve<string>("w");
if (widthstring.length() != 0)
width =stoi(widthstring);
saveData = false;
string saveDatastr = parser.retrieve<string>("s");
if (saveDatastr.length() != 0)
saveData =(stoi(saveDatastr) == 1);
saveVideo = false;
string saveVideostr = parser.retrieve<string>("v");
if (saveVideostr.length() != 0)
saveVideo =(stoi(saveVideostr) == 1);
saveTiming = false;
string saveTimingstr = parser.retrieve<string>("t");
if (saveTimingstr.length() != 0)
saveTiming =(stoi(saveTimingstr) == 1);
quiet = false;
string quietstr = parser.retrieve<string>("q");
if (quietstr.length() != 0)
quiet =(stoi(quietstr) == 1);
}
示例2: main
int main(int argc, char *argv[])
{
ArgumentParser parser;
parser.addArgument("-i", "--input", 1, false);
parser.parse(argc, argv);
TApplication *myapp = new TApplication("App", &argc, argv);
fit(parser.retrieve<string>("i"));
myapp->Run();
}
示例3: main
int main(int argc, char **argv)
{
ArgumentParser parser;
parser.addArgument("-i", "--input", 1, false);
parser.addArgument("-t", "--tree", 1, true);
parser.addArgument("-b", "--branch", 1, false);
parser.addArgument("-f", "--filter", 1, true);
parser.addArgument("--hits_name", 1, true);
parser.addArgument("--hits_bins", 1, true);
parser.addArgument("--hist-start", 1, true);
parser.addArgument("--hist-end", 1, true);
parser.addArgument("--fit-start", 1, true);
parser.addArgument("--fit-end", 1, true);
parser.addArgument("-o", "--output", 1, false);
parser.parse(argc, argv);
Fit *fit;
if (parser.count("tree"))
fit = new Fit(parser.retrieve<string>("input"), parser.retrieve<string>("tree"));
else
fit = new Fit(parser.retrieve<string>("input"));
if (parser.count("hist-start"))
fit->hist_start = stod(parser.retrieve<string>("hist-start"));
if (parser.count("hist-end"))
fit->hist_start = stod(parser.retrieve<string>("hist-end"));
if (parser.count("fit-start"))
fit->hist_start = stod(parser.retrieve<string>("fit-start"));
if (parser.count("fit-end"))
fit->hist_start = stod(parser.retrieve<string>("fit-end"));
if (parser.count("hits_bins"))
fit->hist_bins = stoi(parser.retrieve<string>("hits_bins"));
if (parser.count("hits_name"))
fit->create_hist(parser.retrieve<string>("hist_name"));
else
fit->create_hist();
if (parser.count("filter"))
fit->load(parser.retrieve<string>("branch"), parser.retrieve<string>("filter"));
else
fit->load(parser.retrieve<string>("branch"));
fit->process(parser.retrieve<string>("output"));
}
示例4: main
int main(int argc, char** argv)
{
sofa::simulation::tree::init();
sofa::component::initComponentBase();
sofa::component::initComponentCommon();
bool showHelp = false;
unsigned int idExample = 0;
ArgumentParser* argParser = new ArgumentParser(argc, argv);
argParser->addArgument(po::value<bool>(&showHelp)->default_value(false)->implicit_value(true), "help,h", "Display this help message");
argParser->addArgument(po::value<unsigned int>(&idExample)->default_value(0)->notifier([](unsigned int value)
{
if (value < 0 || value > 9) {
std::cerr << "Example Number to enter from (0 - 9), current value: " << value << std::endl;
exit( EXIT_FAILURE );
}
}), "example,e", "Example Number to enter from (0 - 9)");
argParser->parse();
if(showHelp)
{
argParser->showHelp();
exit( EXIT_SUCCESS );
}
// init GUI
sofa::gui::initMain();
sofa::gui::GUIManager::Init(argv[0]);
// Create simulation tree
sofa::simulation::setSimulation(new sofa::simulation::tree::TreeSimulation());
// Create the graph root node with collision
sofa::simulation::Node::SPtr root = sofa::modeling::createRootWithCollisionPipeline();
root->setGravity( sofa::defaulttype::Vec3Types::Deriv(0,-10.0,0) );
// Create scene example (depends on user input)
switch (idExample)
{
case 0:
fallingCubeExample(root);
break;
case 1:
fallingCylinderExample(root);
break;
case 2:
fallingSphereExample(root);
break;
case 3:
fallingDrapExample(root);
break;
default:
fallingCubeExample(root);
break;
}
root->setAnimate(false);
sofa::simulation::getSimulation()->init(root.get());
//=======================================
// Run the main loop
sofa::gui::GUIManager::MainLoop(root);
sofa::simulation::tree::cleanup();
return 0;
}
示例5: main
int main(int argc, const char** argv) {
// Load the command line config
ArgumentParser parser;
parser.addArgument("-e", "--epochs", 1);
parser.addArgument("-s", "--seed", 1);
parser.addArgument("-l", "--layers", 1);
parser.addArgument("-S", "--samples", 1);
parser.addArgument("-c", "--corpus", 1);
parser.addArgument("--nlayers", 1);
parser.addArgument("--ifbradius", 1);
parser.addArgument("--lw", 1);
parser.addArgument("--lh", 1);
parser.addArgument("--ssize", 1);
parser.addArgument("--sseednoise", 1);
parser.addArgument("--sprednoise", 1);
parser.parse(argc, argv);
// RNG
unsigned int seed = std::atoi(parser.retrieve("seed", std::to_string(time(nullptr))).c_str());
std::mt19937 generator(seed);
std::uniform_real_distribution<float> dist01(0.0f, 1.0f);
// ---------------------------------- Load the Corpus ----------------------------------
std::string corpusPath = parser.retrieve("corpus", "corpus.txt");
std::ifstream fromFile(corpusPath);
fromFile.seekg(0, std::ios::end);
size_t size = fromFile.tellg();
std::string test(size, ' ');
fromFile.seekg(0);
fromFile.read(&test[0], size);
// ---------------------------------- Find Character Set ----------------------------------
VectorCodec textcodec(test);
int numInputs = textcodec.N;
int inputsRoot = std::ceil(std::sqrt(static_cast<float>(numInputs)));
// ---------------------------------- Create Hierarchy ----------------------------------
// Fill out layer descriptions
int nLayers = std::atoi(parser.retrieve("nlayers", "3").c_str());
int layerW = std::atoi(parser.retrieve("lw", "16").c_str());
int layerH = std::atoi(parser.retrieve("lh", "16").c_str());
int inFeedBackRadius = std::atoi(parser.retrieve("ifbradius", "16").c_str());
std::vector<neo::PredictiveHierarchy::LayerDesc> layerDescs(nLayers);
for (int i = 0; i < nLayers; i++) {
layerDescs[i]._width = layerW;
layerDescs[i]._height = layerH;
}
neo::PredictiveHierarchy ph;
ph.createRandom(inputsRoot, inputsRoot, inFeedBackRadius, layerDescs, -0.01f, 0.01f, 0.01f, 0.05f, 0.1f, generator);
// ---------------------------------- Iterate Over Corpus ----------------------------------
int numEpochs = std::atoi(parser.retrieve("epochs", "10").c_str());
int numSamples = std::atoi(parser.retrieve("samples", "10").c_str());
int sampleSize = std::atoi(parser.retrieve("ssize", std::to_string(test.length())).c_str());
float sampleSeedNoise = std::atof(parser.retrieve("sseednoise", "0.5").c_str());
float samplePredNoise = std::atof(parser.retrieve("sprednoise", "0.05").c_str());
std::cout << "NeoRL text prediction experiment" << std::endl;
std::cout << "Corpus: " << corpusPath << " size: " << test.length() << " alphabet size: " << textcodec.nSymbols << std::endl;
std::cout << "Model: nLayers: " << nLayers << " layerW: " << layerW << " layerH: " << layerH << " inFeedbackRadius: " << inFeedBackRadius
<< " input: " << inputsRoot << "x" << inputsRoot << std::endl;
std::cout << "Training: epochs: " << numEpochs << std::endl;
std::cout << "Sampling: samples: " << numSamples << " size: " << sampleSize << " seed noise: " << sampleSeedNoise << " pred noise " << samplePredNoise << std::endl;
std::cout << "--[ Start training ]--" << std::endl;
train(ph, generator, test, numEpochs, textcodec);
std::cout << "--[ Start sampling ]--" << std::endl;
for (int i = 0; i < numSamples; i++) {
sample(ph, generator, textcodec.getRandomSymbol(generator), sampleSize, textcodec, sampleSeedNoise, samplePredNoise);
}
return 0;
}