ReUseX  0.0.1
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
RTABMapDatabase.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#pragma once
5
6#include <filesystem>
7#include <map>
8#include <memory>
9#include <vector>
10
11#include <opencv2/core/mat.hpp>
12
13// Forward declarations to avoid including RTABMap headers
14namespace rtabmap {
15class Transform;
16class Link;
17class Signature;
18} // namespace rtabmap
19
20namespace ReUseX::io {
21
37public:
45 explicit RTABMapDatabase(std::filesystem::path dbPath, bool readOnly = false);
46
51
52 // Non-copyable (RAII resource management)
55
56 // Movable
58 RTABMapDatabase& operator=(RTABMapDatabase&&) noexcept;
59
60 // --- Core Database Operations ---
61
66 bool isOpen() const noexcept;
67
72 const std::filesystem::path& getPath() const noexcept;
73
78 void validateSchema() const;
79
80 // --- Node Operations ---
81
88 std::vector<int> getNodeIds(bool ignoreChildren = false) const;
89
100 cv::Mat getImage(int nodeId) const;
101
102 // --- Graph Operations ---
103
118 std::map<int, rtabmap::Transform>& poses,
119 std::multimap<int, rtabmap::Link>& links,
120 std::map<int, rtabmap::Signature>* signatures = nullptr,
121 bool optimized = true,
122 bool withImages = false,
123 bool withScan = false) const;
124
125 // --- Segmentation Table Operations ---
126
133 bool hasSegmentation(int nodeId) const;
134
146 cv::Mat getLabels(int nodeId) const;
147
160 void saveLabels(int nodeId, const cv::Mat& labels, bool autoRotate = true);
161
173 void saveLabels(const std::vector<int>& nodeIds,
174 const std::vector<cv::Mat>& labels,
175 bool autoRotate = true);
176
177private:
178 // Pimpl idiom to hide RTABMap dependencies
179 class Impl;
180 std::unique_ptr<Impl> impl_;
181};
182
183} // namespace ReUseX::io
RTABMapDatabase(std::filesystem::path dbPath, bool readOnly=false)
Opens an RTABMap database and validates its schema.
const std::filesystem::path & getPath() const noexcept
Get the path to the database file.
RTABMapDatabase & operator=(const RTABMapDatabase &)=delete
cv::Mat getImage(int nodeId) const
Get image data for a specific node.
bool isOpen() const noexcept
Check if database connection is open.
bool hasSegmentation(int nodeId) const
Check if a node has segmentation labels stored.
~RTABMapDatabase()
Destructor closes database connection.
RTABMapDatabase(RTABMapDatabase &&) noexcept
std::vector< int > getNodeIds(bool ignoreChildren=false) const
Get list of all node IDs in the database.
void getGraph(std::map< int, rtabmap::Transform > &poses, std::multimap< int, rtabmap::Link > &links, std::map< int, rtabmap::Signature > *signatures=nullptr, bool optimized=true, bool withImages=false, bool withScan=false) const
Retrieve the SLAM graph (poses, links, signatures).
RTABMapDatabase(const RTABMapDatabase &)=delete
void saveLabels(int nodeId, const cv::Mat &labels, bool autoRotate=true)
Save segmentation labels for a single node.
void validateSchema() const
Validate that required RTABMap tables exist.
cv::Mat getLabels(int nodeId) const
Get segmentation labels for a node.