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

Method Initialize

apps/InterfacePolycam/InterfacePolycam.cpp:73–157  ·  view source on GitHub ↗

initialize and parse the command line parameters

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.45

Calls 5

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

Tested by

no test coverage detected