MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / main

Function main

Source/Tools/ImageCompare/ImageCompare.cpp:382–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380}
381
382int main(int argc, char** argv)
383{
384 args::ArgumentParser parser("Utility to compare images.");
385 parser.helpParams.programName = "ImageCompare";
386 args::HelpFlag helpFlag(parser, "help", "Display this help menu.", {'h', "help"});
387 args::Flag listMetricsFlag(parser, "", "List available error metrics.", {'l'});
388 args::ValueFlag<std::string> metricFlag(parser, "metric", "The error metric.", {'m'});
389 args::ValueFlag<float> thresholdFlag(parser, "threshold", "The error threshold.", {'t'});
390 args::Flag alphaFlag(parser, "", "Include alpha channel.", {'a'});
391 args::ValueFlag<std::string> heatMapFlag(parser, "filename", "Generate error heat map.", {'e'});
392 args::Positional<std::string> image1(parser, "image1", "The first image.", args::Options::Required);
393 args::Positional<std::string> image2(parser, "image2", "The second image.", args::Options::Required);
394 args::CompletionFlag completionFlag(parser, {"complete"});
395
396 try
397 {
398 parser.ParseCLI(argc, argv);
399 }
400 catch (const args::Completion& e)
401 {
402 std::cout << e.what();
403 return 0;
404 }
405 catch (const args::Help&)
406 {
407 std::cout << parser;
408 return 0;
409 }
410 catch (const args::ParseError& e)
411 {
412 std::cerr << e.what() << std::endl;
413 std::cerr << parser;
414 return 1;
415 }
416 catch (const args::RequiredError& e)
417 {
418 std::cerr << e.what() << std::endl;
419 std::cerr << parser;
420 return 1;
421 }
422
423 if (listMetricsFlag)
424 {
425 printMetrics();
426 return 0;
427 }
428
429 ErrorMetric metric = errorMetrics.front();
430 if (metricFlag)
431 {
432 auto name = args::get(metricFlag);
433 auto it =
434 std::find_if(errorMetrics.begin(), errorMetrics.end(), [&name](const ErrorMetric& metric) { return metric.name == name; });
435 if (it == errorMetrics.end())
436 {
437 std::cerr << "Unknown error metric '" << args::get(metricFlag) << "'." << std::endl;
438 printMetrics(std::cerr);
439 return 1;

Callers

nothing calls this directly

Calls 7

printMetricsFunction · 0.85
compareImagesFunction · 0.85
whatMethod · 0.80
frontMethod · 0.80
getFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected