Skip to content

Commit 2528ea9

Browse files
Merge pull request #1924 from alicevision/fix/nodalPipeline
Fix nodal pipeline including scenePreview crash
2 parents 00a8015 + b0d1013 commit 2528ea9

File tree

5 files changed

+49
-16
lines changed

5 files changed

+49
-16
lines changed

meshroom/blender/scripts/preview.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,13 @@ def loadModel(filename):
222222
bpy.ops.wm.alembic_import(filepath=filename)
223223
root = bpy.data.objects['mvgRoot']
224224
root.rotation_euler.rotate_axis('X', math.radians(-90.0))
225-
return bpy.data.objects['mvgPointCloud'], bpy.data.meshes['particleShape1']
225+
226+
obj = bpy.data.objects['mvgPointCloud']
227+
228+
mesh=None
229+
if "particleShape1" in [c.name for c in bpy.data.meshes]:
230+
mesh = bpy.data.meshes['particleShape1']
231+
return obj, mesh
226232

227233

228234
def setupWireframeShading(mesh, color):
@@ -290,21 +296,27 @@ def setupPointCloudShading(obj, color, size):
290296
# Setup nodes
291297
nodeInput = geo.nodes.new(type='NodeGroupInput')
292298
nodeOutput = geo.nodes.new(type='NodeGroupOutput')
293-
nodeM2P = geo.nodes.new(type='GeometryNodeMeshToPoints')
294299
nodeIoP = geo.nodes.new(type='GeometryNodeInstanceOnPoints')
295300
nodeCube = geo.nodes.new(type='GeometryNodeMeshCube')
296301
nodeSize = geo.nodes.new(type='ShaderNodeValue')
297302
nodeSize.outputs['Value'].default_value = size
298303
nodeMat = geo.nodes.new(type='GeometryNodeSetMaterial')
299304
nodeMat.inputs[2].default_value = material
305+
306+
# Create sockets
307+
if hasattr(geo, 'interface'):
308+
geo.interface.new_socket('Geometry', in_out='INPUT', socket_type='NodeSocketGeometry')
309+
geo.interface.new_socket('Geometry', in_out='OUTPUT', socket_type='NodeSocketGeometry')
310+
else:
311+
geo.inputs.new('NodeSocketGeometry', 'Geometry')
312+
geo.outputs.new('NodeSocketGeometry', 'Geometry')
313+
300314
# Connect nodes
301-
geo.links.new(nodeInput.outputs[0], nodeM2P.inputs['Mesh'])
302-
geo.links.new(nodeM2P.outputs['Points'], nodeIoP.inputs['Points'])
315+
geo.links.new(nodeInput.outputs['Geometry'], nodeIoP.inputs['Points'])
303316
geo.links.new(nodeCube.outputs['Mesh'], nodeIoP.inputs['Instance'])
304317
geo.links.new(nodeSize.outputs['Value'], nodeIoP.inputs['Scale'])
305318
geo.links.new(nodeIoP.outputs['Instances'], nodeMat.inputs['Geometry'])
306-
geo.links.new(nodeMat.outputs[0], nodeOutput.inputs[0])
307-
319+
geo.links.new(nodeMat.outputs[0], nodeOutput.inputs['Geometry'])
308320

309321

310322
def main():

meshroom/nodalCameraTracking.mg

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"header": {
33
"releaseVersion": "2025.1.0-develop",
44
"fileVersion": "2.0",
5-
"template": true,
65
"nodesVersions": {
76
"ApplyCalibration": "1.0",
87
"CameraInit": "12.0",
@@ -15,13 +14,14 @@
1514
"FeatureMatching": "2.0",
1615
"ImageDetectionPrompt": "0.1",
1716
"ImageMatching": "2.0",
18-
"ImageSegmentationBox": "0.1",
17+
"ImageSegmentationBox": "0.2",
1918
"NodalSfM": "2.0",
2019
"Publish": "1.3",
2120
"RelativePoseEstimating": "3.0",
2221
"ScenePreview": "2.0",
2322
"TracksBuilding": "1.0"
24-
}
23+
},
24+
"template": true
2525
},
2626
"graph": {
2727
"ApplyCalibration_1": {
@@ -246,7 +246,8 @@
246246
"inputs": {
247247
"input": "{TracksBuilding_1.input}",
248248
"tracksFilename": "{TracksBuilding_1.output}",
249-
"enforcePureRotation": true
249+
"enforcePureRotation": true,
250+
"imagePairsList": "{FeatureMatching_1.imagePairsList}"
250251
},
251252
"internalInputs": {
252253
"color": "#80766f"

meshroom/nodalCameraTrackingWithoutCalibration.mg

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"header": {
33
"releaseVersion": "2025.1.0-develop",
44
"fileVersion": "2.0",
5-
"template": true,
65
"nodesVersions": {
76
"CameraInit": "12.0",
87
"ConvertDistortion": "1.0",
@@ -13,13 +12,14 @@
1312
"FeatureMatching": "2.0",
1413
"ImageDetectionPrompt": "0.1",
1514
"ImageMatching": "2.0",
16-
"ImageSegmentationBox": "0.1",
15+
"ImageSegmentationBox": "0.2",
1716
"NodalSfM": "2.0",
1817
"Publish": "1.3",
1918
"RelativePoseEstimating": "3.0",
2019
"ScenePreview": "2.0",
2120
"TracksBuilding": "1.0"
22-
}
21+
},
22+
"template": true
2323
},
2424
"graph": {
2525
"CameraInit_1": {
@@ -203,7 +203,8 @@
203203
"inputs": {
204204
"input": "{TracksBuilding_1.input}",
205205
"tracksFilename": "{TracksBuilding_1.output}",
206-
"enforcePureRotation": true
206+
"enforcePureRotation": true,
207+
"imagePairsList": "{FeatureMatching_1.imagePairsList}"
207208
},
208209
"internalInputs": {
209210
"color": "#80766f"

src/aliceVision/dataio/json.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ std::vector<boost::json::value> readJsons(std::istream& is, boost::system::error
1212
{
1313
content += line;
1414

15-
totalRead = 0;
15+
//Try to read all available items in the buffer
1616
while (true)
1717
{
18-
totalRead += p.write(content, ec);
18+
totalRead = p.write_some(content, ec);
1919

2020
// If the parser did not find a value, then it won't
2121
// find anything more.

src/aliceVision/sfmDataIO/AlembicExporter.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,25 @@ void AlembicExporter::addSurveys(const sfmData::SurveyPoints & points)
623623
{
624624
OPoints outPoints(_dataImpl->_mvgSurveys, "surveys");
625625
OPointsSchema& pSchema = outPoints.getSchema();
626+
627+
//Build positions for abc visualisation
628+
std::vector<V3f> positions;
629+
for (const auto & [viewId, vsp] : points)
630+
{
631+
for (const auto & sp : vsp)
632+
{
633+
positions.emplace_back(sp.point3d[0], -sp.point3d[1], -sp.point3d[2]);
634+
}
635+
}
636+
637+
//Fake indices
638+
std::vector<Alembic::Util::uint64_t> ids(positions.size());
639+
std::iota(begin(ids), end(ids), 0);
640+
641+
OPointsSchema::Sample psamp(std::move(V3fArraySample(positions)), std::move(UInt64ArraySample(ids)));
642+
pSchema.set(psamp);
643+
644+
//Now, store information useful for AliceVision
626645
OCompoundProperty userProps = pSchema.getUserProperties();
627646

628647
std::vector<IndexT> indices;

0 commit comments

Comments
 (0)