Fixed backward compatibility for exporting texture mesh with old databases

This commit is contained in:
matlabbe
2017-03-03 00:19:46 -05:00
parent 300e37124c
commit 1ce4db5604
2 changed files with 33 additions and 10 deletions

View File

@@ -1259,7 +1259,7 @@ pcl::TextureMapping<PointInT>::textureMeshwithMultipleCameras2 (
if((idx_face+1)%10000 == 0) if((idx_face+1)%10000 == 0)
{ {
UDEBUG("face %d/%d", idx_face+1, (int)faces.size()); UDEBUG("face %d/%d", idx_face+1, (int)faces.size());
if(state && !state->callback("")) if(state && !state->callback(uFormat("Textured %d/%d polygons", (int)idx_face+1, (int)faces.size())))
{ {
//cancelled! //cancelled!
UWARN("Texturing cancelled!"); UWARN("Texturing cancelled!");

View File

@@ -740,10 +740,10 @@ void ExportCloudsDialog::viewClouds(
if (globalTexture.empty()) if (globalTexture.empty())
{ {
UASSERT(mesh->tex_materials.size()==1 && if(mesh->tex_materials.size()==1 &&
!mesh->tex_materials[0].tex_file.empty() && !mesh->tex_materials[0].tex_file.empty() &&
uIsInteger(mesh->tex_materials[0].tex_file, false)); uIsInteger(mesh->tex_materials[0].tex_file, false))
{
int textureId = uStr2Int(mesh->tex_materials[0].tex_file); int textureId = uStr2Int(mesh->tex_materials[0].tex_file);
UASSERT(cachedSignatures.contains(textureId) && !cachedSignatures.value(textureId).sensorData().imageCompressed().empty()); UASSERT(cachedSignatures.contains(textureId) && !cachedSignatures.value(textureId).sensorData().imageCompressed().empty());
cachedSignatures.value(textureId).sensorData().uncompressDataConst(&globalTexture, 0); cachedSignatures.value(textureId).sensorData().uncompressDataConst(&globalTexture, 0);
@@ -753,6 +753,12 @@ void ExportCloudsDialog::viewClouds(
_compensator->apply(textureId, globalTexture); _compensator->apply(textureId, globalTexture);
} }
} }
else
{
_progressDialog->appendText(tr("No textures added to mesh %1!?").arg(iter->first), Qt::darkRed);
_progressDialog->setAutoClose(false);
}
}
viewer->addCloudTextureMesh(uFormat("mesh%d",iter->first), mesh, globalTexture, iter->first>0?poses.at(iter->first):Transform::getIdentity()); viewer->addCloudTextureMesh(uFormat("mesh%d",iter->first), mesh, globalTexture, iter->first>0?poses.at(iter->first):Transform::getIdentity());
_progressDialog->appendText(tr("Viewing the mesh %1 (%2 polygons)... done.").arg(iter->first).arg(mesh->tex_polygons.size()?mesh->tex_polygons[0].size():0)); _progressDialog->appendText(tr("Viewing the mesh %1 (%2 polygons)... done.").arg(iter->first).arg(mesh->tex_polygons.size()?mesh->tex_polygons[0].size():0));
@@ -1771,6 +1777,15 @@ bool ExportCloudsDialog::getExportedClouds(
} }
if(!jter->second.isNull() && model.isValidForProjection() && !s.sensorData().imageCompressed().empty()) if(!jter->second.isNull() && model.isValidForProjection() && !s.sensorData().imageCompressed().empty())
{ {
if(model.imageWidth() == 0 || model.imageHeight() == 0)
{
// we are using an old database format (image size not saved in calibrations), we should
// uncompress images to get their size
cv::Mat img;
s.sensorData().uncompressDataConst(&img, 0);
model.setImageSize(img.size());
}
cameraPoses.insert(std::make_pair(jter->first, jter->second)); cameraPoses.insert(std::make_pair(jter->first, jter->second));
cameraModels.insert(std::make_pair(jter->first, model)); cameraModels.insert(std::make_pair(jter->first, model));
} }
@@ -2015,10 +2030,14 @@ bool ExportCloudsDialog::getExportedClouds(
} }
else if(cameraPoses.size() == 0) else if(cameraPoses.size() == 0)
{ {
_progressDialog->appendText(tr("No cameras from %1 poses with valid calibration found!").arg(poses.size()), Qt::darkYellow);
_progressDialog->setAutoClose(false);
UWARN("No camera poses!?"); UWARN("No camera poses!?");
} }
else else
{ {
_progressDialog->appendText(tr("No polygons!?"), Qt::darkYellow);
_progressDialog->setAutoClose(false);
UWARN("No polygons!"); UWARN("No polygons!");
} }
@@ -2617,6 +2636,10 @@ cv::Mat ExportCloudsDialog::mergeTextures(pcl::TextureMesh & mesh, const QMap<in
iter->sensorData().uncompressDataConst(&image, 0); iter->sensorData().uncompressDataConst(&image, 0);
UASSERT(!image.empty()); UASSERT(!image.empty());
tmpImageSize = image.size(); tmpImageSize = image.size();
if(imageSize.height == 0 && imageSize.width == 0)
{
imageType = image.type();
}
} }
if(imageSize.width>0 && imageSize.height>0 && imageSize.width != tmpImageSize.width) if(imageSize.width>0 && imageSize.height>0 && imageSize.width != tmpImageSize.width)
{ {