Skip to content

Commit 9609fd9

Browse files
committed
mesh: finetune params for thin structures
(cherry picked from commit c02207b1aec03dee83e30d41e786d972646f7aaf)
1 parent bf8fc85 commit 9609fd9

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

apps/ReconstructMesh/ReconstructMesh.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ bool Application::Initialize(size_t argc, LPCTSTR* argv)
128128
("input-file,i", boost::program_options::value<std::string>(&OPT::strInputFileName), "input filename containing camera poses and image list")
129129
("pointcloud-file,p", boost::program_options::value<std::string>(&OPT::strPointCloudFileName), "dense point-cloud with views file name to reconstruct (overwrite existing point-cloud)")
130130
("output-file,o", boost::program_options::value<std::string>(&OPT::strOutputFileName), "output filename for storing the mesh")
131-
("min-point-distance,d", boost::program_options::value(&OPT::fDistInsert)->default_value(2.5f), "minimum distance in pixels between the projection of two 3D points to consider them different while triangulating (0 - disabled)")
131+
("min-point-distance,d", boost::program_options::value(&OPT::fDistInsert)->default_value(1.5f), "minimum distance in pixels between the projection of two 3D points to consider them different while triangulating (0 - disabled)")
132132
("integrate-only-roi", boost::program_options::value(&OPT::bUseOnlyROI)->default_value(false), "use only the points inside the ROI")
133133
("constant-weight", boost::program_options::value(&OPT::bUseConstantWeight)->default_value(true), "considers all view weights 1 instead of the available weight")
134134
("free-space-support,f", boost::program_options::value(&OPT::bUseFreeSpaceSupport)->default_value(false), "exploits the free-space support in order to reconstruct weakly-represented surfaces")
@@ -474,8 +474,8 @@ int main(int argc, LPCTSTR* argv)
474474
numVertices-scene.mesh.vertices.size(), numFaces-scene.mesh.faces.size(), TD_TIMER_GET_FMT().c_str());
475475
}
476476
const float fDecimate(OPT::nTargetFaceNum ? static_cast<float>(OPT::nTargetFaceNum) / scene.mesh.faces.size() : OPT::fDecimateMesh);
477-
scene.mesh.Clean(fDecimate, OPT::fRemoveSpurious, OPT::bRemoveSpikes, OPT::nCloseHoles, OPT::nSmoothMesh, OPT::fEdgeLength, false);
478-
scene.mesh.Clean(1.f, 0.f, OPT::bRemoveSpikes, OPT::nCloseHoles, 0u, 0.f, false); // extra cleaning trying to close more holes
477+
scene.mesh.Clean(1.f, OPT::fRemoveSpurious, OPT::bRemoveSpikes, OPT::nCloseHoles, OPT::nSmoothMesh, OPT::fEdgeLength, false);
478+
scene.mesh.Clean(fDecimate, 0.f, OPT::bRemoveSpikes, OPT::nCloseHoles, 0u, 0.f, false); // extra cleaning trying to close more holes
479479
scene.mesh.Clean(1.f, 0.f, false, 0u, 0u, 0.f, true); // extra cleaning to remove non-manifold problems created by closing holes
480480
scene.obb = initialOBB;
481481

libs/MVS/Mesh.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -848,26 +848,22 @@ void Mesh::Clean(float fDecimate, float fSpurious, bool bRemoveSpikes, unsigned
848848
// remove spurious components
849849
if (fSpurious > 0) {
850850
FloatArr edgeLens(0, mesh.EN());
851-
for (CLEAN::Mesh::EdgeIterator ei=mesh.edge.begin(); ei!=mesh.edge.end(); ++ei) {
852-
const CLEAN::Vertex::CoordType& P0((*ei).V(0)->P());
853-
const CLEAN::Vertex::CoordType& P1((*ei).V(1)->P());
854-
edgeLens.Insert((P1-P0).Norm());
851+
for (CLEAN::Mesh::EdgeType& edge: mesh.edge) {
852+
const CLEAN::Vertex::CoordType& P1(edge.V(1)->P());
853+
const CLEAN::Vertex::CoordType& P0(edge.V(0)->P());
854+
edgeLens.Insert((P1-P0).SquaredNorm());
855855
}
856-
#if 0
857-
const auto ret(ComputeX84Threshold<float,float>(edgeLens.Begin(), edgeLens.size(), 3.f*fSpurious));
858-
const float thLongEdge(ret.first+ret.second);
859-
#else
860-
const float thLongEdge(edgeLens.GetNth(edgeLens.size()*95/100)*fSpurious);
861-
#endif
862856
// remove faces with too long edges
857+
const float thLongEdge(SQRT(edgeLens.GetNth(edgeLens.size()*95/100))*fSpurious);
863858
const size_t numLongFaces(vcg::tri::UpdateSelection<CLEAN::Mesh>::FaceOutOfRangeEdge(mesh, 0, thLongEdge));
864859
for (CLEAN::Mesh::FaceIterator fi=mesh.face.begin(); fi!=mesh.face.end(); ++fi)
865860
if (!(*fi).IsD() && (*fi).IsS())
866861
vcg::tri::Allocator<CLEAN::Mesh>::DeleteFace(mesh, *fi);
867862
DEBUG_ULTIMATE("Removed %d faces with edges longer than %f", numLongFaces, thLongEdge);
868863
// remove isolated components
864+
const float thLongSize(SQRT(edgeLens.GetNth(edgeLens.size()*55/100))*fSpurious);
869865
vcg::tri::UpdateTopology<CLEAN::Mesh>::FaceFace(mesh);
870-
const std::pair<int, int> delInfo(vcg::tri::Clean<CLEAN::Mesh>::RemoveSmallConnectedComponentsDiameter(mesh, thLongEdge));
866+
const std::pair<int, int> delInfo(vcg::tri::Clean<CLEAN::Mesh>::RemoveSmallConnectedComponentsDiameter(mesh, thLongSize));
871867
DEBUG_ULTIMATE("Removed %d connected components out of %d", delInfo.second, delInfo.first);
872868
}
873869

0 commit comments

Comments
 (0)