kopia lustrzana https://github.com/OpenDroneMap/ODM
commit
2242d1788d
|
@ -6,6 +6,7 @@ import datetime
|
|||
import dateutil.parser
|
||||
import shutil
|
||||
import multiprocessing
|
||||
from repoze.lru import lru_cache
|
||||
|
||||
from opendm.arghelpers import double_quote, args_to_dict
|
||||
from vmem import virtual_memory
|
||||
|
@ -30,6 +31,7 @@ else:
|
|||
|
||||
lock = threading.Lock()
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
def odm_version():
|
||||
with open(os.path.join(os.path.dirname(__file__), "..", "VERSION")) as f:
|
||||
return f.read().split("\n")[0].strip()
|
||||
|
|
|
@ -21,6 +21,17 @@ from opensfm.geo import ecef_from_lla
|
|||
|
||||
projections = ['perspective', 'fisheye', 'fisheye_opencv', 'brown', 'dual', 'equirectangular', 'spherical']
|
||||
|
||||
def find_mean_utc_time(photos):
|
||||
utc_times = []
|
||||
for p in photos:
|
||||
if p.utc_time is not None:
|
||||
utc_times.append(p.utc_time / 1000.0)
|
||||
if len(utc_times) == 0:
|
||||
return None
|
||||
|
||||
return np.mean(utc_times)
|
||||
|
||||
|
||||
def find_largest_photo_dims(photos):
|
||||
max_mp = 0
|
||||
max_dims = None
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import os
|
||||
import rasterio
|
||||
|
||||
from datetime import datetime
|
||||
from osgeo import gdal
|
||||
from opendm import io
|
||||
from opendm import log
|
||||
from opendm import types
|
||||
from opendm import photo
|
||||
from opendm.utils import copy_paths, get_processing_results_paths
|
||||
from opendm.ogctiles import build_3dtiles
|
||||
|
||||
|
@ -14,6 +17,25 @@ class ODMPostProcess(types.ODM_Stage):
|
|||
|
||||
log.ODM_INFO("Post Processing")
|
||||
|
||||
rasters = [tree.odm_orthophoto_tif,
|
||||
tree.path("odm_dem", "dsm.tif"),
|
||||
tree.path("odm_dem", "dtm.tif")]
|
||||
|
||||
mean_capture_time = photo.find_mean_utc_time(reconstruction.photos)
|
||||
mean_capture_dt = None
|
||||
if mean_capture_time is not None:
|
||||
mean_capture_dt = datetime.fromtimestamp(mean_capture_time).strftime('%Y:%m:%d %H:%M:%S') + '+00:00'
|
||||
|
||||
# Add TIFF tags
|
||||
for product in rasters:
|
||||
if os.path.isfile(product):
|
||||
log.ODM_INFO("Adding TIFFTAGs to {}".format(product))
|
||||
with rasterio.open(product, 'r+') as rst:
|
||||
if mean_capture_dt is not None:
|
||||
rst.update_tags(TIFFTAG_DATETIME=mean_capture_dt)
|
||||
rst.update_tags(TIFFTAG_SOFTWARE='ODM {}'.format(log.odm_version()))
|
||||
|
||||
# GCP info
|
||||
if not outputs['large']:
|
||||
# TODO: support for split-merge?
|
||||
|
||||
|
@ -28,9 +50,7 @@ class ODMPostProcess(types.ODM_Stage):
|
|||
with open(gcp_gml_export_file) as f:
|
||||
gcp_xml = f.read()
|
||||
|
||||
for product in [tree.odm_orthophoto_tif,
|
||||
tree.path("odm_dem", "dsm.tif"),
|
||||
tree.path("odm_dem", "dtm.tif")]:
|
||||
for product in rasters:
|
||||
if os.path.isfile(product):
|
||||
ds = gdal.Open(product)
|
||||
if ds is not None:
|
||||
|
@ -53,3 +73,4 @@ class ODMPostProcess(types.ODM_Stage):
|
|||
copy_paths([os.path.join(args.project_path, p) for p in get_processing_results_paths()], args.copy_to, self.rerun())
|
||||
except Exception as e:
|
||||
log.ODM_WARNING("Cannot copy to %s: %s" % (args.copy_to, str(e)))
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue