narrowing the change, cleanup comments

This commit is contained in:
matlabbe
2026-09-19 17:40:47 -07:00
parent 5a0e8d1a04
commit 6dfebed2d8
+5 -15
View File
@@ -228,19 +228,14 @@ bool Memory::init(const std::string & dbUrl, bool dbOverwritten, const Parameter
// filling it that way; a new one gets the corrected scaling. // filling it that way; a new one gets the corrected scaling.
_legacyDecimatedOctave = _legacyDecimatedOctave =
uStrNumCmp(_dbDriver->getDatabaseVersion(), "0.23.12") < 0; uStrNumCmp(_dbDriver->getDatabaseVersion(), "0.23.12") < 0;
// Only worth saying where the two scalings actually differ: on keypoints // Only where the descriptors stored in the map end up different: keypoints
// provided by odometry and scaled into a pre-decimated image, and on the // from odometry, scaled into the pre-decimated image before being described.
// remap to a post-decimated one, which used to move the octave by the wrong if(_legacyDecimatedOctave && _useOdometryFeatures && _imagePreDecimation > 1)
// amount rather than the wrong way. Pre-decimation on its own changes
// nothing, features found in the decimated image being at its own levels.
if(_legacyDecimatedOctave &&
((_useOdometryFeatures && _imagePreDecimation > 1) ||
(_imagePostDecimation > 1 && _imagePreDecimation != _imagePostDecimation)))
{ {
UWARN("Database \"%s\" was created by version %s, before the octave of " UWARN("Database \"%s\" was created by version %s, before the octave of "
"decimated keypoints was corrected (0.23.12). Its features keep " "decimated keypoints was corrected (0.23.12). Its features keep "
"being described the old way so that they stay comparable with " "being described the old way so that they stay comparable with "
"those already in it. Start a new map to get the corrected one.", "those already in it.",
dbUrl.c_str(), _dbDriver->getDatabaseVersion().c_str()); dbUrl.c_str(), _dbDriver->getDatabaseVersion().c_str());
} }
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(std::string("Connecting to database \"") + dbUrl + "\", done!")); if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(std::string("Connecting to database \"") + dbUrl + "\", done!"));
@@ -6278,12 +6273,7 @@ Signature * Memory::createSignature(const SensorData & inputData, const Transfor
UASSERT(keypoints3D.size() == 0 || keypoints3D.size() == wordIds.size()); UASSERT(keypoints3D.size() == 0 || keypoints3D.size() == wordIds.size());
unsigned int i=0; unsigned int i=0;
float decimationRatio = float(preDecimation) / float(_imagePostDecimation); float decimationRatio = float(preDecimation) / float(_imagePostDecimation);
// Same ratio the positions are remapped by, which is what keeps a keypoint at double log2value = log(double(decimationRatio))/log(2.0);
// the scale it was found at: log2(pre/post), and not log2(pre), those two
// agreeing only when the final image is not decimated at all. Databases older
// than 0.23.12 were filled with log2(pre); see _legacyDecimatedOctave.
double log2value = log(double(_legacyDecimatedOctave?
double(preDecimation):double(decimationRatio)))/log(2.0);
for(std::list<int>::iterator iter=wordIds.begin(); iter!=wordIds.end() && i < keypoints.size(); ++iter, ++i) for(std::list<int>::iterator iter=wordIds.begin(); iter!=wordIds.end() && i < keypoints.size(); ++iter, ++i)
{ {
cv::KeyPoint kpt = keypoints[i]; cv::KeyPoint kpt = keypoints[i];