Skip to content

Commit

Permalink
Fixed #1380
Browse files Browse the repository at this point in the history
  • Loading branch information
matlabbe committed Nov 16, 2024
1 parent f10dee4 commit b2e26e8
Showing 1 changed file with 62 additions and 47 deletions.
109 changes: 62 additions & 47 deletions tools/Export/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,53 @@ int main(int argc, char * argv[])
}
else
{
// Save multiband first
if(multiband)
{
timer.restart();
std::string outputPath=outputDirectory+"/"+baseName+"_mesh_multiband.obj";
printf("MultiBand texturing (size=%d, downscale=%d, unwrap method=%s, fill holes=%s, padding=%d, best score thr=%f, angle thr=%f, force visible=%s)... \"%s\"\n",
textureSize,
multibandDownScale,
multibandUnwrap==1?"ABF":multibandUnwrap==2?"LSCM":"Basic",
multibandFillHoles?"true":"false",
multibandPadding,
multibandBestScoreThr,
multibandAngleHardthr,
multibandForceVisible?"false":"true",
outputPath.c_str());
if(util3d::multiBandTexturing(outputPath,
textureMesh->cloud,
textureMesh->tex_polygons[0],
robotPosesFiltered,
vertexToPixels,
std::map<int, cv::Mat >(),
std::map<int, std::vector<CameraModel> >(),
rtabmap.getMemory(),
0,
textureSize,
multibandDownScale,
multibandNbContrib,
"jpg",
gains,
blendingGains,
contrastValues,
doGainCompensationRGB,
multibandUnwrap,
multibandFillHoles,
multibandPadding,
multibandBestScoreThr,
multibandAngleHardthr,
multibandForceVisible))
{
printf("MultiBand texturing...done (%fs).\n", timer.ticks());
}
else
{
printf("MultiBand texturing...failed! (%fs)\n", timer.ticks());
}
}

// TextureMesh OBJ
bool success = false;
UASSERT(!textures.empty());
Expand All @@ -1973,9 +2020,23 @@ int main(int argc, char * argv[])
}
if(success)
{

std::string outputPath=outputDirectory+"/"+baseName+"_mesh.obj";
printf("Saving obj (%d vertices) to %s.\n", (int)textureMesh->cloud.data.size()/textureMesh->cloud.point_step, outputPath.c_str());
#if PCL_VERSION_COMPARE(>=, 1, 13, 0)
textureMesh->tex_coord_indices = std::vector<std::vector<pcl::Vertices>>();
auto nr_meshes = static_cast<unsigned>(textureMesh->tex_polygons.size());
unsigned f_idx = 0;
for (unsigned m = 0; m < nr_meshes; m++) {
std::vector<pcl::Vertices> ci = textureMesh->tex_polygons[m];
for(std::size_t i = 0; i < ci.size(); i++) {
for (std::size_t j = 0; j < ci[i].vertices.size(); j++) {
ci[i].vertices[j] = ci[i].vertices.size() * (i + f_idx) + j;
}
}
textureMesh->tex_coord_indices.push_back(ci);
f_idx += static_cast<unsigned>(textureMesh->tex_polygons[m].size());
}
#endif
success = pcl::io::saveOBJFile(outputPath, *textureMesh) == 0;

if(success)
Expand All @@ -1988,52 +2049,6 @@ int main(int argc, char * argv[])
}
}
}

if(multiband)
{
timer.restart();
std::string outputPath=outputDirectory+"/"+baseName+"_mesh_multiband.obj";
printf("MultiBand texturing (size=%d, downscale=%d, unwrap method=%s, fill holes=%s, padding=%d, best score thr=%f, angle thr=%f, force visible=%s)... \"%s\"\n",
textureSize,
multibandDownScale,
multibandUnwrap==1?"ABF":multibandUnwrap==2?"LSCM":"Basic",
multibandFillHoles?"true":"false",
multibandPadding,
multibandBestScoreThr,
multibandAngleHardthr,
multibandForceVisible?"false":"true",
outputPath.c_str());
if(util3d::multiBandTexturing(outputPath,
textureMesh->cloud,
textureMesh->tex_polygons[0],
robotPosesFiltered,
vertexToPixels,
std::map<int, cv::Mat >(),
std::map<int, std::vector<CameraModel> >(),
rtabmap.getMemory(),
0,
textureSize,
multibandDownScale,
multibandNbContrib,
"jpg",
gains,
blendingGains,
contrastValues,
doGainCompensationRGB,
multibandUnwrap,
multibandFillHoles,
multibandPadding,
multibandBestScoreThr,
multibandAngleHardthr,
multibandForceVisible))
{
printf("MultiBand texturing...done (%fs).\n", timer.ticks());
}
else
{
printf("MultiBand texturing...failed! (%fs)\n", timer.ticks());
}
}
}
}
}
Expand Down

0 comments on commit b2e26e8

Please sign in to comment.