MCPcopy Create free account
hub / github.com/cdcseacave/openMVS / Initialize

Method Initialize

apps/InterfaceMVSNet/InterfaceMVSNet.cpp:82–167  ·  view source on GitHub ↗

initialize and parse the command line parameters

Source from the content-addressed store, hash-verified

80
81// initialize and parse the command line parameters
82bool Application::Initialize(size_t argc, LPCTSTR* argv)
83{
84 // initialize log and console
85 OPEN_LOG();
86 OPEN_LOGCONSOLE();
87
88 // group of options allowed only on command line
89 boost::program_options::options_description generic("Generic options");
90 generic.add_options()
91 ("help,h", "produce this help message")
92 ("working-folder,w", boost::program_options::value<std::string>(&WORKING_FOLDER), "working directory (default current directory)")
93 ("config-file,c", boost::program_options::value<std::string>(&OPT::strConfigFileName)->default_value(APPNAME _T(".cfg")), "file name containing program options")
94 ("archive-type", boost::program_options::value(&OPT::nArchiveType)->default_value(ARCHIVE_MVS), "project archive type: -1-interface, 0-text, 1-binary, 2-compressed binary")
95 ("process-priority", boost::program_options::value(&OPT::nProcessPriority)->default_value(-1), "process priority (below normal by default)")
96 ("max-threads", boost::program_options::value(&OPT::nMaxThreads)->default_value(0), "maximum number of threads (0 for using all available cores)")
97 #if TD_VERBOSE != TD_VERBOSE_OFF
98 ("verbosity,v", boost::program_options::value(&g_nVerbosityLevel)->default_value(
99 #if TD_VERBOSE == TD_VERBOSE_DEBUG
100 3
101 #else
102 2
103 #endif
104 ), "verbosity level")
105 #endif
106 ;
107
108 // group of options allowed both on command line and in config file
109 boost::program_options::options_description config("Main options");
110 config.add_options()
111 ("input-file,i", boost::program_options::value<std::string>(&OPT::strInputFileName), "input filename containing camera poses and image list")
112 ("output-file,o", boost::program_options::value<std::string>(&OPT::strOutputFileName), "output filename for storing the mesh")
113 ;
114
115 boost::program_options::options_description cmdline_options;
116 cmdline_options.add(generic).add(config);
117
118 boost::program_options::options_description config_file_options;
119 config_file_options.add(config);
120
121 boost::program_options::positional_options_description p;
122 p.add("input-file", -1);
123
124 try {
125 // parse command line options
126 boost::program_options::store(boost::program_options::command_line_parser((int)argc, argv).options(cmdline_options).positional(p).run(), OPT::vm);
127 boost::program_options::notify(OPT::vm);
128 INIT_WORKING_FOLDER;
129 // parse configuration file
130 std::ifstream ifs(MAKE_PATH_SAFE(OPT::strConfigFileName));
131 if (ifs) {
132 boost::program_options::store(parse_config_file(ifs, config_file_options), OPT::vm);
133 boost::program_options::notify(OPT::vm);
134 }
135 }
136 catch (const std::exception& e) {
137 LOG(e.what());
138 return false;
139 }

Callers 1

mainFunction · 0.45

Calls 7

valueFunction · 0.85
CommandLineToStringFunction · 0.85
getFileExtFunction · 0.85
getFileNameFunction · 0.85
whatMethod · 0.80
addMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected