| 30 | #include <algorithm> |
| 31 | |
| 32 | euroc_sequence::euroc_sequence(const std::string &seq_dir_path) |
| 33 | { |
| 34 | const std::string timestamp_file_path = seq_dir_path + "/cam0/data.csv"; |
| 35 | const std::string left_img_dir_path = seq_dir_path + "/cam0/data/"; |
| 36 | const std::string right_img_dir_path = seq_dir_path + "/cam1/data/"; |
| 37 | |
| 38 | timestamps_.clear(); |
| 39 | left_img_file_paths_.clear(); |
| 40 | right_img_file_paths_.clear(); |
| 41 | |
| 42 | // load timestamps |
| 43 | std::ifstream ifs_timestamp; |
| 44 | ifs_timestamp.open(timestamp_file_path.c_str()); |
| 45 | if (!ifs_timestamp) |
| 46 | { |
| 47 | throw std::runtime_error("Could not load a timestamp file from " + timestamp_file_path); |
| 48 | } |
| 49 | |
| 50 | // load header row |
| 51 | std::string s; |
| 52 | getline(ifs_timestamp, s); |
| 53 | |
| 54 | while (!ifs_timestamp.eof()) |
| 55 | { |
| 56 | getline(ifs_timestamp, s); |
| 57 | std::replace(s.begin(), s.end(), ',', ' '); |
| 58 | if (!s.empty()) |
| 59 | { |
| 60 | std::stringstream ss; |
| 61 | ss << s; |
| 62 | unsigned long long timestamp; |
| 63 | ss >> timestamp; |
| 64 | timestamps_.push_back(timestamp / static_cast<double>(1E9)); |
| 65 | left_img_file_paths_.push_back(left_img_dir_path + std::to_string(timestamp) + ".png"); |
| 66 | right_img_file_paths_.push_back(right_img_dir_path + std::to_string(timestamp) + ".png"); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | ifs_timestamp.close(); |
| 71 | } |
| 72 | |
| 73 | std::vector<euroc_sequence::frame> euroc_sequence::get_frames() const |
| 74 | { |