mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-07 05:12:00 +02:00
[setup] add 'setupEnvironment' for setting-up standalone configuration
* setup environment vars to work in a prebuilt, standalone configuration * call 'setupEnvironment' at the beginning of executables
This commit is contained in:
parent
c0c28b5dcf
commit
b8730324c7
6 changed files with 98 additions and 5 deletions
|
@ -1,6 +1,9 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
import meshroom
|
||||||
|
meshroom.setupEnvironment()
|
||||||
|
|
||||||
import meshroom.core.graph
|
import meshroom.core.graph
|
||||||
from meshroom.core.node import Status
|
from meshroom.core.node import Status
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
|
||||||
|
|
||||||
import meshroom.core
|
import meshroom
|
||||||
|
meshroom.setupEnvironment()
|
||||||
|
|
||||||
import meshroom.core.graph
|
import meshroom.core.graph
|
||||||
from meshroom import multiview
|
from meshroom import multiview
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Launch the full photogrammetry pipeline.')
|
parser = argparse.ArgumentParser(description='Launch the full photogrammetry pipeline.')
|
||||||
parser.add_argument('--input', metavar='FOLDER', type=str,
|
parser.add_argument('--input', metavar='FOLDER', type=str,
|
||||||
default='',
|
default='',
|
||||||
|
|
|
@ -3,6 +3,9 @@ import argparse
|
||||||
import os
|
import os
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
|
import meshroom
|
||||||
|
meshroom.setupEnvironment()
|
||||||
|
|
||||||
import meshroom.core.graph
|
import meshroom.core.graph
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Query the status of nodes in a Graph of processes.')
|
parser = argparse.ArgumentParser(description='Query the status of nodes in a Graph of processes.')
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
import meshroom
|
||||||
|
meshroom.setupEnvironment()
|
||||||
|
|
||||||
import meshroom.core.graph
|
import meshroom.core.graph
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Submit a Graph of processes on renderfarm.')
|
parser = argparse.ArgumentParser(description='Submit a Graph of processes on renderfarm.')
|
||||||
|
|
|
@ -1,14 +1,96 @@
|
||||||
__version__ = "2018.1"
|
__version__ = "2018.1"
|
||||||
|
|
||||||
|
import logging
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
class Backend(Enum):
|
class Backend(Enum):
|
||||||
STANDALONE = 1
|
STANDALONE = 1
|
||||||
PYSIDE = 2
|
PYSIDE = 2
|
||||||
|
|
||||||
|
|
||||||
backend = Backend.STANDALONE
|
backend = Backend.STANDALONE
|
||||||
|
|
||||||
|
|
||||||
def useUI():
|
def useUI():
|
||||||
global backend
|
global backend
|
||||||
backend = Backend.PYSIDE
|
backend = Backend.PYSIDE
|
||||||
|
|
||||||
|
|
||||||
|
def setupEnvironment():
|
||||||
|
"""
|
||||||
|
Setup environment for Meshroom to work in a prebuilt, standalone configuration.
|
||||||
|
|
||||||
|
Use 'MESHROOM_INSTALL_DIR' to simulate standalone configuration with a path to a Meshroom installation folder.
|
||||||
|
|
||||||
|
# Meshroom standalone structure
|
||||||
|
|
||||||
|
- Meshroom/
|
||||||
|
- aliceVision/
|
||||||
|
- bin/ # runtime bundled binaries (exe + libs)
|
||||||
|
- share/ # resource files
|
||||||
|
- COPYING.md # AliceVision COPYING file
|
||||||
|
- cameraSensors.db # sensor database
|
||||||
|
- vlfeat_K80L3.tree # voctree file
|
||||||
|
- lib/ # Python lib folder
|
||||||
|
- qtPlugins/
|
||||||
|
Meshroom # main executable
|
||||||
|
COPYING.md # Meshroom COPYING file
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def addToEnvPath(var, val, index=-1):
|
||||||
|
"""
|
||||||
|
Add paths to the given environment variable.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
var (str): the name of the variable to add paths to
|
||||||
|
val (str or list of str): the path(s) to add
|
||||||
|
index (int): insertion index
|
||||||
|
"""
|
||||||
|
paths = os.environ.get(var, "").split(os.pathsep)
|
||||||
|
|
||||||
|
if not isinstance(val, (list, tuple)):
|
||||||
|
val = [val]
|
||||||
|
|
||||||
|
paths[index:index] = val
|
||||||
|
os.environ[var] = os.pathsep.join(paths)
|
||||||
|
|
||||||
|
# detect if this is a frozen environment based on executable name
|
||||||
|
isStandalone = "python" not in os.path.basename(sys.executable).lower()
|
||||||
|
# setup root directory (override possible by setting "MESHROOM_INSTALL_DIR" environment variable)
|
||||||
|
rootDir = os.path.dirname(sys.executable) if isStandalone else os.environ.get("MESHROOM_INSTALL_DIR", None)
|
||||||
|
|
||||||
|
if rootDir:
|
||||||
|
os.environ["MESHROOM_INSTALL_DIR"] = rootDir
|
||||||
|
|
||||||
|
aliceVisionDir = os.path.join(rootDir, "aliceVision")
|
||||||
|
# default directories
|
||||||
|
aliceVisionBinDir = os.path.join(aliceVisionDir, "bin")
|
||||||
|
aliceVisionShareDir = os.path.join(aliceVisionDir, "share")
|
||||||
|
qtPluginsDir = os.path.join(rootDir, "qtPlugins")
|
||||||
|
sensorDBPath = os.path.join(aliceVisionShareDir, "cameraSensors.db")
|
||||||
|
voctreePath = os.path.join(aliceVisionShareDir, "vlfeat_K80L3.tree")
|
||||||
|
|
||||||
|
env = {
|
||||||
|
'PATH': aliceVisionBinDir,
|
||||||
|
'LD_LIBRARY_PATH': aliceVisionBinDir,
|
||||||
|
'QT_PLUGIN_PATH': [qtPluginsDir],
|
||||||
|
'QML2_IMPORT_PATH': [os.path.join(qtPluginsDir, "qml")]
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value in env.items():
|
||||||
|
logging.info("Add to {}: {}".format(key, value))
|
||||||
|
addToEnvPath(key, value, 0)
|
||||||
|
|
||||||
|
variables = {
|
||||||
|
"ALICEVISION_SENSOR_DB": sensorDBPath,
|
||||||
|
"ALICEVISION_VOCTREE": voctreePath
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value in variables.items():
|
||||||
|
if key not in os.environ and os.path.exists(value):
|
||||||
|
logging.info("Set {}: {}".format(key, value))
|
||||||
|
os.environ[key] = value
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
|
import meshroom
|
||||||
from meshroom.ui.app import MeshroomApp
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
meshroom.setupEnvironment()
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||||
|
from meshroom.ui.app import MeshroomApp
|
||||||
app = MeshroomApp(sys.argv)
|
app = MeshroomApp(sys.argv)
|
||||||
app.exec_()
|
app.exec_()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue