ReUseX  0.0.1
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
Dataset.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Povl Filip Sonne-Frederiksen
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#pragma once
6#include <opencv2/core.hpp>
7#include <torch/torch.h>
8
9#include <filesystem>
10#include <memory>
11#include <vector>
12
13// Forward declaration
14namespace ReUseX::io {
15class RTABMapDatabase;
16}
17
26class TorchDataset : public torch::data::datasets::Dataset<TorchDataset> {
27 using Example = torch::data::Example<>;
28
29 public:
34 TorchDataset(std::filesystem::path dbPath = "");
35
45 Example get(size_t index);
46
51 torch::optional<size_t> size() const;
52
59 void save(std::vector<cv::Mat> imgs, torch::Tensor index);
60
61 private:
62 std::shared_ptr<io::RTABMapDatabase> db_;
63 std::vector<int> ids_;
64};
65} // namespace ReUseX::vision::libtorch
Core database class that wraps RTABMap's database functionality.
void save(std::vector< cv::Mat > imgs, torch::Tensor index)
Save label images for multiple nodes.
TorchDataset(std::filesystem::path dbPath="")
Construct TorchDataset from database path.
torch::optional< size_t > size() const
Get the number of samples in the dataset.
Example get(size_t index)
Get a data sample at the given index.