kopia lustrzana https://github.com/OpenDroneMap/ODM
Merge pull request #1550 from pierotofy/memmvs
OpenMVS stability improvements, GCP warning checkspull/1553/head
commit
85396167d6
|
@ -25,7 +25,7 @@ ExternalProject_Add(${_proj_name}
|
|||
#--Download step--------------
|
||||
DOWNLOAD_DIR ${SB_DOWNLOAD_DIR}
|
||||
GIT_REPOSITORY https://github.com/OpenDroneMap/OpenSfM/
|
||||
GIT_TAG 291
|
||||
GIT_TAG 292
|
||||
#--Update/Patch step----------
|
||||
UPDATE_COMMAND git submodule update --init --recursive
|
||||
#--Configure step-------------
|
||||
|
|
|
@ -29,7 +29,7 @@ class GCPFile:
|
|||
if line != "" and line[0] != "#":
|
||||
parts = line.split()
|
||||
if len(parts) >= 6:
|
||||
self.entries.append(line)
|
||||
self.entries.append(line)
|
||||
else:
|
||||
log.ODM_WARNING("Malformed GCP line: %s" % line)
|
||||
|
||||
|
@ -37,6 +37,35 @@ class GCPFile:
|
|||
for entry in self.entries:
|
||||
yield self.parse_entry(entry)
|
||||
|
||||
def check_entries(self):
|
||||
coords = {}
|
||||
gcps = {}
|
||||
errors = 0
|
||||
|
||||
for entry in self.iter_entries():
|
||||
k = entry.coords_key()
|
||||
coords[k] = coords.get(k, 0) + 1
|
||||
if k not in gcps:
|
||||
gcps[k] = []
|
||||
gcps[k].append(entry)
|
||||
|
||||
for k in coords:
|
||||
if coords[k] < 3:
|
||||
description = "insufficient" if coords[k] < 2 else "not ideal"
|
||||
for entry in gcps[k]:
|
||||
log.ODM_WARNING(str(entry))
|
||||
log.ODM_WARNING("The number of images where the GCP %s has been tagged are %s" % (k, description))
|
||||
log.ODM_WARNING("You should tag at least %s more images" % (3 - coords[k]))
|
||||
log.ODM_WARNING("=====================================")
|
||||
errors += 1
|
||||
if len(coords) < 3:
|
||||
log.ODM_WARNING("Low number of GCPs detected (%s). For best results use at least 5." % (3 - len(coords)))
|
||||
log.ODM_WARNING("=====================================")
|
||||
errors += 1
|
||||
|
||||
if errors > 0:
|
||||
log.ODM_WARNING("Some issues detected with GCPs (but we're going to process this anyway)")
|
||||
|
||||
def parse_entry(self, entry):
|
||||
if entry:
|
||||
parts = entry.split()
|
||||
|
@ -204,6 +233,9 @@ class GCPEntry:
|
|||
self.py = py
|
||||
self.filename = filename
|
||||
self.extras = extras
|
||||
|
||||
def coords_key(self):
|
||||
return "{} {} {}".format(self.x, self.y, self.z)
|
||||
|
||||
def __str__(self):
|
||||
return "{} {} {} {} {} {} {}".format(self.x, self.y, self.z,
|
||||
|
|
|
@ -107,6 +107,8 @@ class ODM_Reconstruction(object):
|
|||
if gcp.exists():
|
||||
if gcp.entries_count() == 0:
|
||||
raise RuntimeError("This GCP file does not have any entries. Are the entries entered in the proper format?")
|
||||
|
||||
gcp.check_entries()
|
||||
|
||||
# Convert GCP file to a UTM projection since the rest of the pipeline
|
||||
# does not handle other SRS well.
|
||||
|
|
|
@ -103,7 +103,6 @@ class ODMOpenMVSStage(types.ODM_Stage):
|
|||
system.run('"%s" "%s" %s' % (context.omvs_densify_path,
|
||||
openmvs_scene_file,
|
||||
' '.join(config + gpu_config + extra_config)))
|
||||
|
||||
try:
|
||||
run_densify()
|
||||
except system.SubprocessException as e:
|
||||
|
@ -113,6 +112,11 @@ class ODMOpenMVSStage(types.ODM_Stage):
|
|||
log.ODM_WARNING("OpenMVS failed with GPU, is your graphics card driver up to date? Falling back to CPU.")
|
||||
gpu_config = ["--cuda-device -2"]
|
||||
run_densify()
|
||||
elif (e.errorCode == 137 or e.errorCode == 3221226505) and not args.pc_tile:
|
||||
log.ODM_WARNING("OpenMVS ran out of memory, we're going to turn on tiling to see if we can process this.")
|
||||
args.pc_tile = True
|
||||
config.append("--fusion-mode 1")
|
||||
run_densify()
|
||||
else:
|
||||
raise e
|
||||
|
||||
|
@ -198,6 +202,12 @@ class ODMOpenMVSStage(types.ODM_Stage):
|
|||
# Merge
|
||||
fast_merge_ply(scene_ply_files, tree.openmvs_model)
|
||||
else:
|
||||
def skip_filtering():
|
||||
# Just rename
|
||||
scene_dense_ply = os.path.join(tree.openmvs, 'scene_dense.ply')
|
||||
log.ODM_INFO("Skipped filtering, %s --> %s" % (scene_dense_ply, tree.openmvs_model))
|
||||
os.rename(scene_dense_ply, tree.openmvs_model)
|
||||
|
||||
# Filter all at once
|
||||
if args.pc_filter > 0:
|
||||
if os.path.exists(scene_dense):
|
||||
|
@ -206,14 +216,18 @@ class ODMOpenMVSStage(types.ODM_Stage):
|
|||
'-i "%s"' % scene_dense,
|
||||
"-v 0"
|
||||
]
|
||||
system.run('"%s" %s' % (context.omvs_densify_path, ' '.join(config + gpu_config + extra_config)))
|
||||
try:
|
||||
system.run('"%s" %s' % (context.omvs_densify_path, ' '.join(config + gpu_config + extra_config)))
|
||||
except system.SubprocessException as e:
|
||||
if e.errorCode == 137 or e.errorCode == 3221226505:
|
||||
log.ODM_WARNING("OpenMVS filtering ran out of memory, visibility checks will be skipped.")
|
||||
skip_filtering()
|
||||
else:
|
||||
raise e
|
||||
else:
|
||||
raise system.ExitException("Cannot find scene_dense.mvs, dense reconstruction probably failed. Exiting...")
|
||||
else:
|
||||
# Just rename
|
||||
scene_dense_ply = os.path.join(tree.openmvs, 'scene_dense.ply')
|
||||
log.ODM_INFO("Skipped filtering, %s --> %s" % (scene_dense_ply, tree.openmvs_model))
|
||||
os.rename(scene_dense_ply, tree.openmvs_model)
|
||||
skip_filtering()
|
||||
|
||||
self.update_progress(95)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue