| 167 | } |
| 168 | |
| 169 | int main(int argc, char *argv[]) |
| 170 | { |
| 171 | #ifdef USE_STACK_TRACE_LOGGER |
| 172 | google::InitGoogleLogging(argv[0]); |
| 173 | google::InstallFailureSignalHandler(); |
| 174 | #endif |
| 175 | |
| 176 | // create options |
| 177 | popl::OptionParser op("Allowed options"); |
| 178 | auto help = op.add<popl::Switch>("h", "help", "produce help message"); |
| 179 | auto vocab_file_path = op.add<popl::Value<std::string>>("v", "vocab", "vocabulary file path"); |
| 180 | auto img_dir_path = op.add<popl::Value<std::string>>("i", "img-dir", "directory path which contains images"); |
| 181 | auto config_file_path = op.add<popl::Value<std::string>>("c", "config", "config file path"); |
| 182 | auto map_db_path = op.add<popl::Value<std::string>>("p", "map-db", "path to a prebuilt map database"); |
| 183 | auto mapping = op.add<popl::Switch>("", "mapping", "perform mapping as well as localization"); |
| 184 | auto mask_img_path = op.add<popl::Value<std::string>>("", "mask", "mask image path", ""); |
| 185 | auto frame_skip = op.add<popl::Value<unsigned int>>("", "frame-skip", "interval of frame skip", 1); |
| 186 | auto no_sleep = op.add<popl::Switch>("", "no-sleep", "not wait for next frame in real time"); |
| 187 | auto auto_term = op.add<popl::Switch>("", "auto-term", "automatically terminate the viewer"); |
| 188 | auto debug_mode = op.add<popl::Switch>("", "debug", "debug mode"); |
| 189 | try |
| 190 | { |
| 191 | op.parse(argc, argv); |
| 192 | } |
| 193 | catch (const std::exception &e) |
| 194 | { |
| 195 | std::cerr << e.what() << std::endl; |
| 196 | std::cerr << std::endl; |
| 197 | std::cerr << op << std::endl; |
| 198 | return EXIT_FAILURE; |
| 199 | } |
| 200 | |
| 201 | // check validness of options |
| 202 | if (help->is_set()) |
| 203 | { |
| 204 | std::cerr << op << std::endl; |
| 205 | return EXIT_FAILURE; |
| 206 | } |
| 207 | if (!vocab_file_path->is_set() || !img_dir_path->is_set() || !config_file_path->is_set() || !map_db_path->is_set()) |
| 208 | { |
| 209 | std::cerr << "invalid arguments" << std::endl; |
| 210 | std::cerr << std::endl; |
| 211 | std::cerr << op << std::endl; |
| 212 | return EXIT_FAILURE; |
| 213 | } |
| 214 | |
| 215 | // setup logger |
| 216 | spdlog::set_pattern("[%Y-%m-%d %H:%M:%S.%e] %^[%L] %v%$"); |
| 217 | if (debug_mode->is_set()) |
| 218 | { |
| 219 | spdlog::set_level(spdlog::level::debug); |
| 220 | } |
| 221 | else |
| 222 | { |
| 223 | spdlog::set_level(spdlog::level::info); |
| 224 | } |
| 225 | |
| 226 | // load configuration |
nothing calls this directly
no test coverage detected