With Mem/RotateImagesUpsideUp=true, do not clear features if none of the cameras are rotated. DBViewer: show local transform of all cameras in tooltip

This commit is contained in:
matlabbe
2024-08-12 14:27:08 -07:00
parent cc5da376ec
commit 4911dbe9bb
4 changed files with 11 additions and 5 deletions

View File

@@ -180,8 +180,9 @@ std::vector<int> RTABMAP_CORE_EXPORT SSC(
* @param model a valid camera model
* @param rgb a rgb/grayscale image (set cv::Mat() if not used)
* @param depth a depth image (set cv::Mat() if not used)
* @return true if the model/images have been rotated, false otherwise
*/
void RTABMAP_CORE_EXPORT rotateImagesUpsideUpIfNecessary(
bool RTABMAP_CORE_EXPORT rotateImagesUpsideUpIfNecessary(
CameraModel & model,
cv::Mat & rgb,
cv::Mat & depth);

View File

@@ -4717,13 +4717,14 @@ Signature * Memory::createSignature(const SensorData & inputData, const Transfor
cv::Mat rotatedDepthImages;
std::vector<CameraModel> rotatedCameraModels;
bool allOutputSizesAreOkay = true;
bool atLeastOneCameraRotated = false;
for(size_t i=0; i<data.cameraModels().size(); ++i)
{
UDEBUG("Rotating camera %ld", i);
cv::Mat rgb = cv::Mat(data.imageRaw(), cv::Rect(subInputImageWidth*i, 0, subInputImageWidth, data.imageRaw().rows));
cv::Mat depth = !data.depthRaw().empty()?cv::Mat(data.depthRaw(), cv::Rect(subInputDepthWidth*i, 0, subInputDepthWidth, data.depthRaw().rows)):cv::Mat();
CameraModel model = data.cameraModels()[i];
util2d::rotateImagesUpsideUpIfNecessary(model, rgb, depth);
atLeastOneCameraRotated |= util2d::rotateImagesUpsideUpIfNecessary(model, rgb, depth);
if(rotatedColorImages.empty())
{
rotatedColorImages = cv::Mat(cv::Size(rgb.cols * data.cameraModels().size(), rgb.rows), rgb.type());
@@ -4757,7 +4758,7 @@ Signature * Memory::createSignature(const SensorData & inputData, const Transfor
}
rotatedCameraModels.push_back(model);
}
if(allOutputSizesAreOkay)
if(allOutputSizesAreOkay && atLeastOneCameraRotated)
{
data.setRGBDImage(rotatedColorImages, rotatedDepthImages, rotatedCameraModels);

View File

@@ -2279,7 +2279,7 @@ std::vector<int> SSC(
return ResultVec;
}
void rotateImagesUpsideUpIfNecessary(
bool rotateImagesUpsideUpIfNecessary(
CameraModel & model,
cv::Mat & rgb,
cv::Mat & depth)
@@ -2293,7 +2293,7 @@ void rotateImagesUpsideUpIfNecessary(
{
// Return original because of ambiguity for what would be considered up...
UDEBUG("Ignoring image rotation as pitch(%f)>Pi/4", pitch);
return;
return false;
}
if(roll<0)
{
@@ -2368,7 +2368,9 @@ void rotateImagesUpsideUpIfNecessary(
else
{
UDEBUG("ROTATION_0 (roll=%f)", roll);
return false;
}
return true;
}
}