initialize and parse the command line parameters
| 350 | |
| 351 | // initialize and parse the command line parameters |
| 352 | bool Application::Initialize(size_t argc, LPCTSTR* argv) |
| 353 | { |
| 354 | // initialize log and console |
| 355 | OPEN_LOG(); |
| 356 | OPEN_LOGCONSOLE(); |
| 357 | |
| 358 | // group of options allowed only on command line |
| 359 | boost::program_options::options_description generic("Generic options"); |
| 360 | generic.add_options() |
| 361 | ("help,h", "produce this help message") |
| 362 | ("working-folder,w", boost::program_options::value<std::string>(&WORKING_FOLDER), "working directory (default current directory)") |
| 363 | ("config-file,c", boost::program_options::value<std::string>(&OPT::strConfigFileName)->default_value(APPNAME _T(".cfg")), "file name containing program options") |
| 364 | ("archive-type", boost::program_options::value(&OPT::nArchiveType)->default_value(ARCHIVE_DEFAULT), "project archive type: 0-text, 1-binary, 2-compressed binary") |
| 365 | ("process-priority", boost::program_options::value(&OPT::nProcessPriority)->default_value(-1), "process priority (below normal by default)") |
| 366 | ("max-threads", boost::program_options::value(&OPT::nMaxThreads)->default_value(0), "maximum number of threads (0 for using all available cores)") |
| 367 | #if TD_VERBOSE != TD_VERBOSE_OFF |
| 368 | ("verbosity,v", boost::program_options::value(&g_nVerbosityLevel)->default_value( |
| 369 | #if TD_VERBOSE == TD_VERBOSE_DEBUG |
| 370 | 3 |
| 371 | #else |
| 372 | 2 |
| 373 | #endif |
| 374 | ), "verbosity level") |
| 375 | #endif |
| 376 | ; |
| 377 | |
| 378 | // group of options allowed both on command line and in config file |
| 379 | boost::program_options::options_description config("Main options"); |
| 380 | config.add_options() |
| 381 | ("images-list-file,l", boost::program_options::value<std::string>(&OPT::strListFileName), "input filename containing image list") |
| 382 | ("input-file,i", boost::program_options::value<std::string>(&OPT::strInputFileName), "input filename containing camera poses and image list") |
| 383 | ("output-file,o", boost::program_options::value<std::string>(&OPT::strOutputFileName), "output filename for storing the mesh") |
| 384 | ("output-image-folder", boost::program_options::value<std::string>(&OPT::strOutputImageFolder)->default_value("undistorted_images"), "output folder to store undistorted images") |
| 385 | ("normalize,f", boost::program_options::value(&OPT::bNormalizeIntrinsics)->default_value(true), "normalize intrinsics while exporting to OpenMVS format") |
| 386 | ; |
| 387 | |
| 388 | boost::program_options::options_description cmdline_options; |
| 389 | cmdline_options.add(generic).add(config); |
| 390 | |
| 391 | boost::program_options::options_description config_file_options; |
| 392 | config_file_options.add(config); |
| 393 | |
| 394 | boost::program_options::positional_options_description p; |
| 395 | p.add("input-file", -1); |
| 396 | |
| 397 | try { |
| 398 | // parse command line options |
| 399 | boost::program_options::store(boost::program_options::command_line_parser((int)argc, argv).options(cmdline_options).positional(p).run(), OPT::vm); |
| 400 | boost::program_options::notify(OPT::vm); |
| 401 | INIT_WORKING_FOLDER; |
| 402 | // parse configuration file |
| 403 | std::ifstream ifs(MAKE_PATH_SAFE(OPT::strConfigFileName)); |
| 404 | if (ifs) { |
| 405 | boost::program_options::store(parse_config_file(ifs, config_file_options), OPT::vm); |
| 406 | boost::program_options::notify(OPT::vm); |
| 407 | } |
| 408 | } |
| 409 | catch (const std::exception& e) { |
no test coverage detected