txt提取
原始txt
P0: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 0.000000000000e+00 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00
P1: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 -3.875744000000e+02 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00
P2: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 4.485728000000e+01 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 2.163791000000e-01 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 2.745884000000e-03
P3: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 -3.395242000000e+02 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 2.199936000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 2.729905000000e-03
R_rect 9.999239000000e-01 9.837760000000e-03 -7.445048000000e-03 -9.869795000000e-03 9.999421000000e-01 -4.278459000000e-03 7.402527000000e-03 4.351614000000e-03 9.999631000000e-01
Tr_velo_cam 7.533745000000e-03 -9.999714000000e-01 -6.166020000000e-04 -4.069766000000e-03 1.480249000000e-02 7.280733000000e-04 -9.998902000000e-01 -7.631618000000e-02 9.998621000000e-01 7.523790000000e-03 1.480755000000e-02 -2.717806000000e-01
Tr_imu_velo 9.999976000000e-01 7.553071000000e-04 -2.035826000000e-03 -8.086759000000e-01 -7.854027000000e-04 9.998898000000e-01 -1.482298000000e-02 3.195559000000e-01 2.024406000000e-03 1.482454000000e-02 9.998881000000e-01 -7.997231000000e-01
code
#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
#include <bits/stdc++.h>
using namespace std;
bool UnWanted(string & line)
{
// any selection criteria you like
return (line.find("P2") != string::npos || line.find("P3") != string::npos);
}
void splitString(string str, string delimiter = " ")
{
int start = 0;
int end = str.find(delimiter);
while (end != -1) {
cout << str.substr(start, end - start) << endl;
start = end + delimiter.size();
end = str.find(delimiter, start);
}
cout << str.substr(start, end - start);
}
int main()
{
int calib_num = 0;
bool UnWanted_word;
string line;
string calib_txt = "../config/cali_0004.txt";
ifstream calib;
calib.open(calib_txt);
if (calib.is_open())
{
while(!calib.eof()) {
getline(calib, line);
calib_num ++;
if (UnWanted(line))
{ printf("ignore R2 or R3 \n");
continue;}
splitString(line, " ");
// printf("%s", line.c_str());
// cout << line << endl;
// istringstream iss(line);
// double a, b;
// if (!(iss >> a >> b)) { break; } // error
if (calib_num > 4) {break; } // extract first two lines of calibratation file
}
calib.close();
}
else cout << "Unable to open file";
return 0;
}
运行结果
标定位置介绍
采用的双目灰度数据集部分
实际上Camera0位于中心,所以没有外参矩阵;只有Camera1有