Multispectral split-merge, GCP names fix, bump version

pull/1579/head
Piero Toffanin 2023-01-09 14:05:38 -05:00
rodzic d55202daad
commit 8cb70002f5
7 zmienionych plików z 31 dodań i 7 usunięć

Wyświetl plik

@ -25,7 +25,7 @@ ExternalProject_Add(${_proj_name}
#--Download step--------------
DOWNLOAD_DIR ${SB_DOWNLOAD_DIR}
GIT_REPOSITORY https://github.com/OpenDroneMap/OpenSfM/
GIT_TAG 302
GIT_TAG 303
#--Update/Patch step----------
UPDATE_COMMAND git submodule update --init --recursive
#--Configure step-------------

Wyświetl plik

@ -1 +1 @@
3.0.2
3.0.3

Wyświetl plik

@ -58,7 +58,7 @@ def rectify(lasFile, debug=False, reclassify_threshold=5, min_area=750, min_poin
min_area=min_area, min_points=min_points)
except Exception as e:
raise Exception("Error rectifying ground in file %s: %s" % (lasFile, str(e)))
log.ODM_WARNING("Error rectifying ground in file %s: %s" % (lasFile, str(e)))
log.ODM_INFO('Created %s in %s' % (lasFile, datetime.now() - start))
return lasFile

Wyświetl plik

@ -216,8 +216,8 @@ def merge(input_ortho_and_ortho_cuts, output_orthophoto, orthophoto_vars={}):
left, bottom, right, top = src.bounds
xs.extend([left, right])
ys.extend([bottom, top])
if src.profile["count"] < 4:
raise ValueError("Inputs must be at least 4-band rasters")
if src.profile["count"] < 2:
raise ValueError("Inputs must be at least 2-band rasters")
dst_w, dst_s, dst_e, dst_n = min(xs), min(ys), max(xs), max(ys)
log.ODM_INFO("Output bounds: %r %r %r %r" % (dst_w, dst_s, dst_e, dst_n))

Wyświetl plik

@ -144,3 +144,13 @@ def which(program):
p=os.path.join(p,program)
if os.path.exists(p) and os.access(p,os.X_OK):
return p
def link_file(src, dst):
if os.path.isdir(dst):
dst = os.path.join(dst, os.path.basename(src))
if not os.path.isfile(dst):
if sys.platform == 'win32':
os.link(src, dst)
else:
os.symlink(os.path.relpath(os.path.abspath(src), os.path.dirname(os.path.abspath(dst))), dst)

Wyświetl plik

@ -113,7 +113,7 @@ class ODM_Reconstruction(object):
# Convert GCP file to a UTM projection since the rest of the pipeline
# does not handle other SRS well.
rejected_entries = []
utm_gcp = GCPFile(gcp.create_utm_copy(output_gcp_file, filenames=[p.filename for p in self.photos], rejected_entries=rejected_entries, include_extras=False))
utm_gcp = GCPFile(gcp.create_utm_copy(output_gcp_file, filenames=[p.filename for p in self.photos], rejected_entries=rejected_entries, include_extras=True))
if not utm_gcp.exists():
raise RuntimeError("Could not project GCP file to UTM. Please double check your GCP file for mistakes.")

Wyświetl plik

@ -20,6 +20,7 @@ from opendm import point_cloud
from opendm.utils import double_quote
from opendm.tiles.tiler import generate_dem_tiles
from opendm.cogeo import convert_to_cogeo
from opendm import multispectral
class ODMSplitStage(types.ODM_Stage):
def process(self, args, outputs):
@ -88,12 +89,12 @@ class ODMSplitStage(types.ODM_Stage):
for sp in submodel_paths:
sp_octx = OSFMContext(sp)
submodel_images_dir = os.path.abspath(sp_octx.path("..", "images"))
# Copy filtered GCP file if needed
# One in OpenSfM's directory, one in the submodel project directory
if reconstruction.gcp and reconstruction.gcp.exists():
submodel_gcp_file = os.path.abspath(sp_octx.path("..", "gcp_list.txt"))
submodel_images_dir = os.path.abspath(sp_octx.path("..", "images"))
if reconstruction.gcp.make_filtered_copy(submodel_gcp_file, submodel_images_dir):
log.ODM_INFO("Copied filtered GCP file to %s" % submodel_gcp_file)
@ -107,6 +108,19 @@ class ODMSplitStage(types.ODM_Stage):
io.copy(tree.odm_geo_file, geo_dst_path)
log.ODM_INFO("Copied GEO file to %s" % geo_dst_path)
# If this is a multispectral dataset,
# we need to link the multispectral images
if reconstruction.multi_camera:
submodel_images = os.listdir(submodel_images_dir)
primary_band_name = multispectral.get_primary_band_name(reconstruction.multi_camera, args.primary_band)
_, p2s = multispectral.compute_band_maps(reconstruction.multi_camera, primary_band_name)
for filename in p2s:
if filename in submodel_images:
secondary_band_photos = p2s[filename]
for p in secondary_band_photos:
system.link_file(os.path.join(tree.dataset_raw, p.filename), submodel_images_dir)
# Reconstruct each submodel
log.ODM_INFO("Dataset has been split into %s submodels. Reconstructing each submodel..." % len(submodel_paths))
self.update_progress(25)