diff --git a/include/basalt/device/rs_t265.h b/include/basalt/device/rs_t265.h index de00043..e550e27 100644 --- a/include/basalt/device/rs_t265.h +++ b/include/basalt/device/rs_t265.h @@ -53,9 +53,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include - -namespace fs = std::experimental::filesystem; namespace basalt { diff --git a/include/basalt/io/dataset_io.h b/include/basalt/io/dataset_io.h index 7aa8458..fd76a5f 100644 --- a/include/basalt/io/dataset_io.h +++ b/include/basalt/io/dataset_io.h @@ -66,11 +66,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace basalt { -inline bool file_exists(const std::string &name) { - std::ifstream f(name.c_str()); - return f.good(); -} - struct ImageData { ImageData() : exposure(0) {} diff --git a/include/basalt/io/dataset_io_euroc.h b/include/basalt/io/dataset_io_euroc.h index fd3847c..dd3d98e 100644 --- a/include/basalt/io/dataset_io_euroc.h +++ b/include/basalt/io/dataset_io_euroc.h @@ -36,9 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define DATASET_IO_EUROC_H #include - -#include -namespace fs = std::experimental::filesystem; +#include #include @@ -99,7 +97,7 @@ class EurocVioDataset : public VioDataset { std::string full_image_path = path + folder[i] + "data/" + image_path[t_ns]; - if (file_exists(full_image_path)) { + if (fs::exists(full_image_path)) { cv::Mat img = cv::imread(full_image_path, cv::IMREAD_UNCHANGED); if (img.type() == CV_8UC1) { @@ -169,20 +167,20 @@ class EurocIO : public DatasetIoInterface { read_imu_data(path + "/mav0/imu0/"); if (!load_mocap_as_gt && - file_exists(path + "/mav0/state_groundtruth_estimate0/data.csv")) { + fs::exists(path + "/mav0/state_groundtruth_estimate0/data.csv")) { read_gt_data_state(path + "/mav0/state_groundtruth_estimate0/"); - } else if (!load_mocap_as_gt && file_exists(path + "/mav0/gt/data.csv")) { + } else if (!load_mocap_as_gt && fs::exists(path + "/mav0/gt/data.csv")) { read_gt_data_pose(path + "/mav0/gt/"); - } else if (file_exists(path + "/mav0/mocap0/data.csv")) { + } else if (fs::exists(path + "/mav0/mocap0/data.csv")) { read_gt_data_pose(path + "/mav0/mocap0/"); } data->exposure_times.resize(data->num_cams); - if (file_exists(path + "/mav0/cam0/exposure.csv")) { + if (fs::exists(path + "/mav0/cam0/exposure.csv")) { std::cout << "Loading exposure times for cam0" << std::endl; read_exposure(path + "/mav0/cam0/", data->exposure_times[0]); } - if (file_exists(path + "/mav0/cam1/exposure.csv")) { + if (fs::exists(path + "/mav0/cam1/exposure.csv")) { std::cout << "Loading exposure times for cam1" << std::endl; read_exposure(path + "/mav0/cam1/", data->exposure_times[1]); } diff --git a/include/basalt/io/dataset_io_kitti.h b/include/basalt/io/dataset_io_kitti.h index 74ca418..65faed6 100644 --- a/include/basalt/io/dataset_io_kitti.h +++ b/include/basalt/io/dataset_io_kitti.h @@ -36,9 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #include - -#include -namespace fs = std::experimental::filesystem; +#include #include @@ -95,7 +93,7 @@ class KittiVioDataset : public VioDataset { for (size_t i = 0; i < num_cams; i++) { std::string full_image_path = path + folder[i] + image_path[t_ns]; - if (file_exists(full_image_path)) { + if (fs::exists(full_image_path)) { cv::Mat img = cv::imread(full_image_path, cv::IMREAD_UNCHANGED); if (img.type() == CV_8UC1) { @@ -140,7 +138,7 @@ class KittiIO : public DatasetIoInterface { read_image_timestamps(path + "/times.txt"); - if (file_exists(path + "/poses.txt")) { + if (fs::exists(path + "/poses.txt")) { read_gt_data_pose(path + "/poses.txt"); } } diff --git a/include/basalt/io/dataset_io_rosbag.h b/include/basalt/io/dataset_io_rosbag.h index 638bf4b..83a139d 100644 --- a/include/basalt/io/dataset_io_rosbag.h +++ b/include/basalt/io/dataset_io_rosbag.h @@ -52,8 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include -namespace fs = std::experimental::filesystem; +#include namespace basalt { diff --git a/include/basalt/io/dataset_io_uzh.h b/include/basalt/io/dataset_io_uzh.h index 361c5b8..239a715 100644 --- a/include/basalt/io/dataset_io_uzh.h +++ b/include/basalt/io/dataset_io_uzh.h @@ -36,9 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #include - -#include -namespace fs = std::experimental::filesystem; +#include #include @@ -99,7 +97,7 @@ class UzhVioDataset : public VioDataset { path + "/" + (i == 0 ? left_image_path.at(t_ns) : right_image_path.at(t_ns)); - if (file_exists(full_image_path)) { + if (fs::exists(full_image_path)) { cv::Mat img = cv::imread(full_image_path, cv::IMREAD_UNCHANGED); if (img.type() == CV_8UC1) { @@ -182,7 +180,7 @@ class UzhIO : public DatasetIoInterface { std::cout << "Loaded " << data->get_gyro_data().size() << " imu msgs." << std::endl; - if (file_exists(path + "/groundtruth.txt")) { + if (fs::exists(path + "/groundtruth.txt")) { read_gt_data_pose(path + "/groundtruth.txt"); } diff --git a/include/basalt/utils/filesystem.h b/include/basalt/utils/filesystem.h new file mode 100644 index 0000000..4629bf8 --- /dev/null +++ b/include/basalt/utils/filesystem.h @@ -0,0 +1,4 @@ +#pragma once + +#include +namespace fs = std::experimental::filesystem; diff --git a/src/calibration/cam_calib.cpp b/src/calibration/cam_calib.cpp index 8eb2c5d..b2c5ef9 100644 --- a/src/calibration/cam_calib.cpp +++ b/src/calibration/cam_calib.cpp @@ -43,8 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include -namespace fs = std::experimental::filesystem; +#include namespace basalt { diff --git a/src/io/marg_data_io.cpp b/src/io/marg_data_io.cpp index 7e30677..6a7eef2 100644 --- a/src/io/marg_data_io.cpp +++ b/src/io/marg_data_io.cpp @@ -36,9 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include - -#include -namespace fs = std::experimental::filesystem; +#include namespace basalt { diff --git a/src/mapper.cpp b/src/mapper.cpp index a214d67..2b5c6ab 100644 --- a/src/mapper.cpp +++ b/src/mapper.cpp @@ -56,6 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include #include #include @@ -63,12 +64,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include - #include -namespace fs = std::experimental::filesystem; - using basalt::POSE_SIZE; using basalt::POSE_VEL_BIAS_SIZE; diff --git a/src/mapper_sim.cpp b/src/mapper_sim.cpp index 0645f8f..f1dec05 100644 --- a/src/mapper_sim.cpp +++ b/src/mapper_sim.cpp @@ -56,6 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include #include #include @@ -64,12 +65,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include - #include -namespace fs = std::experimental::filesystem; - using basalt::POSE_SIZE; using basalt::POSE_VEL_BIAS_SIZE; diff --git a/src/rs_t265_record.cpp b/src/rs_t265_record.cpp index f3f3913..f440008 100644 --- a/src/rs_t265_record.cpp +++ b/src/rs_t265_record.cpp @@ -56,11 +56,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include #include -#include - -namespace fs = std::experimental::filesystem; constexpr int UI_WIDTH = 200; diff --git a/src/time_alignment.cpp b/src/time_alignment.cpp index 588e6e2..99e0694 100644 --- a/src/time_alignment.cpp +++ b/src/time_alignment.cpp @@ -42,15 +42,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include -#include #include #include -namespace fs = std::experimental::filesystem; - basalt::Calibration calib; basalt::MocapCalibration mocap_calib;