Merge georeferencing conflicts

pull/261/head
Dakota Benjamin 2016-02-25 15:02:48 -05:00
commit 050ba88d81
5 zmienionych plików z 88 dodań i 28 usunięć

Wyświetl plik

@ -102,7 +102,8 @@ set(custom_libs OpenGV
CMVS
Catkin
Ecto
LAStools)
LAStools
PDAL)
foreach(lib ${custom_libs})
SETUP_EXTERNAL_PROJECT_CUSTOM(${lib})

Wyświetl plik

@ -0,0 +1,29 @@
set(_proj_name pdal)
set(_SB_BINARY_DIR "${SB_BINARY_DIR}/${_proj_name}")
ExternalProject_Add(${_proj_name}
PREFIX ${_SB_BINARY_DIR}
TMP_DIR ${_SB_BINARY_DIR}/tmp
STAMP_DIR ${_SB_BINARY_DIR}/stamp
#--Download step--------------
DOWNLOAD_DIR ${SB_DOWNLOAD_DIR}
URL https://github.com/PDAL/PDAL/archive/d242c6704aafe85fd49fda11adae63d07ce11b76.zip
URL_MD5 14a7319e1f8483808eb93732cfa6511a
#--Update/Patch step----------
UPDATE_COMMAND ""
#--Configure step-------------
SOURCE_DIR ${SB_SOURCE_DIR}/${_proj_name}
CMAKE_ARGS
-BUILD_PGPOINTCLOUD_TESTS=ON
-BUILD_PLUGIN_PCL=ON
-BUILD_PLUGIN_PGPOINTCLOUD=ON
-DCMAKE_INSTALL_PREFIX:PATH=${SB_INSTALL_DIR}
#--Build step-----------------
BINARY_DIR ${_SB_BINARY_DIR}
#--Install step---------------
INSTALL_DIR ${SB_INSTALL_DIR}
#--Output logging-------------
LOG_DOWNLOAD OFF
LOG_CONFIGURE OFF
LOG_BUILD OFF
)

Wyświetl plik

@ -25,6 +25,7 @@ pmvs2_path = os.path.join(superbuild_path, "install/bin/pmvs2")
# define txt2las path
txt2las_path = os.path.join(superbuild_path, 'src/las-tools/bin')
pdal_path = os.path.join(superbuild_path, 'build/pdal/bin')
# define odm modules path
odm_modules_path = os.path.join(root_path, "build/bin")

Wyświetl plik

@ -123,25 +123,54 @@ class ODM_GeoRef(object):
log.ODM_ERROR('Unknown pole format %s' % _pole)
return
def convert_to_las(self, _file):
def convert_to_las(self, _file, pdalXML):
if not self.epsg:
log.ODM_ERROR('Empty EPSG: Could not convert to LAS')
return
kwargs = { 'bin': context.txt2las_path,
kwargs = { 'bin': context.pdal_path,
'f_in': _file,
'f_out': _file + '.laz',
'f_out': _file + '.las',
'east': self.utm_east_offset,
'north': self.utm_north_offset,
'epsg': self.epsg }
'epsg': self.epsg,
'xml': pdalXML}
# call txt2las
system.run('{bin}/txt2las -i {f_in} -o {f_out} -skip 30 -parse xyzRGBssss ' \
'-set_scale 0.01 0.01 0.01 -set_offset {east} {north} 0 ' \
'-translate_xyz 0 -epsg {epsg}'.format(**kwargs))
# system.run('{bin}/txt2las -i {f_in} -o {f_out} -skip 30 -parse xyzRGBssss ' \
# '-set_scale 0.01 0.01 0.01 -set_offset {east} {north} 0 ' \
# '-translate_xyz 0 -epsg {epsg}'.format(**kwargs))
#
# create pipeline file transform.xml to enable transformation
pipelineXml = '<?xml version=\"1.0\" encoding=\"utf-8\"?>'
pipelineXml += '<Pipeline version=\"1.0\">'
pipelineXml += ' <Writer type=\"writers.las\">'
pipelineXml += ' <Option name=\"filename\">'
pipelineXml += ' transformed.las'
pipelineXml += ' </Option>'
pipelineXml += ' <Filter type=\"filters.transformation\">'
pipelineXml += ' <Option name=\"matrix\">'
pipelineXml += ' 1 0 0 {east}'.format(**kwargs)
pipelineXml += ' 0 1 0 {north}'.format(**kwargs)
pipelineXml += ' 0 0 1 0'
pipelineXml += ' 0 0 0 1'
pipelineXml += ' </Option>'
pipelineXml += ' <Reader type=\"readers.ply\">'
pipelineXml += ' <Option name=\"filename\">'
pipelineXml += ' untransformed.ply'
pipelineXml += ' </Option>'
pipelineXml += ' </Reader>'
pipelineXml += ' </Filter>'
pipelineXml += ' </Writer>'
pipelineXml += '</Pipeline>'
with open(pdalXML, 'w') as f:
f.write(pipelineXml)
# call pdal
system.run('{bin}/pdal pipeline -i {xml} --readers.ply.filename={f_in} '
'--writers.las.filename={f_out}'.format(**kwargs))
def utm_to_latlon(self, _file, _photo, idx):
@ -154,8 +183,8 @@ class ODM_GeoRef(object):
'y': gcp.y + self.utm_north_offset,
'z': gcp.z }
latlon = system.run_and_return('echo {x} {y} | cs2cs +proj=utm ' \
'+datum={datum} +ellps={datum} +zone={zone} +units=m +to ' \
latlon = system.run_and_return('echo {x} {y} | cs2cs +proj=utm '
'+datum={datum} +ellps={datum} +zone={zone} +units=m +to '
'+proj=latlon +ellps={datum}'.format(**kwargs)).split()
# Example: 83d18'16.285"W
@ -261,6 +290,7 @@ class ODM_GeoRef(object):
# update EPSG
self.epsg = self.calculate_EPSG(self.utm_zone, self.utm_pole)
class ODM_Tree(object):
def __init__(self, root_path):
### root path to the project
@ -279,6 +309,7 @@ class ODM_Tree(object):
self.odm_texturing = io.join_paths(self.root_path, 'odm_texturing')
self.odm_georeferencing = io.join_paths(self.root_path, 'odm_georeferencing')
self.odm_orthophoto = io.join_paths(self.root_path, 'odm_orthophoto')
self.odm_pdal = io.join_paths(self.root_path, 'pdal')
### important files paths
@ -327,8 +358,9 @@ class ODM_Tree(object):
self.odm_georeferencing_model_mtl_geo = io.join_paths(
self.odm_georeferencing, 'odm_textured_model_geo.mtl')
self.odm_georeferencing_xyz_file = io.join_paths(
self.odm_georeferencing, 'odm_georeferenced_model.csv'
)
self.odm_georeferencing, 'odm_georeferenced_model.csv')
self.odm_georeferencing_pdal = io.join_paths(
self.odm_georeferencing, 'pipeline.xml')
# odm_orthophoto
self.odm_orthophoto_file = io.join_paths(self.odm_orthophoto, 'odm_orthophoto.png')
@ -337,9 +369,3 @@ class ODM_Tree(object):
self.odm_orthophoto_log = io.join_paths(self.odm_orthophoto, 'odm_orthophoto_log.txt')
self.odm_orthophoto_tif_log = io.join_paths(self.odm_orthophoto, 'gdal_translate_log.txt')

Wyświetl plik

@ -7,6 +7,7 @@ from opendm import types
from opendm import system
from opendm import context
class ODMGeoreferencingCell(ecto.Cell):
def declare_params(self, params):
params.declare("gcp_file", 'path to the file containing the ground control '
@ -39,8 +40,9 @@ class ODMGeoreferencingCell(ecto.Cell):
if not self.params.use_gcp and \
not io.file_exists(tree.odm_georeferencing_coords):
log.ODM_WARNING('Warning: No coordinates file. ' \
'Generating coordinates file in: %s' % tree.odm_georeferencing_coords)
log.ODM_WARNING('Warning: No coordinates file. '
'Generating coordinates file in: %s'
% tree.odm_georeferencing_coords)
try:
# odm_georeference definitions
kwargs = {
@ -52,14 +54,14 @@ class ODMGeoreferencingCell(ecto.Cell):
}
# run UTM extraction binary
system.run('{bin}/odm_extract_utm -imagesPath {imgs}/ ' \
'-imageListFile {imgs_list} -outputCoordFile {coords} ' \
'-logFile {log}'.format(**kwargs))
system.run('{bin}/odm_extract_utm -imagesPath {imgs}/ '
'-imageListFile {imgs_list} -outputCoordFile {coords} '
'-logFile {log}'.format(**kwargs))
except Exception, e:
log.ODM_ERROR('Could not generate GCP file from images metadata.' \
'Consider rerunning with argument --odm_georeferencing-useGcp' \
' and provide a proper GCP file')
log.ODM_ERROR('Could not generate GCP file from images metadata.'
'Consider rerunning with argument --odm_georeferencing-useGcp'
' and provide a proper GCP file')
log.ODM_ERROR(e)
return ecto.QUIT
@ -113,7 +115,8 @@ class ODMGeoreferencingCell(ecto.Cell):
geo_ref.utm_to_latlon(tree.odm_georeferencing_latlon, photo, idx)
# convert ply model to LAS reference system
geo_ref.convert_to_las(tree.odm_georeferencing_model_ply_geo)
geo_ref.convert_to_las(tree.odm_georeferencing_model_ply_geo,
tree.odm_georeferencing_pdal)
# XYZ point cloud output
log.ODM_INFO("Creating geo-referenced CSV file (XYZ format, can be used with GRASS to create DEM)")