Merge pull request #260 from smathermather/pdal-adds

Add PDAL to ODM for point cloud stuff
pull/261/head^2
Stephen Mather 2016-02-25 14:33:49 -05:00
commit 6c485b915b
5 zmienionych plików z 75 dodań i 11 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

@ -124,24 +124,55 @@ class ODM_GeoRef(object):
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):
@ -279,6 +310,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
@ -326,6 +358,8 @@ class ODM_Tree(object):
self.odm_georeferencing, 'odm_georeferencing_utm_log.txt')
self.odm_georeferencing_log = io.join_paths(
self.odm_georeferencing, 'odm_georeferencing_log.txt')
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')
@ -338,5 +372,4 @@ class ODM_Tree(object):

Wyświetl plik

@ -117,7 +117,7 @@ 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_textured_model_ply_geo)
geo_ref.convert_to_las(tree.odm_textured_model_ply_geo, tree.odm_georeferencing_pdal)
log.ODM_INFO('Running OMD Georeferencing Cell - Finished')
@ -266,4 +266,4 @@ def odm_georeferencing():
if args['--end-with'] != "odm_georeferencing":
odm_orthophoto()
odm_orthophoto()