move photogrammetryPipeline to new multiview module

This commit is contained in:
Yann Lanthony 2017-10-16 18:05:38 +02:00
parent ce6925117a
commit 84945c52bb
2 changed files with 40 additions and 34 deletions

View file

@ -1,42 +1,11 @@
#!/usr/bin/env python
import argparse
import os
import meshroom.core
from meshroom import multiview
from meshroom.core import graph as pg
def photogrammetryPipeline(imageDirectory):
graph = pg.Graph('pipeline')
cameraInit = graph.addNewNode('CameraInit',
sensorDatabase=os.environ.get('ALICEVISION_SENSOR_DB', 'sensor_width_camera_database.txt'))
if imageDirectory:
cameraInit.imageDirectory.value = imageDirectory
featureExtraction = graph.addNewNode('FeatureExtraction',
input=cameraInit.outputSfm)
# TODO: imageMatching
featureMatching = graph.addNewNode('FeatureMatching',
input=cameraInit.outputSfm,
featuresDirectory=featureExtraction.output)
structureFromMotion = graph.addNewNode('StructureFromMotion',
input=cameraInit.outputSfm,
featuresDirectory=featureExtraction.output,
matchesDirectory=featureMatching.output)
prepareDenseScene = graph.addNewNode('PrepareDenseScene',
input=structureFromMotion.output)
camPairs = graph.addNewNode('CamPairs',
mvsConfig=prepareDenseScene.mvsConfig)
depthMap = graph.addNewNode('DepthMap',
mvsConfig=camPairs.mvsConfig)
depthMapFilter = graph.addNewNode('DepthMapFilter',
mvsConfig=depthMap.mvsConfig)
meshing = graph.addNewNode('Meshing',
mvsConfig=depthMapFilter.mvsConfig)
texturing = graph.addNewNode('Texturing',
mvsConfig=meshing.mvsConfig)
return graph
parser = argparse.ArgumentParser(description='Launch the full photogrammetry pipeline.')
parser.add_argument('--input', metavar='FOLDER', type=str, required=True,
help='Input folder or json file.')
@ -57,7 +26,10 @@ if not args.output and not args.save:
print('Nothing to do. You need to set --output or --save.')
exit(1)
graph = photogrammetryPipeline(imageDirectory=args.input)
graph = multiview.photogrammetryPipeline()
if args.input:
cameraInit = graph.findNodeCandidates("CameraInit")
cameraInit.imageDirectory.value = args.input
if args.save:
graph.save(args.save)
@ -70,4 +42,3 @@ if args.output:
toNodes = graph.findNodes(args.toNode)
pg.execute(graph, toNodes=toNodes)

35
meshroom/multiview.py Normal file
View file

@ -0,0 +1,35 @@
import os
from .core.graph import Graph
def photogrammetryPipeline():
# type: () -> Graph
graph = Graph('pipeline')
cameraInit = graph.addNewNode('CameraInit',
sensorDatabase=os.environ.get('ALICEVISION_SENSOR_DB', 'sensor_width_camera_database.txt'))
featureExtraction = graph.addNewNode('FeatureExtraction',
input=cameraInit.outputSfm)
# TODO: imageMatching
featureMatching = graph.addNewNode('FeatureMatching',
input=cameraInit.outputSfm,
featuresDirectory=featureExtraction.output)
structureFromMotion = graph.addNewNode('StructureFromMotion',
input=cameraInit.outputSfm,
featuresDirectory=featureExtraction.output,
matchesDirectory=featureMatching.output)
prepareDenseScene = graph.addNewNode('PrepareDenseScene',
input=structureFromMotion.output)
camPairs = graph.addNewNode('CamPairs',
mvsConfig=prepareDenseScene.mvsConfig)
depthMap = graph.addNewNode('DepthMap',
mvsConfig=camPairs.mvsConfig)
depthMapFilter = graph.addNewNode('DepthMapFilter',
mvsConfig=depthMap.mvsConfig)
meshing = graph.addNewNode('Meshing',
mvsConfig=depthMapFilter.mvsConfig)
texturing = graph.addNewNode('Texturing',
mvsConfig=meshing.mvsConfig)
return graph