mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-04 03:41:56 +02:00
[bin] meshroom_photogrammetry: setup cache folder according to --save path
except if --cache is set explicitly
This commit is contained in:
parent
ee2fc63bd5
commit
979ee4ba94
2 changed files with 16 additions and 8 deletions
|
@ -38,7 +38,7 @@ parser.add_argument('--cache', metavar='FOLDER', type=str,
|
||||||
'If not set, the default cache folder will be used: ' + meshroom.core.defaultCacheFolder)
|
'If not set, the default cache folder will be used: ' + meshroom.core.defaultCacheFolder)
|
||||||
|
|
||||||
parser.add_argument('--save', metavar='FILE', type=str, required=False,
|
parser.add_argument('--save', metavar='FILE', type=str, required=False,
|
||||||
help='Save the configured Meshroom project to a file.')
|
help='Save the configured Meshroom graph to a project file. It will setup the cache folder accordingly if not explicitly changed by --cache.')
|
||||||
|
|
||||||
parser.add_argument('--compute', metavar='<yes/no>', type=lambda x: bool(distutils.util.strtobool(x)), default=True, required=False,
|
parser.add_argument('--compute', metavar='<yes/no>', type=lambda x: bool(distutils.util.strtobool(x)), default=True, required=False,
|
||||||
help='You can set it to <no/false/0> to disable the computation.')
|
help='You can set it to <no/false/0> to disable the computation.')
|
||||||
|
@ -130,13 +130,13 @@ if args.scale > 0:
|
||||||
for node in graph.nodesByType('DepthMap'):
|
for node in graph.nodesByType('DepthMap'):
|
||||||
node.downscale.value = args.scale
|
node.downscale.value = args.scale
|
||||||
|
|
||||||
if args.save:
|
|
||||||
graph.save(args.save)
|
|
||||||
print('File successfully saved:', args.save)
|
|
||||||
|
|
||||||
# setup cache directory
|
# setup cache directory
|
||||||
graph.cacheDir = args.cache if args.cache else meshroom.core.defaultCacheFolder
|
graph.cacheDir = args.cache if args.cache else meshroom.core.defaultCacheFolder
|
||||||
|
|
||||||
|
if args.save:
|
||||||
|
graph.save(args.save, fileLink=not bool(args.cache))
|
||||||
|
print('File successfully saved: "{}"'.format(args.save))
|
||||||
|
|
||||||
if not args.output:
|
if not args.output:
|
||||||
print('No output set, results will be available in the cache folder: "{}"'.format(graph.cacheDir))
|
print('No output set, results will be available in the cache folder: "{}"'.format(graph.cacheDir))
|
||||||
|
|
||||||
|
|
|
@ -905,7 +905,7 @@ class Graph(BaseObject):
|
||||||
def asString(self):
|
def asString(self):
|
||||||
return str(self.toDict())
|
return str(self.toDict())
|
||||||
|
|
||||||
def save(self, filepath=None):
|
def save(self, filepath=None, fileLink=True):
|
||||||
path = filepath or self._filepath
|
path = filepath or self._filepath
|
||||||
if not path:
|
if not path:
|
||||||
raise ValueError("filepath must be specified for unsaved files.")
|
raise ValueError("filepath must be specified for unsaved files.")
|
||||||
|
@ -929,7 +929,7 @@ class Graph(BaseObject):
|
||||||
with open(path, 'w') as jsonFile:
|
with open(path, 'w') as jsonFile:
|
||||||
json.dump(data, jsonFile, indent=4)
|
json.dump(data, jsonFile, indent=4)
|
||||||
|
|
||||||
if path != self._filepath:
|
if path != self._filepath and fileLink:
|
||||||
self._setFilepath(path)
|
self._setFilepath(path)
|
||||||
|
|
||||||
def _setFilepath(self, filepath):
|
def _setFilepath(self, filepath):
|
||||||
|
@ -939,7 +939,9 @@ class Graph(BaseObject):
|
||||||
Args:
|
Args:
|
||||||
filepath: the graph file path
|
filepath: the graph file path
|
||||||
"""
|
"""
|
||||||
assert os.path.isfile(filepath)
|
if not os.path.isfile(filepath):
|
||||||
|
self._unsetFilepath()
|
||||||
|
return
|
||||||
|
|
||||||
if self._filepath == filepath:
|
if self._filepath == filepath:
|
||||||
return
|
return
|
||||||
|
@ -951,6 +953,12 @@ class Graph(BaseObject):
|
||||||
self.cacheDir = os.path.join(os.path.abspath(os.path.dirname(filepath)), meshroom.core.cacheFolderName)
|
self.cacheDir = os.path.join(os.path.abspath(os.path.dirname(filepath)), meshroom.core.cacheFolderName)
|
||||||
self.filepathChanged.emit()
|
self.filepathChanged.emit()
|
||||||
|
|
||||||
|
def _unsetFilepath(self):
|
||||||
|
self._filepath = ""
|
||||||
|
self.name = ""
|
||||||
|
self.cacheDir = meshroom.core.defaultCacheFolder
|
||||||
|
self.filepathChanged.emit()
|
||||||
|
|
||||||
def updateInternals(self, startNodes=None, force=False):
|
def updateInternals(self, startNodes=None, force=False):
|
||||||
nodes, edges = self.dfsOnFinish(startNodes=startNodes)
|
nodes, edges = self.dfsOnFinish(startNodes=startNodes)
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue