diff --git a/SuperBuild/CMakeLists.txt b/SuperBuild/CMakeLists.txt index 152916e2..97636956 100644 --- a/SuperBuild/CMakeLists.txt +++ b/SuperBuild/CMakeLists.txt @@ -102,7 +102,8 @@ set(custom_libs OpenGV CMVS Catkin Ecto - LAStools) + LAStools + PDAL) foreach(lib ${custom_libs}) SETUP_EXTERNAL_PROJECT_CUSTOM(${lib}) diff --git a/SuperBuild/cmake/External-PDAL.cmake b/SuperBuild/cmake/External-PDAL.cmake new file mode 100644 index 00000000..908915b1 --- /dev/null +++ b/SuperBuild/cmake/External-PDAL.cmake @@ -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 +) diff --git a/opendm/context.py b/opendm/context.py index 60485766..b10a965f 100644 --- a/opendm/context.py +++ b/opendm/context.py @@ -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") diff --git a/opendm/types.py b/opendm/types.py index d698b38b..a71f766d 100644 --- a/opendm/types.py +++ b/opendm/types.py @@ -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 = '' + pipelineXml += '' + pipelineXml += ' ' + pipelineXml += ' ' + pipelineXml += ' ' + pipelineXml += ' ' + pipelineXml += ' ' + pipelineXml += ' ' + pipelineXml += ' ' + pipelineXml += ' ' + pipelineXml += ' ' + pipelineXml += '' + + 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): - diff --git a/scripts/odm_georeferencing.py b/scripts/odm_georeferencing.py index 9a1f2009..1fafbcc2 100644 --- a/scripts/odm_georeferencing.py +++ b/scripts/odm_georeferencing.py @@ -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() \ No newline at end of file + odm_orthophoto()