Rtabmap::getSignatureCopy() added withWords and withGlobalDescriptors options

This commit is contained in:
matlabbe
2020-06-22 22:56:25 -04:00
parent c19f81ac12
commit 274903dd63
4 changed files with 39 additions and 24 deletions

View File

@@ -21,7 +21,7 @@ SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake_modules")
####################### #######################
SET(RTABMAP_MAJOR_VERSION 0) SET(RTABMAP_MAJOR_VERSION 0)
SET(RTABMAP_MINOR_VERSION 20) SET(RTABMAP_MINOR_VERSION 20)
SET(RTABMAP_PATCH_VERSION 1) SET(RTABMAP_PATCH_VERSION 2)
SET(RTABMAP_VERSION SET(RTABMAP_VERSION
${RTABMAP_MAJOR_VERSION}.${RTABMAP_MINOR_VERSION}.${RTABMAP_PATCH_VERSION}) ${RTABMAP_MAJOR_VERSION}.${RTABMAP_MINOR_VERSION}.${RTABMAP_PATCH_VERSION})

View File

@@ -180,7 +180,7 @@ public:
void rejectLastLoopClosure(); void rejectLastLoopClosure();
void deleteLastLocation(); void deleteLastLocation();
void setOptimizedPoses(const std::map<int, Transform> & poses); void setOptimizedPoses(const std::map<int, Transform> & poses);
Signature getSignatureCopy(int id, bool images, bool scan, bool userData, bool occupancyGrid) const; Signature getSignatureCopy(int id, bool images, bool scan, bool userData, bool occupancyGrid, bool withWords, bool withGlobalDescriptors) const;
RTABMAP_DEPRECATED( RTABMAP_DEPRECATED(
void get3DMap(std::map<int, Signature> & signatures, void get3DMap(std::map<int, Signature> & signatures,
std::map<int, Transform> & poses, std::map<int, Transform> & poses,
@@ -195,7 +195,9 @@ public:
bool withImages = false, bool withImages = false,
bool withScan = false, bool withScan = false,
bool withUserData = false, bool withUserData = false,
bool withGrid = false) const; bool withGrid = false,
bool withWords = true,
bool withGlobalDescriptors = true) const;
int detectMoreLoopClosures( int detectMoreLoopClosures(
float clusterRadius = 0.5f, float clusterRadius = 0.5f,
float clusterAngle = M_PI/6.0f, float clusterAngle = M_PI/6.0f,

View File

@@ -4389,7 +4389,7 @@ void Rtabmap::dumpPrediction() const
} }
} }
Signature Rtabmap::getSignatureCopy(int id, bool images, bool scan, bool userData, bool occupancyGrid) const Signature Rtabmap::getSignatureCopy(int id, bool images, bool scan, bool userData, bool occupancyGrid, bool withWords, bool withGlobalDescriptors) const
{ {
Signature s; Signature s;
if(_memory) if(_memory)
@@ -4410,7 +4410,7 @@ Signature Rtabmap::getSignatureCopy(int id, bool images, bool scan, bool userDat
{ {
data = _memory->getNodeData(id, images, scan, userData, occupancyGrid); data = _memory->getNodeData(id, images, scan, userData, occupancyGrid);
} }
if(!images) if(!images && withWords)
{ {
std::vector<CameraModel> models; std::vector<CameraModel> models;
StereoCameraModel stereoModel; StereoCameraModel stereoModel;
@@ -4418,23 +4418,34 @@ Signature Rtabmap::getSignatureCopy(int id, bool images, bool scan, bool userDat
data.setCameraModels(models); data.setCameraModels(models);
data.setStereoCameraModel(stereoModel); data.setStereoCameraModel(stereoModel);
} }
std::multimap<int, cv::KeyPoint> words;
std::multimap<int, cv::Point3f> words3;
std::multimap<int, cv::Mat> wordsDescriptors;
std::vector<rtabmap::GlobalDescriptor> globalDescriptors;
_memory->getNodeWordsAndGlobalDescriptors(id, words, words3, wordsDescriptors, globalDescriptors);
s=Signature(id, s=Signature(id,
mapId, mapId,
weight, weight,
stamp, stamp,
label, label,
odomPoseLocal, odomPoseLocal,
groundTruth, groundTruth,
data); data);
s.setWords(words);
s.setWords3(words3); if(withWords || withGlobalDescriptors)
s.setWordsDescriptors(wordsDescriptors); {
s.sensorData().setGlobalDescriptors(globalDescriptors); std::multimap<int, cv::KeyPoint> words;
std::multimap<int, cv::Point3f> words3;
std::multimap<int, cv::Mat> wordsDescriptors;
std::vector<rtabmap::GlobalDescriptor> globalDescriptors;
_memory->getNodeWordsAndGlobalDescriptors(id, words, words3, wordsDescriptors, globalDescriptors);
if(withWords)
{
s.setWords(words);
s.setWords3(words3);
s.setWordsDescriptors(wordsDescriptors);
}
if(withGlobalDescriptors)
{
s.sensorData().setGlobalDescriptors(globalDescriptors);
}
}
if(velocity.size()==6) if(velocity.size()==6)
{ {
s.setVelocity(velocity[0], velocity[1], velocity[2], velocity[3], velocity[4], velocity[5]); s.setVelocity(velocity[0], velocity[1], velocity[2], velocity[3], velocity[4], velocity[5]);
@@ -4465,7 +4476,9 @@ void Rtabmap::getGraph(
bool withImages, bool withImages,
bool withScan, bool withScan,
bool withUserData, bool withUserData,
bool withGrid) const bool withGrid,
bool withWords,
bool withGlobalDescriptors) const
{ {
if(_memory && _memory->getLastWorkingSignature()) if(_memory && _memory->getLastWorkingSignature())
{ {
@@ -4506,7 +4519,7 @@ void Rtabmap::getGraph(
for(std::set<int>::iterator iter = ids.begin(); iter!=ids.end(); ++iter) for(std::set<int>::iterator iter = ids.begin(); iter!=ids.end(); ++iter)
{ {
signatures->insert(std::make_pair(*iter, getSignatureCopy(*iter, withImages, withScan, withUserData, withGrid))); signatures->insert(std::make_pair(*iter, getSignatureCopy(*iter, withImages, withScan, withUserData, withGrid, withWords, withGlobalDescriptors)));
} }
} }
} }

View File

@@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<package> <package>
<name>rtabmap</name> <name>rtabmap</name>
<version>0.20.1</version> <version>0.20.2</version>
<description>RTAB-Map's standalone library. RTAB-Map is a RGB-D SLAM approach with real-time constraints.</description> <description>RTAB-Map's standalone library. RTAB-Map is a RGB-D SLAM approach with real-time constraints.</description>
<maintainer email="matlabbe@gmail.com">Mathieu Labbe</maintainer> <maintainer email="matlabbe@gmail.com">Mathieu Labbe</maintainer>
<author>Mathieu Labbe</author> <author>Mathieu Labbe</author>