Run tasks in main instead of doing nested calls

Former-commit-id: 1e8ea93092
gh-pages
Pau Gargallo 2015-08-27 16:29:54 +02:00
rodzic fb0f48e62a
commit e572570861
1 zmienionych plików z 23 dodań i 47 usunięć

70
run.py
Wyświetl plik

@ -470,9 +470,6 @@ def resize():
fileObject["height"] = int(match.group(2).strip())
print "\t (" + str(fileObject["width"]) + " x " + str(fileObject["height"]) + ")"
if args.end_with != "resize":
getKeypoints()
def getKeypoints():
"""Run vlsift to create keypoint files for each image"""
@ -509,9 +506,6 @@ def getKeypoints():
run("\"" + BIN_PATH + "/parallel\" --no-notice --halt-on-error 1 -j+0 < \"" + jobOptions["step_1_vlsift"] + "\"")
if args.end_with != "getKeypoints":
match()
def match():
"""Run matches on images"""
@ -587,9 +581,6 @@ def match():
# run("\"" + BIN_PATH + "/KeyMatchFull\" \"" + jobOptions["step_2_filelist"] + "\" \"" + jobOptions["step_2_matches"] + "\" ")
if args.end_with != "match":
bundler()
def bundler():
"""Run bundler and prepare bundle for PMVS"""
@ -659,9 +650,6 @@ def bundler():
run("\"" + BIN_PATH + "/Bundle2Vis\" pmvs/bundle.rd.out pmvs/vis.dat")
if args.end_with != "bundler":
cmvs()
def cmvs():
"""Run CMVS"""
@ -672,9 +660,6 @@ def cmvs():
run("\"" + BIN_PATH + "/cmvs\" pmvs/ " + str(args.cmvs_maxImages) + " " + str(CORES))
run("\"" + BIN_PATH + "/genOption\" pmvs/ " + str(args.pmvs_level) + " " + str(args.pmvs_csize) + " " + str(args.pmvs_threshold) + " " + str(args.pmvs_wsize) + " " + str(args.pmvs_minImageNum) + " " + str(CORES))
if args.end_with != "cmvs":
pmvs()
def pmvs():
"""Run PMVS"""
@ -686,9 +671,6 @@ def pmvs():
run("cp -Rf \"" + jobOptions["jobDir"] + "/pmvs/models\" \"" + jobOptions["jobDir"] + "-results\"")
if args.end_with != "pmvs":
odm_meshing()
def odm_meshing():
"""Run odm_meshing"""
@ -702,9 +684,6 @@ def odm_meshing():
run("\"" + BIN_PATH + "/odm_meshing\" -inputFile " + jobOptions["jobDir"] + "-results/option-0000.ply -outputFile " + jobOptions["jobDir"] + "-results/odm_mesh-0000.ply -logFile " + jobOptions["jobDir"] + "/odm_meshing/odm_meshing_log.txt -maxVertexCount " + str(args.odm_meshing_maxVertexCount) + " -octreeDepth " + str(args.odm_meshing_octreeDepth) + " -samplesPerNode " + str(args.odm_meshing_samplesPerNode) + " -solverDivide " + str(args.odm_meshing_solverDivide))
if args.end_with != "odm_meshing":
odm_texturing()
def odm_texturing():
"""Run odm_texturing"""
@ -719,9 +698,6 @@ def odm_texturing():
run("\"" + BIN_PATH + "/odm_texturing\" -bundleFile " + jobOptions["jobDir"] + "/pmvs/bundle.rd.out -imagesPath " + jobOptions["srcDir"] + "/ -imagesListPath " + jobOptions["jobDir"] + "/pmvs/list.rd.txt -inputModelPath " + jobOptions["jobDir"] + "-results/odm_mesh-0000.ply -outputFolder " + jobOptions["jobDir"] + "-results/odm_texturing/ -textureResolution " + str(args.odm_texturing_textureResolution) + " -bundleResizedTo " + str(jobOptions["resizeTo"]) + " -textureWithSize " + str(args.odm_texturing_textureWithSize) + " -logFile " + jobOptions["jobDir"] + "/odm_texturing/odm_texturing_log.txt")
if args.end_with != "odm_texturing":
odm_georeferencing()
def odm_georeferencing():
"""Run odm_georeferencing"""
@ -820,9 +796,6 @@ def odm_georeferencing():
print(" Creating geo-referenced LAS file (expecting warning)...")
run(lasCmd)
if args.end_with != "odm_georeferencing":
odm_orthophoto()
def odm_orthophoto():
"""Run odm_orthophoto"""
@ -870,31 +843,34 @@ def odm_orthophoto():
print(" Warning: No geo-referenced orthophoto created due to "
"missing geo-referencing or corner coordinates.")
tasks = [
("resize", resize),
("getKeypoints", getKeypoints),
("match", match),
("bundler", bundler),
("cmvs", cmvs),
("pmvs", pmvs),
("odm_meshing", odm_meshing),
("odm_texturing", odm_texturing),
("odm_georeferencing", odm_georeferencing),
("odm_orthophoto", odm_orthophoto),
]
if __name__ == '__main__':
prepare_objects()
os.chdir(jobOptions["jobDir"])
if args.start_with == "resize":
resize()
elif args.start_with == "getKeypoints":
getKeypoints()
elif args.start_with == "match":
match()
elif args.start_with == "bundler":
bundler()
elif args.start_with == "cmvs":
cmvs()
elif args.start_with == "pmvs":
pmvs()
elif args.start_with == "odm_meshing":
odm_meshing()
elif args.start_with == "odm_texturing":
odm_texturing()
elif args.start_with == "odm_georeferencing":
odm_georeferencing()
elif args.start_with == "odm_orthophoto":
odm_orthophoto()
run_tasks = True
for name, func in tasks:
if args.start_with == name:
run_tasks = True
if run_tasks:
func()
if args.end_with == name:
break
if args.zip_results:
print "\nCompressing results - " + now()