|
ReUseX
0.0.1
3D Point Cloud Processing for Building Reuse
|
Core database class that wraps RTABMap's database functionality. More...
#include <RTABMapDatabase.hpp>
Public Member Functions | |
| RTABMapDatabase (std::filesystem::path dbPath, bool readOnly=false) | |
| Opens an RTABMap database and validates its schema. | |
| ~RTABMapDatabase () | |
| Destructor closes database connection. | |
| RTABMapDatabase (const RTABMapDatabase &)=delete | |
| RTABMapDatabase & | operator= (const RTABMapDatabase &)=delete |
| RTABMapDatabase (RTABMapDatabase &&) noexcept | |
| RTABMapDatabase & | operator= (RTABMapDatabase &&) noexcept |
| bool | isOpen () const noexcept |
| Check if database connection is open. | |
| const std::filesystem::path & | getPath () const noexcept |
| Get the path to the database file. | |
| void | validateSchema () const |
| Validate that required RTABMap tables exist. | |
| std::vector< int > | getNodeIds (bool ignoreChildren=false) const |
| Get list of all node IDs in the database. | |
| cv::Mat | getImage (int nodeId) const |
| Get image data for a specific node. | |
| 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). | |
| bool | hasSegmentation (int nodeId) const |
| Check if a node has segmentation labels stored. | |
| cv::Mat | getLabels (int nodeId) const |
| Get segmentation labels for a node. | |
| void | saveLabels (int nodeId, const cv::Mat &labels, bool autoRotate=true) |
| Save segmentation labels for a single node. | |
| void | saveLabels (const std::vector< int > &nodeIds, const std::vector< cv::Mat > &labels, bool autoRotate=true) |
| Save segmentation labels for multiple nodes (batch operation). | |
Core database class that wraps RTABMap's database functionality.
This class provides a unified interface for accessing RTABMap databases, including both the core RTABMap tables (Node, Data, Link) and custom extensions (Segmentation table for labels).
The class uses RAII for resource management and the Pimpl idiom to hide RTABMap implementation details. It is not thread-safe; create separate instances for each thread if concurrent access is needed.
Thread Safety: NOT thread-safe. sqlite3 connections should not be shared between threads. Create per-thread instances if needed.
Definition at line 36 of file RTABMapDatabase.hpp.
|
explicit |
Opens an RTABMap database and validates its schema.
| dbPath | Path to the database file |
| readOnly | If true, opens database in read-only mode |
| std::runtime_error | if database cannot be opened or schema is invalid |
Referenced by operator=(), operator=(), RTABMapDatabase(), and RTABMapDatabase().
| ReUseX::io::RTABMapDatabase::~RTABMapDatabase | ( | ) |
Destructor closes database connection.
|
delete |
References RTABMapDatabase().
|
noexcept |
References RTABMapDatabase().
| void ReUseX::io::RTABMapDatabase::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).
This uses RTABMap's high-level Rtabmap class to extract graph data.
| poses | Output map of node IDs to 3D transforms |
| links | Output multimap of node IDs to links (edges) |
| signatures | Optional output map of node IDs to full signatures |
| optimized | If true, return optimized poses |
| withImages | If true, include image data in signatures |
| withScan | If true, include laser scan data in signatures |
| std::runtime_error | if graph retrieval fails |
References getGraph().
Referenced by getGraph().
| cv::Mat ReUseX::io::RTABMapDatabase::getImage | ( | int | nodeId | ) | const |
Get image data for a specific node.
Retrieves the image from the Data table and applies 90° clockwise rotation to match RTABMap's coordinate convention.
| nodeId | The node ID to retrieve image for |
| std::runtime_error | if database access fails |
References getImage().
Referenced by getImage().
| cv::Mat ReUseX::io::RTABMapDatabase::getLabels | ( | int | nodeId | ) | const |
Get segmentation labels for a node.
Returns labels as CV_32S with -1 for unlabeled/background pixels and 0+ for class labels. Applies 90° clockwise rotation to match the image coordinate system.
| nodeId | Node ID to retrieve labels for |
| std::runtime_error | if database access fails |
References getLabels().
Referenced by getLabels().
| std::vector< int > ReUseX::io::RTABMapDatabase::getNodeIds | ( | bool | ignoreChildren = false | ) | const |
Get list of all node IDs in the database.
| ignoreChildren | If true, only return parent nodes (not children) |
References getNodeIds().
Referenced by getNodeIds().
|
noexcept |
| bool ReUseX::io::RTABMapDatabase::hasSegmentation | ( | int | nodeId | ) | const |
Check if a node has segmentation labels stored.
| nodeId | Node ID to check |
References hasSegmentation().
Referenced by hasSegmentation().
|
noexcept |
|
delete |
References RTABMapDatabase().
|
noexcept |
References RTABMapDatabase().
| void ReUseX::io::RTABMapDatabase::saveLabels | ( | const std::vector< int > & | nodeIds, |
| const std::vector< cv::Mat > & | labels, | ||
| bool | autoRotate = true ) |
Save segmentation labels for multiple nodes (batch operation).
Uses a database transaction for efficiency. All nodes must exist in the Node table or the entire operation fails.
| nodeIds | Vector of node IDs |
| labels | Vector of label Mats (must match nodeIds length) |
| autoRotate | If true, applies 90° counterclockwise rotation before saving |
| std::runtime_error | if sizes don't match, nodes don't exist, or save fails |
References saveLabels().
| void ReUseX::io::RTABMapDatabase::saveLabels | ( | int | nodeId, |
| const cv::Mat & | labels, | ||
| bool | autoRotate = true ) |
Save segmentation labels for a single node.
Labels should be CV_32S with -1 for unlabeled/background and 0+ for class labels. Internally converts to CV_16U with +1 offset for storage (0 = background).
| nodeId | Node ID to save labels for |
| labels | OpenCV Mat with labels (CV_32S) |
| autoRotate | If true, applies 90° counterclockwise rotation before saving |
| std::runtime_error | if node doesn't exist or save fails |
References saveLabels().
Referenced by saveLabels(), and saveLabels().
| void ReUseX::io::RTABMapDatabase::validateSchema | ( | ) | const |
Validate that required RTABMap tables exist.
| std::runtime_error | if required tables are missing |
References validateSchema().
Referenced by validateSchema().