Function bodies 2,155 total
read_file_list function · python · L49-L71 (23 LOC)evaluation/associate.py
def read_file_list(filename,remove_bounds):
"""
Reads a trajectory from a text file.
File format:
The file format is "stamp d1 d2 d3 ...", where stamp denotes the time stamp (to be matched)
and "d1 d2 d3.." is arbitary data (e.g., a 3D position and 3D orientation) associated to this timestamp.
Input:
filename -- File name
Output:
dict -- dictionary of (stamp,data) tuples
"""
file = open(filename)
data = file.read()
lines = data.replace(","," ").replace("\t"," ").split("\n")
if remove_bounds:
lines = lines[100:-100]
list = [[v.strip() for v in line.split(" ") if v.strip()!=""] for line in lines if len(line)>0 and line[0]!="#"]
list = [(float(l[0]),l[1:]) for l in list if len(l)>1]
return dict(list)associate function · python · L73-L103 (31 LOC)evaluation/associate.py
def associate(first_list, second_list,offset,max_difference):
"""
Associate two dictionaries of (stamp,data). As the time stamps never match exactly, we aim
to find the closest match for every input tuple.
Input:
first_list -- first dictionary of (stamp,data) tuples
second_list -- second dictionary of (stamp,data) tuples
offset -- time offset between both dictionaries (e.g., to model the delay between the sensors)
max_difference -- search radius for candidate generation
Output:
matches -- list of matched tuples ((stamp1,data1),(stamp2,data2))
"""
first_keys = first_list.keys()
second_keys = second_list.keys()
potential_matches = [(abs(a - (b + offset)), a, b)
for a in first_keys
for b in second_keys
if abs(a - (b + offset)) < max_difference]
potential_matches.sort()
matches = []
for diff, a, b in potential_matches:
if a indataset class · python · L24-L152 (129 LOC)Examples/Calibration/python_scripts/process_imu.py
class dataset:
# imu_sync = np.zeros((1,7))
# acc = np.zeros((1,7))
# gyro = np.zeros((1,7))
def __init__(self, dirName):
self.name = dirName
self.acc = np.zeros((1, 4))
self.gyro = np.zeros((1, 4))
self.timesCam = np.zeros((1, 1))
timesName = self.name + "/cam0/times.txt"
timeFile = open(timesName, "r")
i = 0
next = 0
for line in timeFile:
currentline = line.split(",")
if i%2 == 0:
self.timesCam[next] = currentline
next = next + 1
self.timesCam = np.pad(self.timesCam, ((0, 1), (0, 0)), mode='constant', constant_values=0)
i = i + 1
print(i, "/", next)
accName = self.name + "/IMU/acc.txt"
accFile = open(accName, "r")
i = 0
for line in accFile:
currentline = line.split(",")
for j in range(0, 4):
self.acc[i][j] = currentline[j]
__init__ method · python · L30-L74 (45 LOC)Examples/Calibration/python_scripts/process_imu.py
def __init__(self, dirName):
self.name = dirName
self.acc = np.zeros((1, 4))
self.gyro = np.zeros((1, 4))
self.timesCam = np.zeros((1, 1))
timesName = self.name + "/cam0/times.txt"
timeFile = open(timesName, "r")
i = 0
next = 0
for line in timeFile:
currentline = line.split(",")
if i%2 == 0:
self.timesCam[next] = currentline
next = next + 1
self.timesCam = np.pad(self.timesCam, ((0, 1), (0, 0)), mode='constant', constant_values=0)
i = i + 1
print(i, "/", next)
accName = self.name + "/IMU/acc.txt"
accFile = open(accName, "r")
i = 0
for line in accFile:
currentline = line.split(",")
for j in range(0, 4):
self.acc[i][j] = currentline[j]
self.acc = np.pad(self.acc, ((0, 1), (0, 0)), mode='constant', constant_values=0)
i = iinterpolate method · python · L76-L109 (34 LOC)Examples/Calibration/python_scripts/process_imu.py
def interpolate(self):
self.imuSync = np.zeros((self.gyro.shape[0], 7))
print("shape = ", self.imuSync.shape)
totAcc = self.acc.shape[0]
totGyro = self.gyro.shape[0]
idxAcc = 0
idxGyro = 0
print(self.acc[idxAcc][0])
print(self.gyro[idxGyro][0])
while (self.acc[idxAcc][0] > self.gyro[idxGyro][0]):
idxGyro = idxGyro + 1
idxSync = 0
while (idxAcc + 1 < totAcc and idxGyro < totGyro):
# variables for interpolation
deltaTimeAcc = self.acc[idxAcc + 1, 0] - self.acc[idxAcc, 0]
deltaAcc = self.acc[idxAcc + 1, 1:4] - self.acc[idxAcc, 1:4]
while (idxGyro < totGyro and self.acc[idxAcc + 1, 0] >= self.gyro[idxGyro, 0]):
self.imuSync[idxSync, 0] = self.gyro[idxGyro, 0]
# Interpolate accelerometer
self.imuSync[idxSync, 4:7] = self.acc[idxAcc, 1:4] + (
self.gyro[idxGyro, 0] plotGyro method · python · L111-L118 (8 LOC)Examples/Calibration/python_scripts/process_imu.py
def plotGyro(self):
for i in range(1, 4):
plt.plot(self.imuSync[:, 0], self.imuSync[:, i], label=str("acc ") + str(i))
plt.xlabel("time (s)")
plt.ylabel("ang. vel. (rad/s)")
plt.title("Gyroscope")
plt.legend()
plt.show()plotAcc method · python · L120-L127 (8 LOC)Examples/Calibration/python_scripts/process_imu.py
def plotAcc(self):
for i in range(4, 7):
plt.plot(self.imuSync[:, 0], self.imuSync[:, i], label=str("acc ") + str(i))
plt.xlabel("time (s)")
plt.ylabel("acc (m/s^2)")
plt.title("Accelerometer")
plt.legend()
plt.show()Repobility · code-quality intelligence · https://repobility.com
saveSynchronized method · python · L129-L142 (14 LOC)Examples/Calibration/python_scripts/process_imu.py
def saveSynchronized(self):
imuName = self.name + "/imu0.csv"
imuFile = open(imuName, "w")
imuFile.write("#timestamp [ns],w_RS_S_x [rad s^-1],w_RS_S_y [rad s^-1],w_RS_S_z [rad s^-1],a_RS_S_x [m s^-2],a_RS_S_y [m s^-2],a_RS_S_z [m s^-2]\n")
for row in self.imuSync:
i = 0
for num in row:
if i == 0:
imuFile.write(str((int)(1e9 * num)))
i = 1
else:
imuFile.write("," + str(num))
imuFile.write("\n")saveCorrectTimes method · python · L144-L152 (9 LOC)Examples/Calibration/python_scripts/process_imu.py
def saveCorrectTimes(self):
timesName = self.name + "/cam0/corrTimes.txt"
timesFile = open(timesName, "w")
print("self.timesCam shape ", self.timesCam.shape)
for row in self.timesCam:
i = 0
for num in row:
timesFile.write(str((int) (num)))
timesFile.write("\n")exit_loop_handler function · cpp · L40-L45 (6 LOC)Examples/Calibration/recorder_realsense_D435i.cc
void exit_loop_handler(int s){
cout << "Finishing session" << endl;
b_continue_session = false;
}get_sensor_option function · cpp · L46-L87 (42 LOC)Examples/Calibration/recorder_realsense_D435i.cc
static rs2_option get_sensor_option(const rs2::sensor& sensor)
{
// Sensors usually have several options to control their properties
// such as Exposure, Brightness etc.
std::cout << "Sensor supports the following options:\n" << std::endl;
// The following loop shows how to iterate over all available options
// Starting from 0 until RS2_OPTION_COUNT (exclusive)
for (int i = 0; i < static_cast<int>(RS2_OPTION_COUNT); i++)
{
rs2_option option_type = static_cast<rs2_option>(i);
//SDK enum types can be streamed to get a string that represents them
std::cout << " " << i << ": " << option_type;
// To control an option, use the following api:
// First, verify that the sensor actually supports this option
if (sensor.supports(option_type))
{
std::cout << std::endl;
// Get a human readable description of the option
const char* description = sensor.get_option_descriptionmain function · cpp · L88-L286 (199 LOC)Examples/Calibration/recorder_realsense_D435i.cc
int main(int argc, char **argv) {
if (argc != 2) {
cerr << endl
<< "Usage: ./recorder_realsense_D435i path_to_saving_folder"
<< endl;
return 1;
}
string directory = string(argv[argc - 1]);
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = exit_loop_handler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
b_continue_session = true;
double offset = 0; // ms
rs2::context ctx;
rs2::device_list devices = ctx.query_devices();
rs2::device selected_device;
if (devices.size() == 0)
{
std::cerr << "No device connected, please connect a RealSense device" << std::endl;
return 0;
}
else
selected_device = devices[0];
std::vector<rs2::sensor> sensors = selected_device.query_sensors();
int index = 0;
// We can now iterate the sensors and print their names
for (rs2::sensor sensorexit_loop_handler function · cpp · L45-L50 (6 LOC)Examples/Calibration/recorder_realsense_T265.cc
void exit_loop_handler(int s){
cout << "Finishing session" << endl;
b_continue_session = false;
}get_sensor_option function · cpp · L51-L92 (42 LOC)Examples/Calibration/recorder_realsense_T265.cc
static rs2_option get_sensor_option(const rs2::sensor& sensor)
{
// Sensors usually have several options to control their properties
// such as Exposure, Brightness etc.
std::cout << "Sensor supports the following options:\n" << std::endl;
// The following loop shows how to iterate over all available options
// Starting from 0 until RS2_OPTION_COUNT (exclusive)
for (int i = 0; i < static_cast<int>(RS2_OPTION_COUNT); i++)
{
rs2_option option_type = static_cast<rs2_option>(i);
//SDK enum types can be streamed to get a string that represents them
std::cout << " " << i << ": " << option_type;
// To control an option, use the following api:
// First, verify that the sensor actually supports this option
if (sensor.supports(option_type))
{
std::cout << std::endl;
// Get a human readable description of the option
const char* description = sensor.get_option_descriptionmain function · cpp · L93-L286 (194 LOC)Examples/Calibration/recorder_realsense_T265.cc
int main(int argc, char **argv) {
if (argc != 2) {
cerr << endl
<< "Usage: ./recorder_realsense_D435i path_to_saving_folder"
<< endl;
return 1;
}
string directory = string(argv[argc - 1]);
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = exit_loop_handler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
b_continue_session = true;
double offset = 0; // ms
// Declare RealSense pipeline, encapsulating the actual device and sensors
rs2::pipeline pipe;
// Create a configuration for configuring the pipeline with a non default profile
rs2::config cfg;
cfg.enable_stream(RS2_STREAM_FISHEYE, 1, RS2_FORMAT_Y8,30);
cfg.enable_stream(RS2_STREAM_FISHEYE, 2, RS2_FORMAT_Y8,30);
cfg.enable_stream(RS2_STREAM_ACCEL, RS2_FORMAT_MOTION_XYZ32F); //, 250); // 63
cfg.enable_stream(RS2_STREAM_GYRO, RS2_FORMAT_MOTION_XYZ32FWant fix-PRs on findings? Install Repobility's GitHub App · github.com/apps/repobility-bot
main function · cpp · L40-L250 (211 LOC)Examples/Monocular-Inertial/mono_inertial_euroc.cc
int main(int argc, char *argv[])
{
if(argc < 5)
{
cerr << endl << "Usage: ./mono_inertial_euroc path_to_vocabulary path_to_settings path_to_sequence_folder_1 path_to_times_file_1 (path_to_image_folder_2 path_to_times_file_2 ... path_to_image_folder_N path_to_times_file_N) " << endl;
return 1;
}
const int num_seq = (argc-3)/2;
cout << "num_seq = " << num_seq << endl;
bool bFileName= (((argc-3) % 2) == 1);
string file_name;
if (bFileName)
{
file_name = string(argv[argc-1]);
cout << "file name: " << file_name << endl;
}
// Load all sequences:
int seq;
vector< vector<string> > vstrImageFilenames;
vector< vector<double> > vTimestampsCam;
vector< vector<cv::Point3f> > vAcc, vGyro;
vector< vector<double> > vTimestampsImu;
vector<int> nImages;
vector<int> nImu;
vector<int> first_imu(num_seq,0);
vstrImageFilenames.resize(num_seq);
vTimestampsCam.resize(num_seq);
vAcc.resizLoadImages function · cpp · L251-L274 (24 LOC)Examples/Monocular-Inertial/mono_inertial_euroc.cc
void LoadImages(const string &strImagePath, const string &strPathTimes,
vector<string> &vstrImages, vector<double> &vTimeStamps)
{
ifstream fTimes;
fTimes.open(strPathTimes.c_str());
vTimeStamps.reserve(5000);
vstrImages.reserve(5000);
while(!fTimes.eof())
{
string s;
getline(fTimes,s);
if(!s.empty())
{
stringstream ss;
ss << s;
vstrImages.push_back(strImagePath + "/" + ss.str() + ".png");
double t;
ss >> t;
vTimeStamps.push_back(t/1e9);
}
}
}LoadIMU function · cpp · L275-L310 (36 LOC)Examples/Monocular-Inertial/mono_inertial_euroc.cc
void LoadIMU(const string &strImuPath, vector<double> &vTimeStamps, vector<cv::Point3f> &vAcc, vector<cv::Point3f> &vGyro)
{
ifstream fImu;
fImu.open(strImuPath.c_str());
vTimeStamps.reserve(5000);
vAcc.reserve(5000);
vGyro.reserve(5000);
while(!fImu.eof())
{
string s;
getline(fImu,s);
if (s[0] == '#')
continue;
if(!s.empty())
{
string item;
size_t pos = 0;
double data[7];
int count = 0;
while ((pos = s.find(',')) != string::npos) {
item = s.substr(0, pos);
data[count++] = stod(item);
s.erase(0, pos + 1);
}
item = s.substr(0, pos);
data[6] = stod(item);
vTimeStamps.push_back(data[0]/1e9);
vAcc.push_back(cv::Point3f(data[4],data[5],data[6]));
vGyro.push_back(cv::Point3f(data[1],data[2],data[3]));
}
}
}exit_loop_handler function · cpp · L40-L45 (6 LOC)Examples/Monocular-Inertial/mono_inertial_realsense_D435i.cc
void exit_loop_handler(int s){
cout << "Finishing session" << endl;
b_continue_session = false;
}get_sensor_option function · cpp · L54-L95 (42 LOC)Examples/Monocular-Inertial/mono_inertial_realsense_D435i.cc
static rs2_option get_sensor_option(const rs2::sensor& sensor)
{
// Sensors usually have several options to control their properties
// such as Exposure, Brightness etc.
std::cout << "Sensor supports the following options:\n" << std::endl;
// The following loop shows how to iterate over all available options
// Starting from 0 until RS2_OPTION_COUNT (exclusive)
for (int i = 0; i < static_cast<int>(RS2_OPTION_COUNT); i++)
{
rs2_option option_type = static_cast<rs2_option>(i);
//SDK enum types can be streamed to get a string that represents them
std::cout << " " << i << ": " << option_type;
// To control an option, use the following api:
// First, verify that the sensor actually supports this option
if (sensor.supports(option_type))
{
std::cout << std::endl;
// Get a human readable description of the option
const char* description = sensor.get_option_descriptionmain function · cpp · L96-L413 (318 LOC)Examples/Monocular-Inertial/mono_inertial_realsense_D435i.cc
int main(int argc, char **argv) {
if (argc < 3 || argc > 4) {
cerr << endl
<< "Usage: ./mono_inertial_realsense_D435i path_to_vocabulary path_to_settings (trajectory_file_name)"
<< endl;
return 1;
}
string file_name;
if (argc == 4) {
file_name = string(argv[argc - 1]);
}
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = exit_loop_handler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
b_continue_session = true;
double offset = 0; // ms
rs2::context ctx;
rs2::device_list devices = ctx.query_devices();
rs2::device selected_device;
if (devices.size() == 0)
{
std::cerr << "No device connected, please connect a RealSense device" << std::endl;
return 0;
}
else
selected_device = devices[0];
std::vector<rs2::sensor> sensors = selected_device.query_sensors();
intinterpolateMeasure function · cpp · L414-L452 (39 LOC)Examples/Monocular-Inertial/mono_inertial_realsense_D435i.cc
rs2_vector interpolateMeasure(const double target_time,
const rs2_vector current_data, const double current_time,
const rs2_vector prev_data, const double prev_time)
{
// If there are not previous information, the current data is propagated
if(prev_time == 0)
{
return current_data;
}
rs2_vector increment;
rs2_vector value_interp;
if(target_time > current_time) {
value_interp = current_data;
}
else if(target_time > prev_time)
{
increment.x = current_data.x - prev_data.x;
increment.y = current_data.y - prev_data.y;
increment.z = current_data.z - prev_data.z;
double factor = (target_time - prev_time) / (current_time - prev_time);
value_interp.x = prev_data.x + increment.x * factor;
value_interp.y = prev_data.y + increment.y * factor;
value_interp.z = prev_data.z + increment.z * factor;
// zero interpolatiexit_loop_handler function · cpp · L39-L44 (6 LOC)Examples/Monocular-Inertial/mono_inertial_realsense_t265.cc
void exit_loop_handler(int s){
cout << "Finishing session" << endl;
b_continue_session = false;
}Repobility · open methodology · https://repobility.com/research/
main function · cpp · L49-L343 (295 LOC)Examples/Monocular-Inertial/mono_inertial_realsense_t265.cc
int main(int argc, char **argv)
{
if (argc < 3 || argc > 4) {
cerr << endl
<< "Usage: ./mono_inertial_realsense_t265 path_to_vocabulary path_to_settings (trajectory_file_name)"
<< endl;
return 1;
}
string file_name;
bool bFileName = false;
if (argc == 4) {
file_name = string(argv[argc - 1]);
bFileName = true;
}
ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::IMU_MONOCULAR, true, 0, file_name);
float imageScale = SLAM.GetImageScale();
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = exit_loop_handler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
b_continue_session = true;
double offset = 0; // ms
// Declare RealSense pipeline, encapsulating the actual device and sensors
rs2::pipeline pipe;
// Create a configuration for configuring the pipeline with a non default profile
interpolateMeasure function · cpp · L344-L379 (36 LOC)Examples/Monocular-Inertial/mono_inertial_realsense_t265.cc
rs2_vector interpolateMeasure(const double target_time,
const rs2_vector current_data, const double current_time,
const rs2_vector prev_data, const double prev_time){
// If there are not previous information, the current data is propagated
if(prev_time == 0){
return current_data;
}
rs2_vector increment;
rs2_vector value_interp;
if(target_time > current_time) {
value_interp = current_data;
}
else if(target_time > prev_time){
increment.x = current_data.x - prev_data.x;
increment.y = current_data.y - prev_data.y;
increment.z = current_data.z - prev_data.z;
double factor = (target_time - prev_time) / (current_time - prev_time);
value_interp.x = prev_data.x + increment.x * factor;
value_interp.y = prev_data.y + increment.y * factor;
value_interp.z = prev_data.z + increment.z * factor;
// zero interpolation
main function · cpp · L40-L284 (245 LOC)Examples/Monocular-Inertial/mono_inertial_tum_vi.cc
int main(int argc, char **argv)
{
const int num_seq = (argc-3)/3;
cout << "num_seq = " << num_seq << endl;
bool bFileName= ((argc % 3) == 1);
string file_name;
if (bFileName)
file_name = string(argv[argc-1]);
cout << "file name: " << file_name << endl;
if(argc < 6)
{
cerr << endl << "Usage: ./mono_inertial_tum_vi path_to_vocabulary path_to_settings path_to_image_folder_1 path_to_times_file_1 path_to_imu_data_1 (path_to_image_folder_2 path_to_times_file_2 path_to_imu_data_2 ... path_to_image_folder_N path_to_times_file_N path_to_imu_data_N) (trajectory_file_name)" << endl;
return 1;
}
// Load all sequences:
int seq;
vector< vector<string> > vstrImageFilenames;
vector< vector<double> > vTimestampsCam;
vector< vector<cv::Point3f> > vAcc, vGyro;
vector< vector<double> > vTimestampsImu;
vector<int> nImages;
vector<int> nImu;
vector<int> first_imu(num_seq,0);
vstrImageFilenames.resize(nLoadImagesTUMVI function · cpp · L285-L313 (29 LOC)Examples/Monocular-Inertial/mono_inertial_tum_vi.cc
void LoadImagesTUMVI(const string &strImagePath, const string &strPathTimes,
vector<string> &vstrImages, vector<double> &vTimeStamps)
{
ifstream fTimes;
cout << strImagePath << endl;
cout << strPathTimes << endl;
fTimes.open(strPathTimes.c_str());
vTimeStamps.reserve(5000);
vstrImages.reserve(5000);
while(!fTimes.eof())
{
string s;
getline(fTimes,s);
if(!s.empty())
{
if (s[0] == '#')
continue;
int pos = s.find(' ');
string item = s.substr(0, pos);
vstrImages.push_back(strImagePath + "/" + item + ".png");
double t = stod(item);
vTimeStamps.push_back(t/1e9);
}
}
}LoadIMU function · cpp · L314-L349 (36 LOC)Examples/Monocular-Inertial/mono_inertial_tum_vi.cc
void LoadIMU(const string &strImuPath, vector<double> &vTimeStamps, vector<cv::Point3f> &vAcc, vector<cv::Point3f> &vGyro)
{
ifstream fImu;
fImu.open(strImuPath.c_str());
vTimeStamps.reserve(5000);
vAcc.reserve(5000);
vGyro.reserve(5000);
while(!fImu.eof())
{
string s;
getline(fImu,s);
if (s[0] == '#')
continue;
if(!s.empty())
{
string item;
size_t pos = 0;
double data[7];
int count = 0;
while ((pos = s.find(',')) != string::npos) {
item = s.substr(0, pos);
data[count++] = stod(item);
s.erase(0, pos + 1);
}
item = s.substr(0, pos);
data[6] = stod(item);
vTimeStamps.push_back(data[0]/1e9);
vAcc.push_back(cv::Point3f(data[4],data[5],data[6]));
vGyro.push_back(cv::Point3f(data[1],data[2],data[3]));
}
}
}main function · cpp · L32-L204 (173 LOC)Examples/Monocular/mono_euroc.cc
int main(int argc, char **argv)
{
if(argc < 5)
{
cerr << endl << "Usage: ./mono_euroc path_to_vocabulary path_to_settings path_to_sequence_folder_1 path_to_times_file_1 (path_to_image_folder_2 path_to_times_file_2 ... path_to_image_folder_N path_to_times_file_N) (trajectory_file_name)" << endl;
return 1;
}
const int num_seq = (argc-3)/2;
cout << "num_seq = " << num_seq << endl;
bool bFileName= (((argc-3) % 2) == 1);
string file_name;
if (bFileName)
{
file_name = string(argv[argc-1]);
cout << "file name: " << file_name << endl;
}
// Load all sequences:
int seq;
vector< vector<string> > vstrImageFilenames;
vector< vector<double> > vTimestampsCam;
vector<int> nImages;
vstrImageFilenames.resize(num_seq);
vTimestampsCam.resize(num_seq);
nImages.resize(num_seq);
int tot_images = 0;
for (seq = 0; seq<num_seq; seq++)
{
cout << "Loading images for sequence " << seq LoadImages function · cpp · L205-L228 (24 LOC)Examples/Monocular/mono_euroc.cc
void LoadImages(const string &strImagePath, const string &strPathTimes,
vector<string> &vstrImages, vector<double> &vTimeStamps)
{
ifstream fTimes;
fTimes.open(strPathTimes.c_str());
vTimeStamps.reserve(5000);
vstrImages.reserve(5000);
while(!fTimes.eof())
{
string s;
getline(fTimes,s);
if(!s.empty())
{
stringstream ss;
ss << s;
vstrImages.push_back(strImagePath + "/" + ss.str() + ".png");
double t;
ss >> t;
vTimeStamps.push_back(t*1e-9);
}
}
}main function · cpp · L33-L154 (122 LOC)Examples/Monocular/mono_kitti.cc
int main(int argc, char **argv)
{
if(argc != 4)
{
cerr << endl << "Usage: ./mono_kitti path_to_vocabulary path_to_settings path_to_sequence" << endl;
return 1;
}
// Retrieve paths to images
vector<string> vstrImageFilenames;
vector<double> vTimestamps;
LoadImages(string(argv[3]), vstrImageFilenames, vTimestamps);
int nImages = vstrImageFilenames.size();
// Create SLAM system. It initializes all system threads and gets ready to process frames.
ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::MONOCULAR,true);
float imageScale = SLAM.GetImageScale();
// Vector for tracking time statistics
vector<float> vTimesTrack;
vTimesTrack.resize(nImages);
cout << endl << "-------" << endl;
cout << "Start processing sequence ..." << endl;
cout << "Images in the sequence: " << nImages << endl << endl;
// Main loop
double t_resize = 0.f;
double t_track = 0.f;
cv::Mat im;
for(int ni=0;Repobility · code-quality intelligence platform · https://repobility.com
LoadImages function · cpp · L155-L186 (32 LOC)Examples/Monocular/mono_kitti.cc
void LoadImages(const string &strPathToSequence, vector<string> &vstrImageFilenames, vector<double> &vTimestamps)
{
ifstream fTimes;
string strPathTimeFile = strPathToSequence + "/times.txt";
fTimes.open(strPathTimeFile.c_str());
while(!fTimes.eof())
{
string s;
getline(fTimes,s);
if(!s.empty())
{
stringstream ss;
ss << s;
double t;
ss >> t;
vTimestamps.push_back(t);
}
}
string strPrefixLeft = strPathToSequence + "/image_0/";
const int nTimes = vTimestamps.size();
vstrImageFilenames.resize(nTimes);
for(int i=0; i<nTimes; i++)
{
stringstream ss;
ss << setfill('0') << setw(6) << i;
vstrImageFilenames[i] = strPrefixLeft + ss.str() + ".png";
}
}exit_loop_handler function · cpp · L40-L45 (6 LOC)Examples/Monocular/mono_realsense_D435i.cc
void exit_loop_handler(int s){
cout << "Finishing session" << endl;
b_continue_session = false;
}get_sensor_option function · cpp · L50-L91 (42 LOC)Examples/Monocular/mono_realsense_D435i.cc
static rs2_option get_sensor_option(const rs2::sensor& sensor)
{
// Sensors usually have several options to control their properties
// such as Exposure, Brightness etc.
std::cout << "Sensor supports the following options:\n" << std::endl;
// The following loop shows how to iterate over all available options
// Starting from 0 until RS2_OPTION_COUNT (exclusive)
for (int i = 0; i < static_cast<int>(RS2_OPTION_COUNT); i++)
{
rs2_option option_type = static_cast<rs2_option>(i);
//SDK enum types can be streamed to get a string that represents them
std::cout << " " << i << ": " << option_type;
// To control an option, use the following api:
// First, verify that the sensor actually supports this option
if (sensor.supports(option_type))
{
std::cout << std::endl;
// Get a human readable description of the option
const char* description = sensor.get_option_descriptionmain function · cpp · L92-L291 (200 LOC)Examples/Monocular/mono_realsense_D435i.cc
int main(int argc, char **argv) {
if (argc < 3 || argc > 4) {
cerr << endl
<< "Usage: ./mono_realsense_D435i path_to_vocabulary path_to_settings (trajectory_file_name)"
<< endl;
return 1;
}
string file_name;
if (argc == 4) {
file_name = string(argv[argc - 1]);
}
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = exit_loop_handler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
b_continue_session = true;
double offset = 0; // ms
rs2::context ctx;
rs2::device_list devices = ctx.query_devices();
rs2::device selected_device;
if (devices.size() == 0)
{
std::cerr << "No device connected, please connect a RealSense device" << std::endl;
return 0;
}
else
selected_device = devices[0];
std::vector<rs2::sensor> sensors = selected_device.query_sensors();
int index = exit_loop_handler function · cpp · L37-L42 (6 LOC)Examples/Monocular/mono_realsense_t265.cc
void exit_loop_handler(int s){
cout << "Finishing session" << endl;
b_continue_session = false;
}main function · cpp · L43-L173 (131 LOC)Examples/Monocular/mono_realsense_t265.cc
int main(int argc, char **argv)
{
if(argc < 3 || argc > 4)
{
cerr << endl << "Usage: ./mono_realsense_t265 path_to_vocabulary path_to_settings (trajectory_file_name)" << endl;
return 1;
}
string file_name;
bool bFileName = false;
if (argc == 4)
{
file_name = string(argv[argc-1]);
bFileName = true;
}
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = exit_loop_handler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
b_continue_session = true;
// Declare RealSense pipeline, encapsulating the actual device and sensors
rs2::pipeline pipe;
// Create a configuration for configuring the pipeline with a non default profile
rs2::config cfg;
// Enable the left camera
cfg.enable_stream(RS2_STREAM_FISHEYE, 1, RS2_FORMAT_Y8);
cfg.enable_stream(RS2_STREAM_FISHEYE, 2, RS2_FORMAT_Y8);
rs2::pipeline_profile pmain function · cpp · L32-L204 (173 LOC)Examples/Monocular/mono_tum.cc
int main(int argc, char **argv)
{
if(argc != 4)
{
cerr << endl << "Usage: ./mono_tum path_to_vocabulary path_to_settings path_to_sequence" << endl;
return 1;
}
// Retrieve paths to images
vector<string> vstrImageFilenames;
vector<double> vTimestamps;
string strFile = string(argv[3])+"/times.txt";
LoadImages(strFile, vstrImageFilenames, vTimestamps);
int nImages = vstrImageFilenames.size();
// Create SLAM system. It initializes all system threads and gets ready to process frames.
ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::MONOCULAR,false);
float imageScale = SLAM.GetImageScale();
// Vector for tracking time statistics
vector<float> vTimesTrack;
vTimesTrack.resize(nImages);
cout << endl << "-------" << endl;
cout << "Start processing sequence ..." << endl;
cout << "Images in the sequence: " << nImages << endl << endl;
// Per-frame map points output
string perframe_path = LoadImages function · cpp · L205-L234 (30 LOC)Examples/Monocular/mono_tum.cc
void LoadImages(const string &strFile, vector<string> &vstrImageFilenames, vector<double> &vTimestamps)
{
ifstream f;
f.open(strFile.c_str());
// skip first three lines
// string s0;
// getline(f,s0);
// getline(f,s0);
// getline(f,s0);
cout << "Load images from " << strFile << endl;
while(!f.eof())
{
string s;
getline(f,s);
if(!s.empty())
{
stringstream ss;
ss << s;
string sRGB;
ss >> sRGB;
vstrImageFilenames.push_back("images/"s + sRGB + ".jpg"s);
double t;
ss >> t;
vTimestamps.push_back(t);
}
}
}Repobility · code-quality intelligence · https://repobility.com
main function · cpp · L37-L227 (191 LOC)Examples/Monocular/mono_tum_vi.cc
int main(int argc, char **argv)
{
const int num_seq = (argc-3)/2;
cout << "num_seq = " << num_seq << endl;
bool bFileName= (((argc-3) % 2) == 1);
string file_name;
if (bFileName)
{
file_name = string(argv[argc-1]);
cout << "file name: " << file_name << endl;
}
if(argc < 4)
{
cerr << endl << "Usage: ./mono_tum_vi path_to_vocabulary path_to_settings path_to_image_folder_1 path_to_times_file_1 (path_to_image_folder_2 path_to_times_file_2 ... path_to_image_folder_N path_to_times_file_N) (trajectory_file_name)" << endl;
return 1;
}
// Load all sequences:
int seq;
vector< vector<string> > vstrImageFilenames;
vector< vector<double> > vTimestampsCam;
vector<int> nImages;
vstrImageFilenames.resize(num_seq);
vTimestampsCam.resize(num_seq);
nImages.resize(num_seq);
int tot_images = 0;
for (seq = 0; seq<num_seq; seq++)
{
cout << "Loading images for sequence " << seq << LoadImages function · cpp · L228-L255 (28 LOC)Examples/Monocular/mono_tum_vi.cc
void LoadImages(const string &strImagePath, const string &strPathTimes,
vector<string> &vstrImages, vector<double> &vTimeStamps)
{
ifstream fTimes;
fTimes.open(strPathTimes.c_str());
vTimeStamps.reserve(5000);
vstrImages.reserve(5000);
while(!fTimes.eof())
{
string s;
getline(fTimes,s);
if(!s.empty())
{
if (s[0] == '#')
continue;
int pos = s.find(' ');
string item = s.substr(0, pos);
vstrImages.push_back(strImagePath + "/" + item + ".png");
double t = stod(item);
vTimeStamps.push_back(t/1e9);
}
}
}main function · cpp · L39-L249 (211 LOC)Examples_old/Monocular-Inertial/mono_inertial_euroc.cc
int main(int argc, char *argv[])
{
if(argc < 5)
{
cerr << endl << "Usage: ./mono_inertial_euroc path_to_vocabulary path_to_settings path_to_sequence_folder_1 path_to_times_file_1 (path_to_image_folder_2 path_to_times_file_2 ... path_to_image_folder_N path_to_times_file_N) " << endl;
return 1;
}
const int num_seq = (argc-3)/2;
cout << "num_seq = " << num_seq << endl;
bool bFileName= (((argc-3) % 2) == 1);
string file_name;
if (bFileName)
{
file_name = string(argv[argc-1]);
cout << "file name: " << file_name << endl;
}
// Load all sequences:
int seq;
vector< vector<string> > vstrImageFilenames;
vector< vector<double> > vTimestampsCam;
vector< vector<cv::Point3f> > vAcc, vGyro;
vector< vector<double> > vTimestampsImu;
vector<int> nImages;
vector<int> nImu;
vector<int> first_imu(num_seq,0);
vstrImageFilenames.resize(num_seq);
vTimestampsCam.resize(num_seq);
vAcc.resizLoadImages function · cpp · L250-L273 (24 LOC)Examples_old/Monocular-Inertial/mono_inertial_euroc.cc
void LoadImages(const string &strImagePath, const string &strPathTimes,
vector<string> &vstrImages, vector<double> &vTimeStamps)
{
ifstream fTimes;
fTimes.open(strPathTimes.c_str());
vTimeStamps.reserve(5000);
vstrImages.reserve(5000);
while(!fTimes.eof())
{
string s;
getline(fTimes,s);
if(!s.empty())
{
stringstream ss;
ss << s;
vstrImages.push_back(strImagePath + "/" + ss.str() + ".png");
double t;
ss >> t;
vTimeStamps.push_back(t/1e9);
}
}
}LoadIMU function · cpp · L274-L309 (36 LOC)Examples_old/Monocular-Inertial/mono_inertial_euroc.cc
void LoadIMU(const string &strImuPath, vector<double> &vTimeStamps, vector<cv::Point3f> &vAcc, vector<cv::Point3f> &vGyro)
{
ifstream fImu;
fImu.open(strImuPath.c_str());
vTimeStamps.reserve(5000);
vAcc.reserve(5000);
vGyro.reserve(5000);
while(!fImu.eof())
{
string s;
getline(fImu,s);
if (s[0] == '#')
continue;
if(!s.empty())
{
string item;
size_t pos = 0;
double data[7];
int count = 0;
while ((pos = s.find(',')) != string::npos) {
item = s.substr(0, pos);
data[count++] = stod(item);
s.erase(0, pos + 1);
}
item = s.substr(0, pos);
data[6] = stod(item);
vTimeStamps.push_back(data[0]/1e9);
vAcc.push_back(cv::Point3f(data[4],data[5],data[6]));
vGyro.push_back(cv::Point3f(data[1],data[2],data[3]));
}
}
}exit_loop_handler function · cpp · L40-L45 (6 LOC)Examples_old/Monocular-Inertial/mono_inertial_realsense_D435i.cc
void exit_loop_handler(int s){
cout << "Finishing session" << endl;
b_continue_session = false;
}get_sensor_option function · cpp · L54-L95 (42 LOC)Examples_old/Monocular-Inertial/mono_inertial_realsense_D435i.cc
static rs2_option get_sensor_option(const rs2::sensor& sensor)
{
// Sensors usually have several options to control their properties
// such as Exposure, Brightness etc.
std::cout << "Sensor supports the following options:\n" << std::endl;
// The following loop shows how to iterate over all available options
// Starting from 0 until RS2_OPTION_COUNT (exclusive)
for (int i = 0; i < static_cast<int>(RS2_OPTION_COUNT); i++)
{
rs2_option option_type = static_cast<rs2_option>(i);
//SDK enum types can be streamed to get a string that represents them
std::cout << " " << i << ": " << option_type;
// To control an option, use the following api:
// First, verify that the sensor actually supports this option
if (sensor.supports(option_type))
{
std::cout << std::endl;
// Get a human readable description of the option
const char* description = sensor.get_option_descriptionmain function · cpp · L96-L413 (318 LOC)Examples_old/Monocular-Inertial/mono_inertial_realsense_D435i.cc
int main(int argc, char **argv) {
if (argc < 3 || argc > 4) {
cerr << endl
<< "Usage: ./mono_inertial_realsense_D435i path_to_vocabulary path_to_settings (trajectory_file_name)"
<< endl;
return 1;
}
string file_name;
if (argc == 4) {
file_name = string(argv[argc - 1]);
}
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = exit_loop_handler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
b_continue_session = true;
double offset = 0; // ms
rs2::context ctx;
rs2::device_list devices = ctx.query_devices();
rs2::device selected_device;
if (devices.size() == 0)
{
std::cerr << "No device connected, please connect a RealSense device" << std::endl;
return 0;
}
else
selected_device = devices[0];
std::vector<rs2::sensor> sensors = selected_device.query_sensors();
intWant fix-PRs on findings? Install Repobility's GitHub App · github.com/apps/repobility-bot
interpolateMeasure function · cpp · L414-L452 (39 LOC)Examples_old/Monocular-Inertial/mono_inertial_realsense_D435i.cc
rs2_vector interpolateMeasure(const double target_time,
const rs2_vector current_data, const double current_time,
const rs2_vector prev_data, const double prev_time)
{
// If there are not previous information, the current data is propagated
if(prev_time == 0)
{
return current_data;
}
rs2_vector increment;
rs2_vector value_interp;
if(target_time > current_time) {
value_interp = current_data;
}
else if(target_time > prev_time)
{
increment.x = current_data.x - prev_data.x;
increment.y = current_data.y - prev_data.y;
increment.z = current_data.z - prev_data.z;
double factor = (target_time - prev_time) / (current_time - prev_time);
value_interp.x = prev_data.x + increment.x * factor;
value_interp.y = prev_data.y + increment.y * factor;
value_interp.z = prev_data.z + increment.z * factor;
// zero interpolatiexit_loop_handler function · cpp · L39-L44 (6 LOC)Examples_old/Monocular-Inertial/mono_inertial_realsense_t265.cc
void exit_loop_handler(int s){
cout << "Finishing session" << endl;
b_continue_session = false;
}main function · cpp · L49-L343 (295 LOC)Examples_old/Monocular-Inertial/mono_inertial_realsense_t265.cc
int main(int argc, char **argv)
{
if (argc < 3 || argc > 4) {
cerr << endl
<< "Usage: ./mono_inertial_realsense_t265 path_to_vocabulary path_to_settings (trajectory_file_name)"
<< endl;
return 1;
}
string file_name;
bool bFileName = false;
if (argc == 4) {
file_name = string(argv[argc - 1]);
bFileName = true;
}
ORB_SLAM3::System SLAM(argv[1],argv[2],ORB_SLAM3::System::IMU_MONOCULAR, true, 0, file_name);
float imageScale = SLAM.GetImageScale();
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = exit_loop_handler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
b_continue_session = true;
double offset = 0; // ms
// Declare RealSense pipeline, encapsulating the actual device and sensors
rs2::pipeline pipe;
// Create a configuration for configuring the pipeline with a non default profile
page 1 / 44next ›