Skip to content

Commit

Permalink
Improved image view scene rect size when no images are there. Added w…
Browse files Browse the repository at this point in the history
…arning when transform cannot be computed because some data are missing.
  • Loading branch information
matlabbe committed Sep 16, 2024
1 parent 69ac21f commit 0e85bd8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
9 changes: 9 additions & 0 deletions corelib/src/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3186,6 +3186,15 @@ Transform Memory::computeTransform(
transform = transform.inverse();
}
}
else
{
std::string msg = uFormat("Missing visual features or missing raw data to compute them. Transform cannot be estimated.");
if(info)
{
info->rejectedMsg = msg;
}
UWARN(msg.c_str());
}
return transform;
}

Expand Down
19 changes: 19 additions & 0 deletions guilib/src/DatabaseViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4762,6 +4762,25 @@ void DatabaseViewer::update(int value,
{
ULOGGER_DEBUG("Image depth is empty");
}
if(!rect.isValid())
{
if(data.cameraModels().size())
{
for(unsigned int i=0; i<data.cameraModels().size(); ++i)
{
rect.setWidth(rect.width()+data.cameraModels()[i].imageWidth());
rect.setHeight(std::max((int)rect.height(), data.cameraModels()[i].imageHeight()));
}
}
else if(data.stereoCameraModels().size())
{
for(unsigned int i=0; i<data.cameraModels().size(); ++i)
{
rect.setWidth(rect.width()+data.stereoCameraModels()[i].left().imageWidth());
rect.setHeight(std::max((int)rect.height(), data.stereoCameraModels()[i].left().imageHeight()));
}
}
}
if(rect.isValid())
{
view->setSceneRect(rect);
Expand Down
4 changes: 2 additions & 2 deletions guilib/src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2328,15 +2328,15 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
for(unsigned int i=0; i<signature.sensorData().cameraModels().size(); ++i)
{
sceneRect.setWidth(sceneRect.width()+signature.sensorData().cameraModels()[i].imageWidth());
sceneRect.setHeight(sceneRect.height()+signature.sensorData().cameraModels()[i].imageHeight());
sceneRect.setHeight(std::max((int)sceneRect.height(), signature.sensorData().cameraModels()[i].imageHeight()));
}
}
else if(signature.sensorData().stereoCameraModels().size())
{
for(unsigned int i=0; i<signature.sensorData().cameraModels().size(); ++i)
{
sceneRect.setWidth(sceneRect.width()+signature.sensorData().stereoCameraModels()[i].left().imageWidth());
sceneRect.setHeight(sceneRect.height()+signature.sensorData().stereoCameraModels()[i].left().imageHeight());
sceneRect.setHeight(std::max((int)sceneRect.height(), signature.sensorData().stereoCameraModels()[i].left().imageHeight()));
}
}
if(sceneRect.isValid())
Expand Down

0 comments on commit 0e85bd8

Please sign in to comment.