kopia lustrzana https://github.com/OpenDroneMap/ODM
rodzic
03d4f7ea1b
commit
f153aa9754
|
@ -235,7 +235,7 @@ class ODM_GeoRef(object):
|
|||
"""Write attributes to jobOptions from coord file"""
|
||||
# check for coordinate file existence
|
||||
if not io.file_exists(_file):
|
||||
log.ODM_ERROR('Could not find file %s' % _coords_file)
|
||||
log.ODM_ERROR('Could not find file %s' % _file)
|
||||
return
|
||||
|
||||
with open(_file) as f:
|
||||
|
@ -329,6 +329,7 @@ class ODM_Tree(object):
|
|||
|
||||
# odm_orthophoto
|
||||
self.odm_orthophoto_file = io.join_paths(self.odm_orthophoto, 'odm_orthophoto.png')
|
||||
self.odm_orthophoto_tif = io.join_paths(self.odm_orthophoto, 'odm_orthophoto.tif')
|
||||
self.odm_orthophoto_corners = io.join_paths(self.odm_orthophoto, 'odm_orthphoto_corners.txt')
|
||||
self.odm_orthophoto_log = io.join_paths(self.odm_orthophoto, 'odm_orthophoto_log.txt')
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ from opendm import io
|
|||
from opendm import log
|
||||
from opendm import system
|
||||
from opendm import context
|
||||
from opendm import types
|
||||
|
||||
|
||||
class ODMOrthoPhotoCell(ecto.Cell):
|
||||
def declare_params(self, params):
|
||||
|
@ -31,7 +33,7 @@ class ODMOrthoPhotoCell(ecto.Cell):
|
|||
|
||||
if not io.file_exists(tree.odm_orthophoto_file) or rerun_cell:
|
||||
|
||||
# odm_georeference definitions
|
||||
# odm_orthophoto definitions
|
||||
kwargs = {
|
||||
'bin': context.odm_modules_path,
|
||||
'model_geo': tree.odm_textured_model_obj_geo,
|
||||
|
@ -41,10 +43,51 @@ class ODMOrthoPhotoCell(ecto.Cell):
|
|||
'res': self.params.resolution
|
||||
}
|
||||
|
||||
# run odm_georeference
|
||||
# run odm_orthophoto
|
||||
system.run('{bin}/odm_orthophoto -inputFile {model_geo} ' \
|
||||
'-logFile {log} -outputFile {ortho} -resolution {res} ' \
|
||||
'-outputCornerFile {corners}'.format(**kwargs))
|
||||
|
||||
# Create georeferenced GeoTiff
|
||||
geoTiffCreated = False
|
||||
georef = types.ODM_GeoRef()
|
||||
# creates the coord refs # TODO I don't want to have to do this twice- after odm_georef
|
||||
georef.parse_coordinate_system(tree.odm_georeferencing_coords)
|
||||
|
||||
if (georef.epsg and georef.utm_east_offset and georef.utm_north_offset):
|
||||
ulx = uly = lrx = lry = 0.0
|
||||
with open(tree.odm_orthophoto_corners) as f:
|
||||
for lineNumber, line in enumerate(f):
|
||||
if lineNumber == 0:
|
||||
tokens = line.split(' ')
|
||||
if len(tokens) == 4:
|
||||
ulx = float(tokens[0]) + \
|
||||
float(georef.utm_east_offset)
|
||||
lry = float(tokens[1]) + \
|
||||
float(georef.utm_north_offset)
|
||||
lrx = float(tokens[2]) + \
|
||||
float(georef.utm_east_offset)
|
||||
uly = float(tokens[3]) + \
|
||||
float(georef.utm_north_offset)
|
||||
log.ODM_INFO('Creating GeoTIFF')
|
||||
|
||||
kwargs = {
|
||||
'ulx': ulx,
|
||||
'uly': uly,
|
||||
'lrx': lrx,
|
||||
'lry': lry,
|
||||
'epsg': georef.epsg,
|
||||
'png': tree.odm_orthophoto_file,
|
||||
'tiff': tree.odm_orthophoto_tif
|
||||
}
|
||||
|
||||
system.run('gdal_translate -a_ullr {ulx} {uly} {lrx} {lry} '
|
||||
'-a_srs \"EPSG:{epsg}\" {png} {tiff}'.format(**kwargs))
|
||||
geoTiffCreated = True
|
||||
if not geoTiffCreated:
|
||||
log.ODM_WARNING('No geo-referenced orthophoto created due '
|
||||
'to missing geo-referencing or corner coordinates.')
|
||||
|
||||
else:
|
||||
log.ODM_WARNING('Found a valid orthophoto in: %s' % tree.odm_orthophoto_file)
|
||||
|
||||
|
@ -69,14 +112,14 @@ def odm_orthophoto():
|
|||
+ "/odm_orthphoto_corners.txt")
|
||||
|
||||
if "csString" not in jobOptions:
|
||||
parse_coordinate_system()
|
||||
parse_coordinate_system() # Writes the coord string to the jobOptions object
|
||||
|
||||
geoTiffCreated = False
|
||||
if ("csString" in jobOptions and
|
||||
"utmEastOffset" in jobOptions and "utmNorthOffset" in jobOptions):
|
||||
ulx = uly = lrx = lry = 0.0
|
||||
with open(jobOptions["jobDir"] +
|
||||
"/odm_orthphoto_corners.txt") as f:
|
||||
"/odm_orthphoto_corners.txt") as f: # Open tree.odm_orthophoto_corners
|
||||
for lineNumber, line in enumerate(f):
|
||||
if lineNumber == 0:
|
||||
tokens = line.split(' ')
|
||||
|
|
Ładowanie…
Reference in New Issue