fixed build

This commit is contained in:
matlabbe
2026-04-05 14:53:11 -07:00
parent 5e85e6192b
commit b5c3d8ef4c
4 changed files with 36 additions and 24 deletions
+6 -6
View File
@@ -169,9 +169,9 @@ public:
void loadWords(const std::set<int> & wordIds, std::list<VisualWord *> & vws); // returned words must be freed after usage void loadWords(const std::set<int> & wordIds, std::list<VisualWord *> & vws); // returned words must be freed after usage
// Specific queries... // Specific queries...
void loadNodeData(Signature & signature, bool images = true, bool scan = true, bool userData = true, bool occupancyGrid = true) const; void loadNodeData(Signature & signature, bool images = true, bool scan = true, bool userData = true, bool occupancyGrid = true, bool features = false) const;
void loadNodeData(std::list<Signature *> & signatures, bool images = true, bool scan = true, bool userData = true, bool occupancyGrid = true) const; void loadNodeData(std::list<Signature *> & signatures, bool images = true, bool scan = true, bool userData = true, bool occupancyGrid = true, bool features = false) const;
void getNodeData(int signatureId, SensorData & data, bool images = true, bool scan = true, bool userData = true, bool occupancyGrid = true) const; void getNodeData(int signatureId, SensorData & data, bool images = true, bool scan = true, bool userData = true, bool occupancyGrid = true, bool features = false) const;
bool getCalibration(int signatureId, std::vector<CameraModel> & models, std::vector<StereoCameraModel> & stereoModels) const; bool getCalibration(int signatureId, std::vector<CameraModel> & models, std::vector<StereoCameraModel> & stereoModels) const;
bool getLaserScanInfo(int signatureId, LaserScan & info) const; bool getLaserScanInfo(int signatureId, LaserScan & info) const;
bool getNodeInfo(int signatureId, Transform & pose, int & mapId, int & weight, std::string & label, double & stamp, Transform & groundTruthPose, std::vector<float> & velocity, GPS & gps, EnvSensors & sensors) const; bool getNodeInfo(int signatureId, Transform & pose, int & mapId, int & weight, std::string & label, double & stamp, Transform & groundTruthPose, std::vector<float> & velocity, GPS & gps, EnvSensors & sensors) const;
@@ -285,7 +285,7 @@ protected:
virtual void loadWordsQuery(const std::set<int> & wordIds, std::list<VisualWord *> & vws) const = 0; virtual void loadWordsQuery(const std::set<int> & wordIds, std::list<VisualWord *> & vws) const = 0;
virtual void loadLinksQuery(int signatureId, std::multimap<int, Link> & links, Link::Type type = Link::kUndef) const = 0; virtual void loadLinksQuery(int signatureId, std::multimap<int, Link> & links, Link::Type type = Link::kUndef) const = 0;
virtual void loadNodeDataQuery(std::list<Signature *> & signatures, bool images=true, bool scan=true, bool userData=true, bool occupancyGrid=true) const = 0; virtual void loadNodeDataQuery(std::list<Signature *> & signatures, bool images=true, bool scan=true, bool userData=true, bool occupancyGrid=true, bool features=false) const = 0;
virtual bool getCalibrationQuery(int signatureId, std::vector<CameraModel> & models, std::vector<StereoCameraModel> & stereoModels) const = 0; virtual bool getCalibrationQuery(int signatureId, std::vector<CameraModel> & models, std::vector<StereoCameraModel> & stereoModels) const = 0;
virtual bool getLaserScanInfoQuery(int signatureId, LaserScan & info) const = 0; virtual bool getLaserScanInfoQuery(int signatureId, LaserScan & info) const = 0;
virtual bool getNodeInfoQuery(int signatureId, Transform & pose, int & mapId, int & weight, std::string & label, double & stamp, Transform & groundTruthPose, std::vector<float> & velocity, GPS & gps, EnvSensors & sensors) const = 0; virtual bool getNodeInfoQuery(int signatureId, Transform & pose, int & mapId, int & weight, std::string & label, double & stamp, Transform & groundTruthPose, std::vector<float> & velocity, GPS & gps, EnvSensors & sensors) const = 0;
@@ -304,13 +304,13 @@ protected:
std::vector<unsigned char> serializeFeatures( std::vector<unsigned char> serializeFeatures(
const std::vector<cv::KeyPoint> & keypoints, const std::vector<cv::KeyPoint> & keypoints,
const std::vector<cv::Point3f> & points3D, const std::vector<cv::Point3f> & points3D,
const cv::Mat & descriptors); const cv::Mat & descriptors) const;
bool deserializeFeatures( bool deserializeFeatures(
const unsigned char * compressedData, const unsigned char * compressedData,
unsigned int compressedDataSize, unsigned int compressedDataSize,
std::vector<cv::KeyPoint> & keypoints, std::vector<cv::KeyPoint> & keypoints,
std::vector<cv::Point3f> & points3D, std::vector<cv::Point3f> & points3D,
cv::Mat & descriptors); cv::Mat & descriptors) const;
private: private:
//non-abstract methods //non-abstract methods
@@ -144,7 +144,7 @@ protected:
virtual void loadWordsQuery(const std::set<int> & wordIds, std::list<VisualWord *> & vws) const; virtual void loadWordsQuery(const std::set<int> & wordIds, std::list<VisualWord *> & vws) const;
virtual void loadLinksQuery(int signatureId, std::multimap<int, Link> & links, Link::Type type = Link::kUndef) const; virtual void loadLinksQuery(int signatureId, std::multimap<int, Link> & links, Link::Type type = Link::kUndef) const;
virtual void loadNodeDataQuery(std::list<Signature *> & signatures, bool images=true, bool scan=true, bool userData=true, bool occupancyGrid=true) const; virtual void loadNodeDataQuery(std::list<Signature *> & signatures, bool images=true, bool scan=true, bool userData=true, bool occupancyGrid=true, bool features=false) const;
virtual bool getCalibrationQuery(int signatureId, std::vector<CameraModel> & models, std::vector<StereoCameraModel> & stereoModels) const; virtual bool getCalibrationQuery(int signatureId, std::vector<CameraModel> & models, std::vector<StereoCameraModel> & stereoModels) const;
virtual bool getLaserScanInfoQuery(int signatureId, LaserScan & info) const; virtual bool getLaserScanInfoQuery(int signatureId, LaserScan & info) const;
virtual bool getNodeInfoQuery(int signatureId, Transform & pose, int & mapId, int & weight, std::string & label, double & stamp, Transform & groundTruthPose, std::vector<float> & velocity, GPS & gps, EnvSensors & sensors) const; virtual bool getNodeInfoQuery(int signatureId, Transform & pose, int & mapId, int & weight, std::string & label, double & stamp, Transform & groundTruthPose, std::vector<float> & velocity, GPS & gps, EnvSensors & sensors) const;
@@ -182,6 +182,7 @@ private:
void stepSensorData(sqlite3_stmt * ppStmt, const SensorData & sensorData) const; void stepSensorData(sqlite3_stmt * ppStmt, const SensorData & sensorData) const;
void stepLink(sqlite3_stmt * ppStmt, const Link & link) const; void stepLink(sqlite3_stmt * ppStmt, const Link & link) const;
void stepWordsChanged(sqlite3_stmt * ppStmt, int signatureId, int oldWordId, int newWordId) const; void stepWordsChanged(sqlite3_stmt * ppStmt, int signatureId, int oldWordId, int newWordId) const;
void stepKeypoint(sqlite3_stmt * ppStmt, int nodeId, int wordId, int kptIndex) const;
void stepKeypoint(sqlite3_stmt * ppStmt, int nodeID, int wordId, const cv::KeyPoint & kp, const cv::Point3f & pt, const cv::Mat & descriptor) const; void stepKeypoint(sqlite3_stmt * ppStmt, int nodeID, int wordId, const cv::KeyPoint & kp, const cv::Point3f & pt, const cv::Mat & descriptor) const;
void stepGlobalDescriptor(sqlite3_stmt * ppStmt, int nodeId, const GlobalDescriptor & descriptor) const; void stepGlobalDescriptor(sqlite3_stmt * ppStmt, int nodeId, const GlobalDescriptor & descriptor) const;
void stepOccupancyGridUpdate(sqlite3_stmt * ppStmt, void stepOccupancyGridUpdate(sqlite3_stmt * ppStmt,
+21 -15
View File
@@ -30,6 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "rtabmap/core/Signature.h" #include "rtabmap/core/Signature.h"
#include "rtabmap/core/VisualWord.h" #include "rtabmap/core/VisualWord.h"
#include "rtabmap/core/DBDriverSqlite3.h" #include "rtabmap/core/DBDriverSqlite3.h"
#include "rtabmap/core/Compression.h"
#include "rtabmap/utilite/UConversion.h" #include "rtabmap/utilite/UConversion.h"
#include "rtabmap/utilite/UMath.h" #include "rtabmap/utilite/UMath.h"
#include "rtabmap/utilite/ULogger.h" #include "rtabmap/utilite/ULogger.h"
@@ -665,14 +666,14 @@ void DBDriver::loadWords(const std::set<int> & wordIds, std::list<VisualWord *>
} }
} }
void DBDriver::loadNodeData(Signature & signature, bool images, bool scan, bool userData, bool occupancyGrid) const void DBDriver::loadNodeData(Signature & signature, bool images, bool scan, bool userData, bool occupancyGrid, bool features) const
{ {
std::list<Signature *> signatures; std::list<Signature *> signatures;
signatures.push_back(&signature); signatures.push_back(&signature);
this->loadNodeData(signatures, images, scan, userData, occupancyGrid); this->loadNodeData(signatures, images, scan, userData, occupancyGrid, features);
} }
void DBDriver::loadNodeData(std::list<Signature *> & signatures, bool images, bool scan, bool userData, bool occupancyGrid) const void DBDriver::loadNodeData(std::list<Signature *> & signatures, bool images, bool scan, bool userData, bool occupancyGrid, bool features) const
{ {
// Don't look in the trash, we assume that if we want to load // Don't look in the trash, we assume that if we want to load
// data of a signature, it is not in thrash! Print an error if so. // data of a signature, it is not in thrash! Print an error if so.
@@ -688,14 +689,14 @@ void DBDriver::loadNodeData(std::list<Signature *> & signatures, bool images, bo
_trashesMutex.unlock(); _trashesMutex.unlock();
_dbSafeAccessMutex.lock(); _dbSafeAccessMutex.lock();
this->loadNodeDataQuery(signatures, images, scan, userData, occupancyGrid); this->loadNodeDataQuery(signatures, images, scan, userData, occupancyGrid, features);
_dbSafeAccessMutex.unlock(); _dbSafeAccessMutex.unlock();
} }
void DBDriver::getNodeData( void DBDriver::getNodeData(
int signatureId, int signatureId,
SensorData & data, SensorData & data,
bool images, bool scan, bool userData, bool occupancyGrid) const bool images, bool scan, bool userData, bool occupancyGrid, bool features) const
{ {
bool found = false; bool found = false;
// look in the trash // look in the trash
@@ -703,11 +704,12 @@ void DBDriver::getNodeData(
if(uContains(_trashSignatures, signatureId)) if(uContains(_trashSignatures, signatureId))
{ {
const Signature * s = _trashSignatures.at(signatureId); const Signature * s = _trashSignatures.at(signatureId);
if((!s->isSaved() || if(!s->isSaved() ||
((!images || !s->sensorData().imageCompressed().empty()) && ((!images || !s->sensorData().imageCompressed().empty()) &&
(!scan || !s->sensorData().laserScanCompressed().isEmpty()) && (!scan || !s->sensorData().laserScanCompressed().isEmpty()) &&
(!userData || !s->sensorData().userDataCompressed().empty()) && (!userData || !s->sensorData().userDataCompressed().empty()) &&
(!occupancyGrid || s->sensorData().gridCellSize() != 0.0f)))) (!occupancyGrid || s->sensorData().gridCellSize() != 0.0f) &&
(!features || !s->sensorData().keypoints().empty())))
{ {
data = (SensorData)s->sensorData(); data = (SensorData)s->sensorData();
if(!images) if(!images)
@@ -726,6 +728,10 @@ void DBDriver::getNodeData(
{ {
data.setOccupancyGrid(cv::Mat(), cv::Mat(), cv::Mat(), 0, cv::Point3f()); data.setOccupancyGrid(cv::Mat(), cv::Mat(), cv::Mat(), 0, cv::Point3f());
} }
if(!features)
{
data.setFeatures(std::vector<cv::KeyPoint>(), std::vector<cv::Point3f>(), cv::Mat());
}
found = true; found = true;
} }
} }
@@ -737,7 +743,7 @@ void DBDriver::getNodeData(
std::list<Signature *> signatures; std::list<Signature *> signatures;
Signature tmp(signatureId); Signature tmp(signatureId);
signatures.push_back(&tmp); signatures.push_back(&tmp);
loadNodeDataQuery(signatures, images, scan, userData, occupancyGrid); loadNodeDataQuery(signatures, images, scan, userData, occupancyGrid, features);
data = signatures.front()->sensorData(); data = signatures.front()->sensorData();
_dbSafeAccessMutex.unlock(); _dbSafeAccessMutex.unlock();
} }
@@ -1517,15 +1523,15 @@ void DBDriver::generateGraph(
std::vector<unsigned char> DBDriver::serializeFeatures( std::vector<unsigned char> DBDriver::serializeFeatures(
const std::vector<cv::KeyPoint> & keypoints, const std::vector<cv::KeyPoint> & keypoints,
const std::vector<cv::Point3f> & points3D, const std::vector<cv::Point3f> & points3D,
const cv::Mat & descriptors) const cv::Mat & descriptors) const
{ {
const int headerSize = 13; const int headerSize = 13;
int header[headerSize] = { int header[headerSize] = {
RTABMAP_VERSION_MAJOR, RTABMAP_VERSION_MINOR, RTABMAP_VERSION_PATCH, // 0,1,2 RTABMAP_VERSION_MAJOR, RTABMAP_VERSION_MINOR, RTABMAP_VERSION_PATCH, // 0,1,2
CV_MAJOR_VERSION, CV_MINOR_VERSION, CV_SUBMINOR_VERSION, // 3,4,5 (In case the format/order/size of KeyPoint and/or Point3f changes in the future) CV_MAJOR_VERSION, CV_MINOR_VERSION, CV_SUBMINOR_VERSION, // 3,4,5 (In case the format/order/size of KeyPoint and/or Point3f changes in the future)
sizeof(cv::KeyPoint), keypoints.size(), // 6,7 sizeof(cv::KeyPoint), (int)keypoints.size(), // 6,7
sizeof(cv::Point3f), points3D.size(), // 8,9 sizeof(cv::Point3f), (int)points3D.size(), // 8,9
descriptors.type(), descriptors.cols, descriptors.rows} // 10,11,12 descriptors.type(), descriptors.cols, descriptors.rows}; // 10,11,12
UDEBUG("Header: %d %d %d %d %d %d %d %d %d %d %d %d %d", UDEBUG("Header: %d %d %d %d %d %d %d %d %d %d %d %d %d",
header[0],header[1],header[2],header[3],header[4],header[5],header[6],header[7],header[8],header[9],header[10],header[11],header[12]); header[0],header[1],header[2],header[3],header[4],header[5],header[6],header[7],header[8],header[9],header[10],header[11],header[12]);
std::vector<unsigned char> data( std::vector<unsigned char> data(
@@ -1558,7 +1564,7 @@ bool DBDriver::deserializeFeatures(
unsigned int compressedDataSize, unsigned int compressedDataSize,
std::vector<cv::KeyPoint> & keypoints, std::vector<cv::KeyPoint> & keypoints,
std::vector<cv::Point3f> & points3D, std::vector<cv::Point3f> & points3D,
cv::Mat & descriptors) cv::Mat & descriptors) const
{ {
cv::Mat serializedData = uncompressData(compressedData, compressedDataSize); cv::Mat serializedData = uncompressData(compressedData, compressedDataSize);
if(serializedData.empty()) if(serializedData.empty())
@@ -1569,7 +1575,7 @@ bool DBDriver::deserializeFeatures(
int headerSize = 13; int headerSize = 13;
if(serializedData.total() >= sizeof(int)*headerSize) if(serializedData.total() >= sizeof(int)*headerSize)
{ {
const int * header = (const int *)serializedData.data(); const int * header = (const int *)serializedData.data;
UASSERT(header[6] == sizeof(cv::KeyPoint)); UASSERT(header[6] == sizeof(cv::KeyPoint));
int n_kpts = header[7]; int n_kpts = header[7];
UASSERT(header[8] == sizeof(cv::Point3f)); UASSERT(header[8] == sizeof(cv::Point3f));
@@ -1610,7 +1616,7 @@ bool DBDriver::deserializeFeatures(
cv::Mat(d_rows, d_cols, d_type, (void*)(serializedData.data+index)).copyTo(descriptors); cv::Mat(d_rows, d_cols, d_type, (void*)(serializedData.data+index)).copyTo(descriptors);
index+=descriptors.elemSize()*(descriptors.total()); index+=descriptors.elemSize()*(descriptors.total());
} }
UASSERT(index == serializedData.size()); UASSERT(index == serializedData.total());
return true; return true;
} }
UERROR("Wrong serialized features format detected (size in bytes=%ld)! Cannot deserialize the data.", serializedData.size()); UERROR("Wrong serialized features format detected (size in bytes=%ld)! Cannot deserialize the data.", serializedData.size());
+7 -2
View File
@@ -1301,7 +1301,7 @@ void DBDriverSqlite3::loadNodeDataQuery(std::list<Signature *> & signatures, boo
//UDEBUG("load data for %d signatures images=%d scan=%d userData=%d, grid=%d", //UDEBUG("load data for %d signatures images=%d scan=%d userData=%d, grid=%d",
// (int)signatures.size(), images?1:0, scan?1:0, userData?1:0, occupancyGrid?1:0); // (int)signatures.size(), images?1:0, scan?1:0, userData?1:0, occupancyGrid?1:0);
if(!images && !scan && !userData && !occupancyGrid && (uStrNumCmp(_version, "0.24.0") < 0 || !features)) if(!images && !scan && !userData && !occupancyGrid && !features)
{ {
UWARN("All requested data fields are false! Nothing loaded..."); UWARN("All requested data fields are false! Nothing loaded...");
return; return;
@@ -1854,7 +1854,7 @@ void DBDriverSqlite3::loadNodeDataQuery(std::list<Signature *> & signatures, boo
dataSize = sqlite3_column_bytes(ppStmt, index++); dataSize = sqlite3_column_bytes(ppStmt, index++);
if(dataSize > 0 && data) if(dataSize > 0 && data)
{ {
if(!deserializeFeatures(data, dataSize, keypoints, points3D, descriptors)) if(!deserializeFeatures((const unsigned char *)data, dataSize, keypoints, points3D, descriptors))
{ {
UERROR("Failed desrializing features for node %d!", (*iter)->id()); UERROR("Failed desrializing features for node %d!", (*iter)->id());
} }
@@ -1914,6 +1914,11 @@ void DBDriverSqlite3::loadNodeDataQuery(std::list<Signature *> & signatures, boo
UASSERT_MSG(rc == SQLITE_OK, uFormat("DB error (%s): %s", _version.c_str(), sqlite3_errmsg(_ppDb)).c_str()); UASSERT_MSG(rc == SQLITE_OK, uFormat("DB error (%s): %s", _version.c_str(), sqlite3_errmsg(_ppDb)).c_str());
//ULOGGER_DEBUG("Time=%fs", timer.ticks()); //ULOGGER_DEBUG("Time=%fs", timer.ticks());
} }
if(features && uStrNumCmp(_version, "0.24.0") < 0)
{
loadWordsQuery(signatures);
}
} }
bool DBDriverSqlite3::getCalibrationQuery( bool DBDriverSqlite3::getCalibrationQuery(