From 485bf806bd011120ee5f71268c40af5d6ea18026 Mon Sep 17 00:00:00 2001 From: matlabbe Date: Mon, 5 Jul 2021 10:04:51 -0400 Subject: [PATCH] export tool: use pcl's PLY writer instead of pdal if camera ids are not exported (ply compatibility issue when reading back using pcl) --- tools/Export/main.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/tools/Export/main.cpp b/tools/Export/main.cpp index 96de28be..341a9f47 100644 --- a/tools/Export/main.cpp +++ b/tools/Export/main.cpp @@ -1091,21 +1091,26 @@ int main(int argc, char * argv[]) std::string outputPath=outputDirectory+"/"+baseName+"_cloud."+ext; printf("Saving %s... (%d points)\n", outputPath.c_str(), !cloudToExport->empty()?(int)cloudToExport->size():(int)cloudIToExport->size()); #ifdef RTABMAP_PDAL - if(!cloudToExport->empty()) - savePDALFile(outputPath, *cloudToExport, pointToCamId, binary); - else if(!cloudIToExport->empty()) - savePDALFile(outputPath, *cloudIToExport, pointToCamId, binary); -#else - if(!pointToCamId.empty()) + if(las || !pointToCamId.empty()) { - printf("Option --cam_projection is enabled but rtabmap is not built " - "with PDAL support, so camera IDs won't be exported in the output cloud.\n"); + if(!cloudToExport->empty()) + savePDALFile(outputPath, *cloudToExport, pointToCamId, binary); + else if(!cloudIToExport->empty()) + savePDALFile(outputPath, *cloudIToExport, pointToCamId, binary); } - if(!cloudToExport->empty()) - pcl::io::savePLYFile(outputPath, *cloudToExport, binary); - else if(!cloudIToExport->empty()) - pcl::io::savePLYFile(outputPath, *cloudIToExport, binary); + else #endif + { + if(!pointToCamId.empty()) + { + printf("Option --cam_projection is enabled but rtabmap is not built " + "with PDAL support, so camera IDs won't be exported in the output cloud.\n"); + } + if(!cloudToExport->empty()) + pcl::io::savePLYFile(outputPath, *cloudToExport, binary); + else if(!cloudIToExport->empty()) + pcl::io::savePLYFile(outputPath, *cloudIToExport, binary); + } printf("Saving %s... done!\n", outputPath.c_str()); } }