Added pdal optional dependency (export to LAS, E57, ...)

This commit is contained in:
matlabbe
2021-01-14 15:49:18 -05:00
parent eae5f2b428
commit 0bc483b6d3
6 changed files with 497 additions and 13 deletions
+19
View File
@@ -165,6 +165,7 @@ ENDIF()
option(WITH_ORB_OCTREE "Include ORB Octree feature support" ON) option(WITH_ORB_OCTREE "Include ORB Octree feature support" ON)
option(WITH_SUPERPOINT_TORCH "Include SuperPoint Torch feature support" ON) option(WITH_SUPERPOINT_TORCH "Include SuperPoint Torch feature support" ON)
option(WITH_PYMATCHER "Include Python3 matchers support" OFF) option(WITH_PYMATCHER "Include Python3 matchers support" OFF)
option(WITH_PDAL "Include PDAL support" ON)
option(WITH_FREENECT "Include Freenect support" ON) option(WITH_FREENECT "Include Freenect support" ON)
option(WITH_FREENECT2 "Include Freenect2 support" ON) option(WITH_FREENECT2 "Include Freenect2 support" ON)
option(WITH_K4W2 "Include Kinect for Windows v2 support" ON) option(WITH_K4W2 "Include Kinect for Windows v2 support" ON)
@@ -336,6 +337,13 @@ IF(WITH_PYMATCHER)
ENDIF(Python3_FOUND) ENDIF(Python3_FOUND)
ENDIF(WITH_PYMATCHER) ENDIF(WITH_PYMATCHER)
IF(WITH_PDAL)
FIND_PACKAGE(PDAL QUIET)
IF(PDAL_FOUND)
MESSAGE(STATUS "Found PDAL ${PDAL_VERSION}: ${PDAL_INCLUDE_DIRS}")
ENDIF(PDAL_FOUND)
ENDIF(WITH_PDAL)
IF(WITH_FREENECT) IF(WITH_FREENECT)
FIND_PACKAGE(Freenect QUIET) FIND_PACKAGE(Freenect QUIET)
IF(Freenect_FOUND) IF(Freenect_FOUND)
@@ -730,6 +738,9 @@ ENDIF(NOT libpointmatcher_FOUND)
IF(NOT FastCV_FOUND) IF(NOT FastCV_FOUND)
SET(FASTCV "//") SET(FASTCV "//")
ENDIF(NOT FastCV_FOUND) ENDIF(NOT FastCV_FOUND)
IF(NOT PDAL_FOUND)
SET(PDAL "//")
ENDIF(NOT PDAL_FOUND)
IF(NOT loam_velodyne_FOUND) IF(NOT loam_velodyne_FOUND)
SET(LOAM "//") SET(LOAM "//")
ENDIF(NOT loam_velodyne_FOUND) ENDIF(NOT loam_velodyne_FOUND)
@@ -1132,6 +1143,14 @@ ELSE()
MESSAGE(STATUS " With FastCV = NO (FastCV not found)") MESSAGE(STATUS " With FastCV = NO (FastCV not found)")
ENDIF() ENDIF()
IF(PDAL_FOUND)
MESSAGE(STATUS " With PDAL = YES (License: BSD)")
ELSEIF(NOT WITH_PDAL)
MESSAGE(STATUS " With PDAL = NO (WITH_PDAL=OFF)")
ELSE()
MESSAGE(STATUS " With PDAL = NO (PDAL not found)")
ENDIF()
MESSAGE(STATUS "") MESSAGE(STATUS "")
MESSAGE(STATUS " Solvers:") MESSAGE(STATUS " Solvers:")
IF(WITH_TORO) IF(WITH_TORO)
+1
View File
@@ -52,6 +52,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@CVSBA@#define RTABMAP_CVSBA @CVSBA@#define RTABMAP_CVSBA
@POINTMATCHER@#define RTABMAP_POINTMATCHER @POINTMATCHER@#define RTABMAP_POINTMATCHER
@FASTCV@#define RTABMAP_FASTCV @FASTCV@#define RTABMAP_FASTCV
@PDAL@#define RTABMAP_PDAL
@LOAM@#define RTABMAP_LOAM @LOAM@#define RTABMAP_LOAM
@DC1394@#define RTABMAP_DC1394 @DC1394@#define RTABMAP_DC1394
@FLYCAPTURE2@#define RTABMAP_FLYCAPTURE2 @FLYCAPTURE2@#define RTABMAP_FLYCAPTURE2
+47
View File
@@ -0,0 +1,47 @@
/*
Copyright (c) 2010-2021, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Universite de Sherbrooke nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CORELIB_INCLUDE_RTABMAP_CORE_PDALWRITER_H_
#define CORELIB_INCLUDE_RTABMAP_CORE_PDALWRITER_H_
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
namespace rtabmap {
std::string getPDALSupportedWriters();
int savePDALFile(const std::string & filePath, const pcl::PointCloud<pcl::PointXYZ> & cloud);
int savePDALFile(const std::string & filePath, const pcl::PointCloud<pcl::PointXYZRGB> & cloud);
int savePDALFile(const std::string & filePath, const pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud);
int savePDALFile(const std::string & filePath, const pcl::PointCloud<pcl::PointXYZI> & cloud);
int savePDALFile(const std::string & filePath, const pcl::PointCloud<pcl::PointXYZINormal> & cloud);
}
#endif /* CORELIB_INCLUDE_RTABMAP_CORE_PDALWRITER_H_ */
+19
View File
@@ -416,6 +416,25 @@ IF(FastCV_FOUND)
) )
ENDIF(FastCV_FOUND) ENDIF(FastCV_FOUND)
IF(PDAL_FOUND)
SET(INCLUDE_DIRS
${INCLUDE_DIRS}
${PDAL_INCLUDE_DIRS}
)
SET(LIBRARIES
${LIBRARIES}
${PDAL_LIBRARIES}
)
SET(SRC_FILES
${SRC_FILES}
PDALWriter.cpp
)
IF(PDAL_VERSION VERSION_LESS "1.7")
add_definitions("-DRTABMAP_PDAL_16")
ENDIF(PDAL_VERSION VERSION_LESS "1.7")
ENDIF(PDAL_FOUND)
IF(loam_velodyne_FOUND) IF(loam_velodyne_FOUND)
SET(INCLUDE_DIRS SET(INCLUDE_DIRS
${INCLUDE_DIRS} ${INCLUDE_DIRS}
+319
View File
@@ -0,0 +1,319 @@
/*
Copyright (c) 2010-2021, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Universite de Sherbrooke nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <rtabmap/core/PDALWriter.h>
#include <rtabmap/utilite/UFile.h>
#include <rtabmap/utilite/ULogger.h>
#include <rtabmap/utilite/UStl.h>
#include <pdal/io/BufferReader.hpp>
#include <pdal/StageFactory.hpp>
#include <pdal/PluginManager.hpp>
#ifdef RTABMAP_PDAL_16
#include <pdal/pdal_defines.h>
#else
#include <pdal/pdal_features.hpp>
#endif
namespace rtabmap {
std::string getPDALSupportedWriters()
{
std::string output;
// Force plugin loading.
#if PDAL_VERSION_MAJOR>1 || (PDAL_VERSION_MAJOR == 1 && PDAL_VERSION_MINOR > 7) || (PDAL_VERSION_MAJOR == 1 && PDAL_VERSION_MINOR == 7 && PDAL_VERSION_MINOR>=1)
pdal::StageFactory f;
pdal::PluginManager<pdal::Stage>::loadAll();
pdal::StringList stages = pdal::PluginManager<pdal::Stage>::names();
#else
pdal::StageFactory f(false);
pdal::StringList stages = pdal::PluginManager::names(PF_PluginType_Writer);
#endif
for(pdal::StringList::iterator iter=stages.begin(); iter!=stages.end(); ++iter)
{
if(!uStrContains(*iter, "writers"))
{
continue;
}
if(iter->compare("writers.null") == 0)
{
continue;
}
if(iter!=stages.begin())
{
output += " ";
}
output += UFile::getExtension(*iter);
}
return output;
}
int savePDALFile(const std::string & filePath, const pcl::PointCloud<pcl::PointXYZ> & cloud)
{
pdal::PointTable table;
table.layout()->registerDims({
pdal::Dimension::Id::X,
pdal::Dimension::Id::Y,
pdal::Dimension::Id::Z});
pdal::BufferReader bufferReader;
pdal::PointViewPtr view(new pdal::PointView(table));
for(size_t i=0; i<cloud.size(); ++i)
{
view->setField(pdal::Dimension::Id::X, i, cloud.at(i).x);
view->setField(pdal::Dimension::Id::Y, i, cloud.at(i).y);
view->setField(pdal::Dimension::Id::Z, i, cloud.at(i).z);
}
bufferReader.addView(view);
pdal::StageFactory factory;
pdal::Stage *writer = factory.createStage("writers." + UFile::getExtension(filePath));
if(writer)
{
pdal::Options writerOps;
writerOps.add("filename", filePath);
writer->setOptions(writerOps);
writer->setInput(bufferReader);
writer->prepare(table);
writer->execute(table);
}
else
{
UERROR("PDAL: cannot find writer for extension \"%s\". Available extensions: \"%s\"",
UFile::getExtension(filePath).c_str(),
getPDALSupportedWriters().c_str());
return 1;
}
return 0; //success
}
int savePDALFile(const std::string & filePath, const pcl::PointCloud<pcl::PointXYZRGB> & cloud)
{
pdal::PointTable table;
table.layout()->registerDims({
pdal::Dimension::Id::X,
pdal::Dimension::Id::Y,
pdal::Dimension::Id::Z,
pdal::Dimension::Id::Red,
pdal::Dimension::Id::Green,
pdal::Dimension::Id::Blue});
pdal::BufferReader bufferReader;
pdal::PointViewPtr view(new pdal::PointView(table));
for(size_t i=0; i<cloud.size(); ++i)
{
view->setField(pdal::Dimension::Id::X, i, cloud.at(i).x);
view->setField(pdal::Dimension::Id::Y, i, cloud.at(i).y);
view->setField(pdal::Dimension::Id::Z, i, cloud.at(i).z);
view->setField(pdal::Dimension::Id::Red, i, cloud.at(i).r);
view->setField(pdal::Dimension::Id::Green, i, cloud.at(i).g);
view->setField(pdal::Dimension::Id::Blue, i, cloud.at(i).b);
}
bufferReader.addView(view);
pdal::StageFactory factory;
pdal::Stage *writer = factory.createStage("writers." + UFile::getExtension(filePath));
if(writer)
{
pdal::Options writerOps;
writerOps.add("filename", filePath);
writer->setOptions(writerOps);
writer->setInput(bufferReader);
writer->prepare(table);
writer->execute(table);
}
else
{
UERROR("PDAL: cannot find writer for extension \"%s\". Available extensions: \"%s\"",
UFile::getExtension(filePath).c_str(),
getPDALSupportedWriters().c_str());
return 1;
}
return 0; //success
}
int savePDALFile(const std::string & filePath, const pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud)
{
pdal::PointTable table;
table.layout()->registerDims({
pdal::Dimension::Id::X,
pdal::Dimension::Id::Y,
pdal::Dimension::Id::Z,
pdal::Dimension::Id::Red,
pdal::Dimension::Id::Green,
pdal::Dimension::Id::Blue,
pdal::Dimension::Id::NormalX,
pdal::Dimension::Id::NormalY,
pdal::Dimension::Id::NormalZ});
pdal::BufferReader bufferReader;
pdal::PointViewPtr view(new pdal::PointView(table));
for(size_t i=0; i<cloud.size(); ++i)
{
view->setField(pdal::Dimension::Id::X, i, cloud.at(i).x);
view->setField(pdal::Dimension::Id::Y, i, cloud.at(i).y);
view->setField(pdal::Dimension::Id::Z, i, cloud.at(i).z);
view->setField(pdal::Dimension::Id::Red, i, cloud.at(i).r);
view->setField(pdal::Dimension::Id::Green, i, cloud.at(i).g);
view->setField(pdal::Dimension::Id::Blue, i, cloud.at(i).b);
view->setField(pdal::Dimension::Id::NormalX, i, cloud.at(i).normal_x);
view->setField(pdal::Dimension::Id::NormalY, i, cloud.at(i).normal_y);
view->setField(pdal::Dimension::Id::NormalZ, i, cloud.at(i).normal_z);
}
bufferReader.addView(view);
pdal::StageFactory factory;
pdal::Stage *writer = factory.createStage("writers." + UFile::getExtension(filePath));
if(writer)
{
pdal::Options writerOps;
writerOps.add("filename", filePath);
writer->setOptions(writerOps);
writer->setInput(bufferReader);
writer->prepare(table);
writer->execute(table);
}
else
{
UERROR("PDAL: cannot find writer for extension \"%s\". Available extensions: \"%s\"",
UFile::getExtension(filePath).c_str(),
getPDALSupportedWriters().c_str());
return 1;
}
return 0; //success
}
int savePDALFile(const std::string & filePath, const pcl::PointCloud<pcl::PointXYZI> & cloud)
{
pdal::PointTable table;
table.layout()->registerDims({
pdal::Dimension::Id::X,
pdal::Dimension::Id::Y,
pdal::Dimension::Id::Z,
pdal::Dimension::Id::Intensity});
pdal::BufferReader bufferReader;
pdal::PointViewPtr view(new pdal::PointView(table));
for(size_t i=0; i<cloud.size(); ++i)
{
view->setField(pdal::Dimension::Id::X, i, cloud.at(i).x);
view->setField(pdal::Dimension::Id::Y, i, cloud.at(i).y);
view->setField(pdal::Dimension::Id::Z, i, cloud.at(i).z);
view->setField(pdal::Dimension::Id::Intensity, i, (unsigned short)cloud.at(i).intensity);
}
bufferReader.addView(view);
pdal::StageFactory factory;
pdal::Stage *writer = factory.createStage("writers." + UFile::getExtension(filePath));
if(writer)
{
pdal::Options writerOps;
writerOps.add("filename", filePath);
writer->setOptions(writerOps);
writer->setInput(bufferReader);
writer->prepare(table);
writer->execute(table);
}
else
{
UERROR("PDAL: cannot find writer for extension \"%s\". Available extensions: \"%s\"",
UFile::getExtension(filePath).c_str(),
getPDALSupportedWriters().c_str());
return 1;
}
return 0; //success
}
int savePDALFile(const std::string & filePath, const pcl::PointCloud<pcl::PointXYZINormal> & cloud)
{
pdal::PointTable table;
table.layout()->registerDims({
pdal::Dimension::Id::X,
pdal::Dimension::Id::Y,
pdal::Dimension::Id::Z,
pdal::Dimension::Id::Intensity,
pdal::Dimension::Id::NormalX,
pdal::Dimension::Id::NormalY,
pdal::Dimension::Id::NormalZ});
pdal::BufferReader bufferReader;
pdal::PointViewPtr view(new pdal::PointView(table));
for(size_t i=0; i<cloud.size(); ++i)
{
view->setField(pdal::Dimension::Id::X, i, cloud.at(i).x);
view->setField(pdal::Dimension::Id::Y, i, cloud.at(i).y);
view->setField(pdal::Dimension::Id::Z, i, cloud.at(i).z);
view->setField(pdal::Dimension::Id::Intensity, i, (unsigned short)cloud.at(i).intensity);
view->setField(pdal::Dimension::Id::NormalX, i, cloud.at(i).normal_x);
view->setField(pdal::Dimension::Id::NormalY, i, cloud.at(i).normal_y);
view->setField(pdal::Dimension::Id::NormalZ, i, cloud.at(i).normal_z);
}
bufferReader.addView(view);
pdal::StageFactory factory;
pdal::Stage *writer = factory.createStage("writers." + UFile::getExtension(filePath));
if(writer)
{
pdal::Options writerOps;
writerOps.add("filename", filePath);
writer->setOptions(writerOps);
writer->setInput(bufferReader);
writer->prepare(table);
writer->execute(table);
}
else
{
UERROR("PDAL: cannot find writer for extension \"%s\". Available extensions: \"%s\"",
UFile::getExtension(filePath).c_str(),
getPDALSupportedWriters().c_str());
return 1;
}
return 0; //success
}
}
+92 -13
View File
@@ -76,6 +76,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <open_chisel/weighting/ConstantWeighter.h> #include <open_chisel/weighting/ConstantWeighter.h>
#endif #endif
#ifdef RTABMAP_PDAL
#include <rtabmap/core/PDALWriter.h>
#endif
namespace rtabmap { namespace rtabmap {
ExportCloudsDialog::ExportCloudsDialog(QWidget *parent) : ExportCloudsDialog::ExportCloudsDialog(QWidget *parent) :
@@ -3401,9 +3405,31 @@ void ExportCloudsDialog::saveClouds(
{ {
if(clouds.size() == 1) if(clouds.size() == 1)
{ {
QString path = QFileDialog::getSaveFileName(this, tr("Save cloud to ..."), workingDirectory+QDir::separator()+"cloud.ply", tr("Point cloud data (*.ply *.pcd)")); #ifdef RTABMAP_PDAL
QString extensions = tr("Point cloud data (*.ply *.pcd");
std::list<std::string> pdalFormats = uSplit(getPDALSupportedWriters(), ' ');
for(std::list<std::string>::iterator iter=pdalFormats.begin(); iter!=pdalFormats.end(); ++iter)
{
if(iter->compare("ply") == 0 || iter->compare("pcd") == 0)
{
continue;
}
extensions += QString(" *.") + iter->c_str();
}
extensions += ")";
#else
QString extensions = tr("Point cloud data (*.ply *.pcd)");
#endif
QString path = QFileDialog::getSaveFileName(this, tr("Save cloud to ..."), workingDirectory+QDir::separator()+"cloud.ply", extensions);
if(!path.isEmpty()) if(!path.isEmpty())
{ {
if(QFileInfo(path).suffix().isEmpty())
{
//use ply by default
path += ".ply";
}
if(clouds.begin()->second->size()) if(clouds.begin()->second->size())
{ {
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudRGBWithoutNormals; pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudRGBWithoutNormals;
@@ -3479,14 +3505,8 @@ void ExportCloudsDialog::saveClouds(
success = pcl::io::savePCDFile(path.toStdString(), *clouds.begin()->second, binaryMode) == 0; success = pcl::io::savePCDFile(path.toStdString(), *clouds.begin()->second, binaryMode) == 0;
} }
} }
else if(QFileInfo(path).suffix() == "ply" || QFileInfo(path).suffix() == "") else if(QFileInfo(path).suffix() == "ply")
{ {
if(QFileInfo(path).suffix() == "")
{
//use ply by default
path += ".ply";
}
if(cloudIWithNormals.get()) if(cloudIWithNormals.get())
{ {
success = pcl::io::savePLYFile(path.toStdString(), *cloudIWithNormals, binaryMode) == 0; success = pcl::io::savePLYFile(path.toStdString(), *cloudIWithNormals, binaryMode) == 0;
@@ -3504,9 +3524,30 @@ void ExportCloudsDialog::saveClouds(
success = pcl::io::savePLYFile(path.toStdString(), *clouds.begin()->second, binaryMode) == 0; success = pcl::io::savePLYFile(path.toStdString(), *clouds.begin()->second, binaryMode) == 0;
} }
} }
#ifdef RTABMAP_PDAL
else if(!QFileInfo(path).suffix().isEmpty())
{
if(cloudIWithNormals.get())
{
success = savePDALFile(path.toStdString(), *cloudIWithNormals) == 0;
}
else if(cloudIWithoutNormals.get())
{
success = savePDALFile(path.toStdString(), *cloudIWithoutNormals) == 0;
}
else if(cloudRGBWithoutNormals.get())
{
success = savePDALFile(path.toStdString(), *cloudRGBWithoutNormals) == 0;
}
else
{
success = savePDALFile(path.toStdString(), *clouds.begin()->second) == 0;
}
}
#endif
else else
{ {
UERROR("Extension not recognized! (%s) Should be one of (*.ply *.pcd).", QFileInfo(path).suffix().toStdString().c_str()); UERROR("Extension not recognized! (%s) Should be one of (*.ply *.pcd *.las).", QFileInfo(path).suffix().toStdString().c_str());
} }
if(success) if(success)
{ {
@@ -3528,13 +3569,30 @@ void ExportCloudsDialog::saveClouds(
} }
else if(clouds.size()) else if(clouds.size())
{ {
QString path = QFileDialog::getExistingDirectory(this, tr("Save clouds to (*.ply *.pcd)..."), workingDirectory, 0); QStringList items;
items.push_back("ply");
items.push_back("pcd");
#ifdef RTABMAP_PDAL
QString extensions = tr("Save clouds to (*.ply *.pcd");
std::list<std::string> pdalFormats = uSplit(getPDALSupportedWriters(), ' ');
for(std::list<std::string>::iterator iter=pdalFormats.begin(); iter!=pdalFormats.end(); ++iter)
{
if(iter->compare("ply") == 0 || iter->compare("pcd") == 0)
{
continue;
}
extensions += QString(" *.") + iter->c_str();
items.push_back(iter->c_str());
}
extensions += ")...";
#else
QString extensions = tr("Save clouds to (*.ply *.pcd)...");
#endif
QString path = QFileDialog::getExistingDirectory(this, extensions, workingDirectory, 0);
if(!path.isEmpty()) if(!path.isEmpty())
{ {
bool ok = false; bool ok = false;
QStringList items;
items.push_back("ply");
items.push_back("pcd");
QString suffix = QInputDialog::getItem(this, tr("File format"), tr("Which format?"), items, 0, false, &ok); QString suffix = QInputDialog::getItem(this, tr("File format"), tr("Which format?"), items, 0, false, &ok);
if(ok) if(ok)
@@ -3641,6 +3699,27 @@ void ExportCloudsDialog::saveClouds(
success = pcl::io::savePLYFile(pathFile.toStdString(), *transformedCloud, binaryMode) == 0; success = pcl::io::savePLYFile(pathFile.toStdString(), *transformedCloud, binaryMode) == 0;
} }
} }
#ifdef RTABMAP_PDAL
else if(!suffix.isEmpty())
{
if(cloudIWithNormals.get())
{
success = savePDALFile(pathFile.toStdString(), *cloudIWithNormals) == 0;
}
else if(cloudIWithoutNormals.get())
{
success = savePDALFile(pathFile.toStdString(), *cloudIWithoutNormals) == 0;
}
else if(cloudRGBWithoutNormals.get())
{
success = savePDALFile(pathFile.toStdString(), *cloudRGBWithoutNormals) == 0;
}
else
{
success = savePDALFile(pathFile.toStdString(), *transformedCloud) == 0;
}
}
#endif
else else
{ {
UFATAL("Extension not recognized! (%s)", suffix.toStdString().c_str()); UFATAL("Extension not recognized! (%s)", suffix.toStdString().c_str());