From 51cddc5af0af8ffb28eca1ee707078ee27fd22ad Mon Sep 17 00:00:00 2001 From: Fabien Servant Date: Tue, 29 Oct 2024 08:42:02 +0100 Subject: [PATCH 1/2] Creation of the sfm Checking node --- meshroom/nodes/aliceVision/SfmChecking.py | 82 +++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 meshroom/nodes/aliceVision/SfmChecking.py diff --git a/meshroom/nodes/aliceVision/SfmChecking.py b/meshroom/nodes/aliceVision/SfmChecking.py new file mode 100644 index 0000000000..2be6789f98 --- /dev/null +++ b/meshroom/nodes/aliceVision/SfmChecking.py @@ -0,0 +1,82 @@ +__version__ = "1.0" + +from meshroom.core import desc +from meshroom.core.utils import VERBOSE_LEVEL +import os.path + + + +class SfmChecking(desc.Node): + + category = 'Utils' + documentation = ''' + Check an input Sfm for validity. + Throw an error if the sfm does not satisfy constraints + ''' + + inputs = [ + desc.File( + name="input", + label="SfMData", + description="Input SfMData file.", + value="", + ), + desc.FloatParam( + name="posecompletion", + label="Completion percentage", + description="Minimal percent of the views reconstructed.", + value=80.0, + range=(0.0, 100.0, 1.0), + ), + desc.ChoiceParam( + name="verboseLevel", + label="Verbose Level", + description="Verbosity level (fatal, error, warning, info, debug, trace).", + values=VERBOSE_LEVEL, + value="info", + ) + ] + + outputs = [ + desc.File( + name="output", + label="SfM File", + description="Path to the output SfM file.", + value=desc.Node.internalFolder + "sfmData.abc", + ) + ] + + def processChunk(self, chunk): + from pyalicevision import sfmData as avsfmdata + from pyalicevision import sfmDataIO as avsfmdataio + + error = False + + chunk.logManager.start(chunk.node.verboseLevel.value) + chunk.logger.error("open input") + data = avsfmdata.SfMData() + ret = avsfmdataio.load(data, chunk.node.input.value, avsfmdataio.ALL) + if not ret: + chunk.logger.error("Cannot open input") + chunk.logManager.end() + raise RuntimeError() + + total = len(data.getViews()) + valid = len(data.getValidViews()) + ratio = (100.0 * float(valid))/float(total) + + chunk.logger.info(f"Total views : {total}") + chunk.logger.info(f"Reconstructed views : {valid}") + chunk.logger.info(f"Percentage : {ratio}") + + if ratio < chunk.node.posecompletion.value: + chunk.logger.error("Percentage of reconstructed views is insufficient") + error = True + + avsfmdataio.save(data, chunk.node.output.value, avsfmdataio.ALL) + + chunk.logManager.end() + + if error: + raise RuntimeError() + From 9ec0a17cf6d5734bf63b08e110a2e45feab38a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Thu, 31 Oct 2024 17:04:32 +0100 Subject: [PATCH 2/2] [nodes] `SfMChecking`: Rename node and minor process improvements --- .../{SfmChecking.py => SfMChecking.py} | 45 +++++++++---------- 1 file changed, 20 insertions(+), 25 deletions(-) rename meshroom/nodes/aliceVision/{SfmChecking.py => SfMChecking.py} (69%) diff --git a/meshroom/nodes/aliceVision/SfmChecking.py b/meshroom/nodes/aliceVision/SfMChecking.py similarity index 69% rename from meshroom/nodes/aliceVision/SfmChecking.py rename to meshroom/nodes/aliceVision/SfMChecking.py index 2be6789f98..de191e1ae9 100644 --- a/meshroom/nodes/aliceVision/SfmChecking.py +++ b/meshroom/nodes/aliceVision/SfMChecking.py @@ -2,17 +2,15 @@ from meshroom.core import desc from meshroom.core.utils import VERBOSE_LEVEL -import os.path +class SfMChecking(desc.Node): -class SfmChecking(desc.Node): - - category = 'Utils' - documentation = ''' - Check an input Sfm for validity. - Throw an error if the sfm does not satisfy constraints - ''' + category = "Utils" + documentation = """ + Check an input SfM for validity. + Throw an error if the SfM does not satisfy constraints. + """ inputs = [ desc.File( @@ -22,8 +20,8 @@ class SfmChecking(desc.Node): value="", ), desc.FloatParam( - name="posecompletion", - label="Completion percentage", + name="poseCompletion", + label="Completion Percentage", description="Minimal percent of the views reconstructed.", value=80.0, range=(0.0, 100.0, 1.0), @@ -50,10 +48,9 @@ def processChunk(self, chunk): from pyalicevision import sfmData as avsfmdata from pyalicevision import sfmDataIO as avsfmdataio - error = False - chunk.logManager.start(chunk.node.verboseLevel.value) - chunk.logger.error("open input") + chunk.logger.info("Open input file") + data = avsfmdata.SfMData() ret = avsfmdataio.load(data, chunk.node.input.value, avsfmdataio.ALL) if not ret: @@ -63,20 +60,18 @@ def processChunk(self, chunk): total = len(data.getViews()) valid = len(data.getValidViews()) - ratio = (100.0 * float(valid))/float(total) + ratio = (100.0 * float(valid)) / float(total) - chunk.logger.info(f"Total views : {total}") - chunk.logger.info(f"Reconstructed views : {valid}") - chunk.logger.info(f"Percentage : {ratio}") + chunk.logger.info(f"Total views: {total}") + chunk.logger.info(f"Reconstructed views: {valid}") + chunk.logger.info(f"Percentage of reconstructed views: {ratio}") - if ratio < chunk.node.posecompletion.value: - chunk.logger.error("Percentage of reconstructed views is insufficient") - error = True + if ratio < chunk.node.poseCompletion.value: + chunk.logger.error("Percentage of reconstructed views is insufficient.") + chunk.logger.error(f"Expected {chunk.node.poseCompletion.value}, got {ratio}.") + chunk.logManager.end() + raise RuntimeError() avsfmdataio.save(data, chunk.node.output.value, avsfmdataio.ALL) - - chunk.logManager.end() - - if error: - raise RuntimeError() + chunk.logManager.end()