moved filesystem to a separate header

This commit is contained in:
Vladyslav Usenko 2019-10-09 18:45:59 +02:00
parent 8d2da587cf
commit b7e9c2e4c9
13 changed files with 24 additions and 48 deletions

View File

@ -53,9 +53,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <basalt/imu/imu_types.h> #include <basalt/imu/imu_types.h>
#include <basalt/optical_flow/optical_flow.h> #include <basalt/optical_flow/optical_flow.h>
#include <basalt/calibration/calibration.hpp> #include <basalt/calibration/calibration.hpp>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
namespace basalt { namespace basalt {

View File

@ -66,11 +66,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace basalt { namespace basalt {
inline bool file_exists(const std::string &name) {
std::ifstream f(name.c_str());
return f.good();
}
struct ImageData { struct ImageData {
ImageData() : exposure(0) {} ImageData() : exposure(0) {}

View File

@ -36,9 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define DATASET_IO_EUROC_H #define DATASET_IO_EUROC_H
#include <basalt/io/dataset_io.h> #include <basalt/io/dataset_io.h>
#include <basalt/utils/filesystem.h>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#include <opencv2/highgui/highgui.hpp> #include <opencv2/highgui/highgui.hpp>
@ -99,7 +97,7 @@ class EurocVioDataset : public VioDataset {
std::string full_image_path = std::string full_image_path =
path + folder[i] + "data/" + image_path[t_ns]; 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); cv::Mat img = cv::imread(full_image_path, cv::IMREAD_UNCHANGED);
if (img.type() == CV_8UC1) { if (img.type() == CV_8UC1) {
@ -169,20 +167,20 @@ class EurocIO : public DatasetIoInterface {
read_imu_data(path + "/mav0/imu0/"); read_imu_data(path + "/mav0/imu0/");
if (!load_mocap_as_gt && 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/"); 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/"); 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/"); read_gt_data_pose(path + "/mav0/mocap0/");
} }
data->exposure_times.resize(data->num_cams); 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; std::cout << "Loading exposure times for cam0" << std::endl;
read_exposure(path + "/mav0/cam0/", data->exposure_times[0]); 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; std::cout << "Loading exposure times for cam1" << std::endl;
read_exposure(path + "/mav0/cam1/", data->exposure_times[1]); read_exposure(path + "/mav0/cam1/", data->exposure_times[1]);
} }

View File

@ -36,9 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma once #pragma once
#include <basalt/io/dataset_io.h> #include <basalt/io/dataset_io.h>
#include <basalt/utils/filesystem.h>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#include <opencv2/highgui/highgui.hpp> #include <opencv2/highgui/highgui.hpp>
@ -95,7 +93,7 @@ class KittiVioDataset : public VioDataset {
for (size_t i = 0; i < num_cams; i++) { for (size_t i = 0; i < num_cams; i++) {
std::string full_image_path = path + folder[i] + image_path[t_ns]; 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); cv::Mat img = cv::imread(full_image_path, cv::IMREAD_UNCHANGED);
if (img.type() == CV_8UC1) { if (img.type() == CV_8UC1) {
@ -140,7 +138,7 @@ class KittiIO : public DatasetIoInterface {
read_image_timestamps(path + "/times.txt"); 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"); read_gt_data_pose(path + "/poses.txt");
} }
} }

View File

@ -52,8 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sensor_msgs/Image.h> #include <sensor_msgs/Image.h>
#include <sensor_msgs/Imu.h> #include <sensor_msgs/Imu.h>
#include <experimental/filesystem> #include <basalt/utils/filesystem.h>
namespace fs = std::experimental::filesystem;
namespace basalt { namespace basalt {

View File

@ -36,9 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma once #pragma once
#include <basalt/io/dataset_io.h> #include <basalt/io/dataset_io.h>
#include <basalt/utils/filesystem.h>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#include <opencv2/highgui/highgui.hpp> #include <opencv2/highgui/highgui.hpp>
@ -99,7 +97,7 @@ class UzhVioDataset : public VioDataset {
path + "/" + path + "/" +
(i == 0 ? left_image_path.at(t_ns) : right_image_path.at(t_ns)); (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); cv::Mat img = cv::imread(full_image_path, cv::IMREAD_UNCHANGED);
if (img.type() == CV_8UC1) { if (img.type() == CV_8UC1) {
@ -182,7 +180,7 @@ class UzhIO : public DatasetIoInterface {
std::cout << "Loaded " << data->get_gyro_data().size() << " imu msgs." std::cout << "Loaded " << data->get_gyro_data().size() << " imu msgs."
<< std::endl; << std::endl;
if (file_exists(path + "/groundtruth.txt")) { if (fs::exists(path + "/groundtruth.txt")) {
read_gt_data_pose(path + "/groundtruth.txt"); read_gt_data_pose(path + "/groundtruth.txt");
} }

View File

@ -0,0 +1,4 @@
#pragma once
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;

View File

@ -43,8 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <basalt/serialization/headers_serialization.h> #include <basalt/serialization/headers_serialization.h>
#include <experimental/filesystem> #include <basalt/utils/filesystem.h>
namespace fs = std::experimental::filesystem;
namespace basalt { namespace basalt {

View File

@ -36,9 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <basalt/io/marg_data_io.h> #include <basalt/io/marg_data_io.h>
#include <basalt/serialization/headers_serialization.h> #include <basalt/serialization/headers_serialization.h>
#include <basalt/utils/filesystem.h>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
namespace basalt { namespace basalt {

View File

@ -56,6 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <basalt/io/marg_data_io.h> #include <basalt/io/marg_data_io.h>
#include <basalt/optimization/accumulator.h> #include <basalt/optimization/accumulator.h>
#include <basalt/spline/se3_spline.h> #include <basalt/spline/se3_spline.h>
#include <basalt/utils/filesystem.h>
#include <basalt/utils/imu_types.h> #include <basalt/utils/imu_types.h>
#include <basalt/utils/nfr.h> #include <basalt/utils/nfr.h>
#include <basalt/utils/vis_utils.h> #include <basalt/utils/vis_utils.h>
@ -63,12 +64,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <basalt/vi_estimator/vio_estimator.h> #include <basalt/vi_estimator/vio_estimator.h>
#include <basalt/calibration/calibration.hpp> #include <basalt/calibration/calibration.hpp>
#include <experimental/filesystem>
#include <basalt/serialization/headers_serialization.h> #include <basalt/serialization/headers_serialization.h>
namespace fs = std::experimental::filesystem;
using basalt::POSE_SIZE; using basalt::POSE_SIZE;
using basalt::POSE_VEL_BIAS_SIZE; using basalt::POSE_VEL_BIAS_SIZE;

View File

@ -56,6 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <basalt/io/marg_data_io.h> #include <basalt/io/marg_data_io.h>
#include <basalt/optimization/accumulator.h> #include <basalt/optimization/accumulator.h>
#include <basalt/spline/se3_spline.h> #include <basalt/spline/se3_spline.h>
#include <basalt/utils/filesystem.h>
#include <basalt/utils/imu_types.h> #include <basalt/utils/imu_types.h>
#include <basalt/utils/nfr.h> #include <basalt/utils/nfr.h>
#include <basalt/utils/sim_utils.h> #include <basalt/utils/sim_utils.h>
@ -64,12 +65,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <basalt/vi_estimator/nfr_mapper.h> #include <basalt/vi_estimator/nfr_mapper.h>
#include <basalt/calibration/calibration.hpp> #include <basalt/calibration/calibration.hpp>
#include <experimental/filesystem>
#include <basalt/serialization/headers_serialization.h> #include <basalt/serialization/headers_serialization.h>
namespace fs = std::experimental::filesystem;
using basalt::POSE_SIZE; using basalt::POSE_SIZE;
using basalt::POSE_VEL_BIAS_SIZE; using basalt::POSE_VEL_BIAS_SIZE;

View File

@ -56,11 +56,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <basalt/device/rs_t265.h> #include <basalt/device/rs_t265.h>
#include <basalt/serialization/headers_serialization.h> #include <basalt/serialization/headers_serialization.h>
#include <basalt/utils/filesystem.h>
#include <CLI/CLI.hpp> #include <CLI/CLI.hpp>
#include <cereal/archives/json.hpp> #include <cereal/archives/json.hpp>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
constexpr int UI_WIDTH = 200; constexpr int UI_WIDTH = 200;

View File

@ -42,15 +42,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <basalt/io/dataset_io.h> #include <basalt/io/dataset_io.h>
#include <basalt/serialization/headers_serialization.h> #include <basalt/serialization/headers_serialization.h>
#include <basalt/utils/filesystem.h>
#include <basalt/calibration/calibration.hpp> #include <basalt/calibration/calibration.hpp>
#include <experimental/filesystem>
#include <tbb/tbb.h> #include <tbb/tbb.h>
#include <CLI/CLI.hpp> #include <CLI/CLI.hpp>
namespace fs = std::experimental::filesystem;
basalt::Calibration<double> calib; basalt::Calibration<double> calib;
basalt::MocapCalibration<double> mocap_calib; basalt::MocapCalibration<double> mocap_calib;