| 4 | |
| 5 | namespace glomap { |
| 6 | void ReadGravity(const std::string& gravity_path, |
| 7 | std::unordered_map<image_t, Image>& images) { |
| 8 | std::unordered_map<std::string, image_t> name_idx; |
| 9 | for (const auto& [image_id, image] : images) { |
| 10 | name_idx[image.file_name] = image_id; |
| 11 | } |
| 12 | |
| 13 | std::ifstream file(gravity_path); |
| 14 | |
| 15 | // Read in the file list |
| 16 | std::string line, item; |
| 17 | Eigen::Vector3d gravity; |
| 18 | int counter = 0; |
| 19 | while (std::getline(file, line)) { |
| 20 | std::stringstream line_stream(line); |
| 21 | |
| 22 | // file_name |
| 23 | std::string name; |
| 24 | std::getline(line_stream, name, ' '); |
| 25 | |
| 26 | // Gravity |
| 27 | for (double i = 0; i < 3; i++) { |
| 28 | std::getline(line_stream, item, ' '); |
| 29 | gravity[i] = std::stod(item); |
| 30 | } |
| 31 | |
| 32 | // Check whether the image present |
| 33 | auto ite = name_idx.find(name); |
| 34 | if (ite != name_idx.end()) { |
| 35 | counter++; |
| 36 | images[ite->second].gravity_info.SetGravity(gravity); |
| 37 | // Make sure the initialization is aligned with the gravity |
| 38 | images[ite->second].cam_from_world.rotation = |
| 39 | images[ite->second].gravity_info.GetRAlign().transpose(); |
| 40 | } |
| 41 | } |
| 42 | LOG(INFO) << counter << " images are loaded with gravity" << std::endl; |
| 43 | } |
| 44 | |
| 45 | } // namespace glomap |
nothing calls this directly
no test coverage detected