Export: added --output name option.

This commit is contained in:
matlabbe
2021-03-13 20:58:10 -05:00
parent 1e4b172a7d
commit ccc519ec58

View File

@@ -56,6 +56,7 @@ void showUsage()
printf("\nUsage:\n"
"rtabmap-export [options] database.db\n"
"Options:\n"
" --output Output name (default: name of the database is used).\n"
" --bin Export PLY in binary format.\n"
" --las Export cloud in LAS instead of PLY (PDAL dependency required).\n"
" --mesh Create a mesh.\n"
@@ -133,6 +134,7 @@ int main(int argc, char * argv[])
bool camProjection = false;
bool exportPoses = false;
bool exportImages = false;
std::string outputName;
cv::Vec3f min, max;
for(int i=1; i<argc; ++i)
{
@@ -140,6 +142,18 @@ int main(int argc, char * argv[])
{
showUsage();
}
else if(std::strcmp(argv[i], "--output") == 0)
{
++i;
if(i<argc-1)
{
outputName = argv[i];
}
else
{
showUsage();
}
}
else if(std::strcmp(argv[i], "--bin") == 0)
{
binary = true;
@@ -563,7 +577,7 @@ int main(int argc, char * argv[])
}
std::string outputDirectory = UDirectory::getDir(dbPath);
std::string baseName = uSplit(UFile::getName(dbPath), '.').front();
std::string baseName = outputName.empty()?uSplit(UFile::getName(dbPath), '.').front():outputName;
if(ba)
{
@@ -874,9 +888,9 @@ int main(int argc, char * argv[])
printf("Camera projection... done! (%fs)\n", timer.ticks());
}
if(saveInDb)
{
if(!(mesh || texture))
{
if(saveInDb)
{
printf("Saving in db... (%d points)\n", !cloudToExport->empty()?(int)cloudToExport->size():(int)cloudIToExport->size());
if(!cloudToExport->empty())
@@ -885,7 +899,6 @@ int main(int argc, char * argv[])
driver->saveOptimizedMesh(util3d::laserScanFromPointCloud(*cloudIToExport, Transform(), false).data());
printf("Saving in db... done!\n");
}
}
else
{
std::string ext = las?"las":"ply";
@@ -909,6 +922,7 @@ int main(int argc, char * argv[])
#endif
printf("Saving %s... done!\n", outputPath.c_str());
}
}
// Meshing...
if(mesh || texture)