| 191 | } |
| 192 | |
| 193 | int main(int argc, char *argv[]) |
| 194 | { |
| 195 | #ifdef USE_STACK_TRACE_LOGGER |
| 196 | google::InitGoogleLogging(argv[0]); |
| 197 | google::InstallFailureSignalHandler(); |
| 198 | #endif |
| 199 | |
| 200 | // create options |
| 201 | popl::OptionParser op("Allowed options"); |
| 202 | auto help = op.add<popl::Switch>("h", "help", "produce help message"); |
| 203 | auto vocab_file_path = op.add<popl::Value<std::string>>("v", "vocab", "vocabulary file path"); |
| 204 | auto img_dir_path = op.add<popl::Value<std::string>>("i", "img-dir", "directory path which contains images"); |
| 205 | auto config_file_path = op.add<popl::Value<std::string>>("c", "config", "config file path"); |
| 206 | auto mask_img_path = op.add<popl::Value<std::string>>("", "mask", "mask image path", ""); |
| 207 | auto frame_skip = op.add<popl::Value<unsigned int>>("", "frame-skip", "interval of frame skip", 1); |
| 208 | auto no_sleep = op.add<popl::Switch>("", "no-sleep", "not wait for next frame in real time"); |
| 209 | auto auto_term = op.add<popl::Switch>("", "auto-term", "automatically terminate the viewer"); |
| 210 | auto debug_mode = op.add<popl::Switch>("", "debug", "debug mode"); |
| 211 | auto eval_log = op.add<popl::Switch>("", "eval-log", "store trajectory and tracking times for evaluation"); |
| 212 | auto map_db_path = op.add<popl::Value<std::string>>("p", "map-db", "store a map database at this path after SLAM", ""); |
| 213 | try |
| 214 | { |
| 215 | op.parse(argc, argv); |
| 216 | } |
| 217 | catch (const std::exception &e) |
| 218 | { |
| 219 | std::cerr << e.what() << std::endl; |
| 220 | std::cerr << std::endl; |
| 221 | std::cerr << op << std::endl; |
| 222 | return EXIT_FAILURE; |
| 223 | } |
| 224 | |
| 225 | // check validness of options |
| 226 | if (help->is_set()) |
| 227 | { |
| 228 | std::cerr << op << std::endl; |
| 229 | return EXIT_FAILURE; |
| 230 | } |
| 231 | if (!vocab_file_path->is_set() || !img_dir_path->is_set() || !config_file_path->is_set()) |
| 232 | { |
| 233 | std::cerr << "invalid arguments" << std::endl; |
| 234 | std::cerr << std::endl; |
| 235 | std::cerr << op << std::endl; |
| 236 | return EXIT_FAILURE; |
| 237 | } |
| 238 | |
| 239 | // setup logger |
| 240 | spdlog::set_pattern("[%Y-%m-%d %H:%M:%S.%e] %^[%L] %v%$"); |
| 241 | if (debug_mode->is_set()) |
| 242 | { |
| 243 | spdlog::set_level(spdlog::level::debug); |
| 244 | } |
| 245 | else |
| 246 | { |
| 247 | spdlog::set_level(spdlog::level::info); |
| 248 | } |
| 249 | |
| 250 | // load configuration |
nothing calls this directly
no test coverage detected