Skip to content

Commit 51cddc5

Browse files
author
Fabien Servant
committed
Creation of the sfm Checking node
1 parent 88f9d4b commit 51cddc5

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
__version__ = "1.0"
2+
3+
from meshroom.core import desc
4+
from meshroom.core.utils import VERBOSE_LEVEL
5+
import os.path
6+
7+
8+
9+
class SfmChecking(desc.Node):
10+
11+
category = 'Utils'
12+
documentation = '''
13+
Check an input Sfm for validity.
14+
Throw an error if the sfm does not satisfy constraints
15+
'''
16+
17+
inputs = [
18+
desc.File(
19+
name="input",
20+
label="SfMData",
21+
description="Input SfMData file.",
22+
value="",
23+
),
24+
desc.FloatParam(
25+
name="posecompletion",
26+
label="Completion percentage",
27+
description="Minimal percent of the views reconstructed.",
28+
value=80.0,
29+
range=(0.0, 100.0, 1.0),
30+
),
31+
desc.ChoiceParam(
32+
name="verboseLevel",
33+
label="Verbose Level",
34+
description="Verbosity level (fatal, error, warning, info, debug, trace).",
35+
values=VERBOSE_LEVEL,
36+
value="info",
37+
)
38+
]
39+
40+
outputs = [
41+
desc.File(
42+
name="output",
43+
label="SfM File",
44+
description="Path to the output SfM file.",
45+
value=desc.Node.internalFolder + "sfmData.abc",
46+
)
47+
]
48+
49+
def processChunk(self, chunk):
50+
from pyalicevision import sfmData as avsfmdata
51+
from pyalicevision import sfmDataIO as avsfmdataio
52+
53+
error = False
54+
55+
chunk.logManager.start(chunk.node.verboseLevel.value)
56+
chunk.logger.error("open input")
57+
data = avsfmdata.SfMData()
58+
ret = avsfmdataio.load(data, chunk.node.input.value, avsfmdataio.ALL)
59+
if not ret:
60+
chunk.logger.error("Cannot open input")
61+
chunk.logManager.end()
62+
raise RuntimeError()
63+
64+
total = len(data.getViews())
65+
valid = len(data.getValidViews())
66+
ratio = (100.0 * float(valid))/float(total)
67+
68+
chunk.logger.info(f"Total views : {total}")
69+
chunk.logger.info(f"Reconstructed views : {valid}")
70+
chunk.logger.info(f"Percentage : {ratio}")
71+
72+
if ratio < chunk.node.posecompletion.value:
73+
chunk.logger.error("Percentage of reconstructed views is insufficient")
74+
error = True
75+
76+
avsfmdataio.save(data, chunk.node.output.value, avsfmdataio.ALL)
77+
78+
chunk.logManager.end()
79+
80+
if error:
81+
raise RuntimeError()
82+

0 commit comments

Comments
 (0)