Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --target-face-num parameter to ReconstructMesh #671

Merged
merged 7 commits into from
Apr 29, 2021

Conversation

pierotofy
Copy link
Contributor

@pierotofy pierotofy commented Apr 26, 2021

Hello ✋

This PR proposes the following additions/changes:

  • Add a --target-face-num parameter to ReconstructMesh. Sometimes a target number of faces is known/desired and can sometimes work better for a user than using the --decimate parameter, which is a function of the number of existing faces.
  • Fixes the logic in ReconstructMesh to allow the usage of --mesh-file without passing an openMVS project. Currently a user needs to always pass an input project (see line 177 and 230 of ReconstructMesh.cpp).

Please let me know if changes are needed? 🙏

@@ -61,6 +61,7 @@ bool bUseFreeSpaceSupport;
float fThicknessFactor;
float fQualityFactor;
float fDecimateMesh;
int iTargetFaceNum;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls use unsigned instead of int as it never takes negative values

@@ -167,12 +169,12 @@ bool Initialize(size_t argc, LPCTSTR* argv)
// validate input
Util::ensureValidPath(OPT::strInputFileName);
Util::ensureUnifySlash(OPT::strInputFileName);
if (OPT::vm.count("help") || OPT::strInputFileName.IsEmpty()) {
if (OPT::vm.count("help") || (OPT::strInputFileName.IsEmpty() && OPT::strMeshFileName.IsEmpty())) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd implement this differently:
pass the mesh file as the input instead as using --mesh-file param, and at the scene loading time you have an import option which if set on true, it allows to load a mesh too instead of only MVS

Copy link
Contributor Author

@pierotofy pierotofy Apr 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @cdcseacave, thanks for the feedback. Could you expand more on this one?

at the scene loading time you have an import option which if set on true

Is this an additional flag? Could one just check for the file extension instead too? (If it's MVS, load scene, if it's OBJ/PLY, load mesh).

Does --mesh-file have another purpose then?

scene.mesh.Clean(OPT::fDecimateMesh, OPT::fRemoveSpurious, OPT::bRemoveSpikes, OPT::nCloseHoles, OPT::nSmoothMesh, false);
scene.mesh.Clean(1.f, 0.f, OPT::bRemoveSpikes, OPT::nCloseHoles, 0, false); // extra cleaning trying to close more holes
scene.mesh.Clean(1.f, 0.f, false, 0, 0, true); // extra cleaning to remove non-manifold problems created by closing holes
scene.mesh.Clean(OPT::fDecimateMesh, OPT::fRemoveSpurious, OPT::bRemoveSpikes, OPT::nCloseHoles, OPT::nSmoothMesh, false, OPT::iTargetFaceNum);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

combine iTargetFaceNum and fDecimateMesh, by converting the new param in the existing one by computing the desired ratio

@cdcseacave
Copy link
Owner

Good idea, but pls address the small suggestions I found.

@cdcseacave
Copy link
Owner

pls see the function definition:

bool Load(const String& fileName, bool bImport=false);

@pierotofy
Copy link
Contributor Author

pierotofy commented Apr 27, 2021

pls use unsigned instead of int as it never takes negative values

✔️

combine iTargetFaceNum and fDecimateMesh, by converting the new param in the existing one by computing the desired ratio

✔️

pass the mesh file as the input instead as using --mesh-file param

❌ this doesn't seem to work, as the logic in https://github.com/cdcseacave/openMVS/blob/develop/apps/ReconstructMesh/ReconstructMesh.cpp#L291-L301 overrides the loaded mesh. I left the use of the --mesh-file parameter instead. Passing both -i and --mesh-file is inefficient because it leads to loading the mesh twice.

@cdcseacave
Copy link
Owner

maybe I misunderstood, I thought the goal is to load a mesh to clean/decimate only
if that is the case, what I suggested is what you need, and you just need to add also scene.mesh.IsEmpty() check here

if (OPT::strMeshFileName.IsEmpty()) {

@pierotofy
Copy link
Contributor Author

I thought the goal is to load a mesh to clean/decimate only

It is.

With this PR, I can do:

OpenMVS/ReconstructMesh --mesh-file mesh.ply -o clean.ply --target-face-num 10000000

I get that you're trying to recommend to use the -i flag so that we could do:

OpenMVS/ReconstructMesh -i mesh.ply -o clean.ply --target-face-num 10000000

I don't know or I'm not understanding how you want me to code this, but feel free to edit as you see fit.

@cdcseacave
Copy link
Owner

cdcseacave commented Apr 27, 2021

I've edited the file as I see it. I did not test it, changed it directly on github, but should be close to working. It should work by running:

ReconstructMesh mesh.ply -o clean.ply --target-face-num 10000000

@pierotofy
Copy link
Contributor Author

Thanks @cdcseacave ! I'll test sometimes tomorrow and report back. 🙏

@pierotofy
Copy link
Contributor Author

Tested, and works great! 👍

@cdcseacave
Copy link
Owner

Cool, I'll merge it then. Thank you, Piero!

@cdcseacave cdcseacave merged commit ecd5890 into cdcseacave:develop Apr 29, 2021
cdcseacave added a commit that referenced this pull request Dec 11, 2021
* dense: add image mask support

* dense: fix bug in mask application

* build: update find packages

* build: fix usage as third-party library

* interface: export and compare camera poses with an OpenMVG refined version

* interface: export MVS scene to NVM format

* common: fix camera scaling

* dense: small code refactor

* mvs: view DMAPs with different resolution

* interface: replace define with constexp

* interface: small change

* common: fix PFM exporter/importer

* common: disable CPUID on ARM platforms

* dense: add Region-Of-Interest (ROI) support

* common: improve octree speed

* build: update AppVeyor

* mesh: split mesh in sub-meshed by max area

* dense: split scene in sub-scenes

* cmake: build libCommon/IO/Math as shared if BUILD_SHARED_LIBS=ON (#650)

* mesh: fix bug in RemoveFaces()

* dense: filter more redundant views from sub-scenes

* common: add ZSTD serialization support

* apps: set internal linkage for functions and variables (#656)

* common: small refactor

* mesh: raster triangles using barycentric coordinates

* remove cotire

* dense: merge small sub-scenes

* interface: import COLMAP depth-maps

* interface: add MVS preset to the python script

* interface: fix COLMAP on linux

* common: make binary projects portable

* viewer: display views seeing selected point or points seen by the current view

* dense: improve depth-map initialization

* dense: merge depth-maps (no fusion)

* interface: add similarity transform functionality

* common: fix file permissions on linux

* mesh: add GLTF writing support

* mesh: add target-face-num parameter to ReconstructMesh (#671)

* mesh: improve GLTF support

* dense: add geometric-consistency

* dense: fix for invalid images

(cherry picked from commit b29648f835e5ee0b36b4240a160a20124001f34d)

* dense: close file in reading invalid depth-map (#685)

* dense: export point-cloud with min number of views per point

(cherry picked from commit 9b6b2fd7ec89a5b7ea3acdef83664daccbfc8c03)

* dense: detect computed depth-maps

(cherry picked from commit 52f9162874e4c3da66bb618dcea9dddc1bdf644a)

* refine: initialize image neighbors from input mesh

(cherry picked from commit 2a069fa0856582da2b766ba85091d3e46fa783de)

* dense: select better angle neighbors

(cherry picked from commit 05a49551ad13873c664bf394d4584cf5c44f198c)

* dense: patch-match implemented in CUDA (faster & better)

* common: fix latest boost

* dense: expose --cuda-device option (#707)

* build: add Dockerfile for CUDA #710

* dense: fix bug in selecting views

(cherry picked from commit d068c02295234199f49b26afc85ac643886f2311)

* build: fix CUDA for older cards (#712)

* dense: fix small clusters (#702)

* interface: fix COLMAP log export

* interface: add Metashape and predefined neighbors list support

* interface: fix compile linux

* dense: add support for scenes with empty point-cloud but known (coarse) mesh

* dense: filter low score estimates

* interface: add Metashape ROI support

* viewer: display ROI

* dense: increase NCC threshold for CUDA

* interface: remap Metashape indices

* dense: fix depth-map crash in CUDA

* interface: update MVG-MVS pipeline

Co-authored-by: YOSHIFUJI Naoki <lwisteria.ao@gmail.com>
Co-authored-by: Piero Toffanin <pt@masseranolabs.com>
Co-authored-by: Tommy Bojanin <Bojanint@gmail.com>
cdcseacave added a commit that referenced this pull request Dec 11, 2021
* dense: add image mask support

* dense: fix bug in mask application

* build: update find packages

* build: fix usage as third-party library

* interface: export and compare camera poses with an OpenMVG refined version

* interface: export MVS scene to NVM format

* common: fix camera scaling

* dense: small code refactor

* mvs: view DMAPs with different resolution

* interface: replace define with constexp

* interface: small change

* common: fix PFM exporter/importer

* common: disable CPUID on ARM platforms

* dense: add Region-Of-Interest (ROI) support

* common: improve octree speed

* build: update AppVeyor

* mesh: split mesh in sub-meshed by max area

* dense: split scene in sub-scenes

* cmake: build libCommon/IO/Math as shared if BUILD_SHARED_LIBS=ON (#650)

* mesh: fix bug in RemoveFaces()

* dense: filter more redundant views from sub-scenes

* common: add ZSTD serialization support

* apps: set internal linkage for functions and variables (#656)

* common: small refactor

* mesh: raster triangles using barycentric coordinates

* remove cotire

* dense: merge small sub-scenes

* interface: import COLMAP depth-maps

* interface: add MVS preset to the python script

* interface: fix COLMAP on linux

* common: make binary projects portable

* viewer: display views seeing selected point or points seen by the current view

* dense: improve depth-map initialization

* dense: merge depth-maps (no fusion)

* interface: add similarity transform functionality

* common: fix file permissions on linux

* mesh: add GLTF writing support

* mesh: add target-face-num parameter to ReconstructMesh (#671)

* mesh: improve GLTF support

* dense: add geometric-consistency

* dense: fix for invalid images

(cherry picked from commit b29648f835e5ee0b36b4240a160a20124001f34d)

* dense: close file in reading invalid depth-map (#685)

* dense: export point-cloud with min number of views per point

(cherry picked from commit 9b6b2fd7ec89a5b7ea3acdef83664daccbfc8c03)

* dense: detect computed depth-maps

(cherry picked from commit 52f9162874e4c3da66bb618dcea9dddc1bdf644a)

* refine: initialize image neighbors from input mesh

(cherry picked from commit 2a069fa0856582da2b766ba85091d3e46fa783de)

* dense: select better angle neighbors

(cherry picked from commit 05a49551ad13873c664bf394d4584cf5c44f198c)

* dense: patch-match implemented in CUDA (faster & better)

* common: fix latest boost

* dense: expose --cuda-device option (#707)

* build: add Dockerfile for CUDA #710

* dense: fix bug in selecting views

(cherry picked from commit d068c02295234199f49b26afc85ac643886f2311)

* build: fix CUDA for older cards (#712)

* dense: fix small clusters (#702)

* interface: fix COLMAP log export

* interface: add Metashape and predefined neighbors list support

* interface: fix compile linux

* dense: add support for scenes with empty point-cloud but known (coarse) mesh

* dense: filter low score estimates

* interface: add Metashape ROI support

* viewer: display ROI

* dense: increase NCC threshold for CUDA

* interface: remap Metashape indices

* dense: fix depth-map crash in CUDA

* interface: update MVG-MVS pipeline

* increase version to 2.0.0

Co-authored-by: YOSHIFUJI Naoki <lwisteria.ao@gmail.com>
Co-authored-by: Piero Toffanin <pt@masseranolabs.com>
Co-authored-by: Tommy Bojanin <Bojanint@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants