diff --git a/event_camera_simulator/esim_data_provider/include/esim/data_provider/data_provider_from_folder.hpp b/event_camera_simulator/esim_data_provider/include/esim/data_provider/data_provider_from_folder.hpp index 4df491e..1dbe0d3 100644 --- a/event_camera_simulator/esim_data_provider/include/esim/data_provider/data_provider_from_folder.hpp +++ b/event_camera_simulator/esim_data_provider/include/esim/data_provider/data_provider_from_folder.hpp @@ -35,7 +35,8 @@ private: std::string path_to_data_folder_; std::ifstream images_in_str_; const char delimiter_{','}; - const size_t num_tokens_in_line_ = 3; // stamp, image, depth + const size_t num_tokens_in_line_ = 2; // stamp, image + bool finished_parsing_; SimulatorData sim_data_; }; diff --git a/event_camera_simulator/esim_data_provider/src/data_provider_from_folder.cpp b/event_camera_simulator/esim_data_provider/src/data_provider_from_folder.cpp index 132d589..fb61a31 100644 --- a/event_camera_simulator/esim_data_provider/src/data_provider_from_folder.cpp +++ b/event_camera_simulator/esim_data_provider/src/data_provider_from_folder.cpp @@ -1,21 +1,26 @@ #include #include #include +#include namespace event_camera_simulator { DataProviderFromFolder::DataProviderFromFolder(const std::string& path_to_data_folder) : DataProviderBase(DataProviderType::Folder), - path_to_data_folder_(path_to_data_folder) + path_to_data_folder_(path_to_data_folder), + finished_parsing_(false) { // Load CSV image file images_in_str_.open(ze::joinPath(path_to_data_folder, "images.csv")); CHECK(images_in_str_.is_open()); - // Load camera rig - camera_rig_ = ze::cameraRigFromYaml(ze::joinPath(path_to_data_folder, "calib.yaml")); - CHECK(camera_rig_); - CHECK_EQ(camera_rig_->size(), 1u) << "Only one camera in the rig is supported at the moment"; + // Create dummy camera rig + // these intrinsic values are filled with garbage (width = height = 1) since the actual values are not known + ze::CameraVector cameras; + cameras.emplace_back(ze::createEquidistantCameraShared(1, 1, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); + ze::TransformationVector extrinsics; + extrinsics.push_back(ze::Transformation()); + camera_rig_ = std::make_shared(extrinsics, cameras, "camera"); // Allocate memory for image data sim_data_.images.emplace_back(ImagePtr(new Image( @@ -46,6 +51,8 @@ bool DataProviderFromFolder::spinOnce() std::string line; if(!getline(images_in_str_, line)) { + VLOG(1) << "Finished parsing images.csv file"; + finished_parsing_ = true; return false; } @@ -55,12 +62,9 @@ bool DataProviderFromFolder::spinOnce() CHECK_GE(items.size(), num_tokens_in_line_); int64_t stamp = getTimeStamp(items[0]); - const std::string& path_to_image = ze::joinPath(path_to_data_folder_, "frame", "cam_0", items[1]); + const std::string& path_to_image = ze::joinPath(path_to_data_folder_, items[1]); cv::Mat image = cv::imread(path_to_image, 0); CHECK(image.data) << "Could not load image from file: " << path_to_image; - CHECK(image.rows == camera_rig_->at(0).height() - && image.cols == camera_rig_->at(0).width()) << "The image size in the data folder and the image size" - "specified in the camera rig do not match"; VLOG(3) << "Read image from file: " << path_to_image; image.convertTo(*sim_data_.images[0], cv::DataType::type, 1./255.); @@ -77,7 +81,7 @@ bool DataProviderFromFolder::spinOnce() bool DataProviderFromFolder::ok() const { - if (!running_) + if (!running_ || finished_parsing_) { VLOG(1) << "Data Provider was paused/terminated."; return false;