KITTI Dataset pose 불러오기
늘 까먹어서 메모용으로 기록해둔다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <fstream> | |
#include <eigen3/Eigen/Dense> | |
using namespace std; | |
vector<float> split(string input, char delimiter) { | |
vector<float> answer; | |
stringstream ss(input); | |
string temp; | |
while (getline(ss, temp, delimiter)) { | |
answer.push_back(stof(temp)); | |
} | |
return answer; | |
} | |
void vec2tf4x4(vector<float>& pose, Eigen::Matrix4f& tf4x4){ | |
for (int idx = 0; idx < 12; ++idx){ | |
int i = idx / 4; | |
int j = idx % 4; | |
tf4x4(i, j) = pose[idx]; | |
} | |
} | |
int main(){ | |
vector<Eigen::Matrix4f > poses; | |
std::ifstream in("/home/shapelim/dataset/dataset/sequences/00/poses.txt"); | |
std::string line; | |
while (std::getline(in, line)) { | |
// output the line | |
std::cout << line << std::endl; | |
vector<float> pose = split(line, ' '); | |
Eigen::Matrix4f tf4x4 = Eigen::Matrix4f::Identity(); // Crucial! | |
vec2tf4x4(pose, tf4x4); | |
} | |
} |