From fed4cb95dc2ead79430ea071805e30a9197bdbd9 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Tue, 20 Jun 2017 14:53:17 -0400 Subject: [PATCH] Added lidar2dems superbuild module, modified dockerfile, configure.sh to install lidar2dems deps --- .gitmodules | 3 -- Dockerfile | 8 +----- SuperBuild/CMakeLists.txt | 1 + SuperBuild/cmake/External-Lidar2dems.cmake | 25 ++++++++++++++++ configure.sh | 13 ++------- modules/lidar2dems | 1 - opendm/types.py | 33 ++-------------------- scripts/odm_georeferencing.py | 1 - 8 files changed, 31 insertions(+), 54 deletions(-) create mode 100644 SuperBuild/cmake/External-Lidar2dems.cmake delete mode 160000 modules/lidar2dems diff --git a/.gitmodules b/.gitmodules index 3a5f4fa0..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "modules/lidar2dems"] - path = modules/lidar2dems - url = https://github.com/pierotofy/lidar2dems diff --git a/Dockerfile b/Dockerfile index 1ea62125..038363e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ jhead liblas-bin python-matplotlib libatlas-base-dev libgmp-dev libmpfr-dev swig RUN apt-get remove libdc1394-22-dev RUN pip install --upgrade pip RUN pip install setuptools -RUN pip install -U PyYAML exifread gpxpy xmltodict catkin-pkg appsettings https://github.com/Applied-GeoSolutions/gippy/archive/v0.3.9.tar.gz +RUN pip install -U PyYAML exifread gpxpy xmltodict catkin-pkg appsettings https://github.com/pierotofy/gippy/archive/v0.3.9.tar.gz ENV PYTHONPATH="$PYTHONPATH:/code/SuperBuild/install/lib/python2.7/dist-packages" ENV PYTHONPATH="$PYTHONPATH:/code/SuperBuild/src/opensfm" @@ -49,12 +49,6 @@ COPY VERSION /code/VERSION RUN cd SuperBuild && mkdir build && cd build && cmake .. && make -j$(nproc) && cd ../.. && mkdir build && cd build && cmake .. && make -j$(nproc) -# Update and initialize git submodules -RUN git submodule update --init - -# Setup lidar2dems -RUN CPLUS_INCLUDE_PATH=/usr/include/gdal C_INCLUDE_PATH=/usr/include/gdal /code/modules/lidar2dems/setup.py install && ln -s /code/SuperBuild/build/pdal/bin/pdal /usr/bin/pdal - RUN apt-get -y remove libgl1-mesa-dri git cmake python-pip build-essential RUN apt-get install -y libvtk5-dev diff --git a/SuperBuild/CMakeLists.txt b/SuperBuild/CMakeLists.txt index f6b61d75..b6892d06 100644 --- a/SuperBuild/CMakeLists.txt +++ b/SuperBuild/CMakeLists.txt @@ -114,6 +114,7 @@ set(custom_libs OpenGV Ecto PDAL MvsTexturing + Lidar2dems ) # Dependencies of the SLAM module diff --git a/SuperBuild/cmake/External-Lidar2dems.cmake b/SuperBuild/cmake/External-Lidar2dems.cmake new file mode 100644 index 00000000..14d30e99 --- /dev/null +++ b/SuperBuild/cmake/External-Lidar2dems.cmake @@ -0,0 +1,25 @@ +set(_proj_name lidar2dems) +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}/${_proj_name} + URL https://github.com/pierotofy/lidar2dems/archive/master.zip + URL_MD5 6cfe2d081cda1680e6e98a9925651b03 + #--Update/Patch step---------- + UPDATE_COMMAND "" + #--Configure step------------- + SOURCE_DIR ${SB_SOURCE_DIR}/${_proj_name} + CONFIGURE_COMMAND "" + #--Build step----------------- + BUILD_COMMAND "" + #--Install step--------------- + INSTALL_COMMAND "${SB_SOURCE_DIR}/${_proj_name}/install.sh" + #--Output logging------------- + LOG_DOWNLOAD OFF + LOG_CONFIGURE OFF + LOG_BUILD OFF +) diff --git a/configure.sh b/configure.sh index 199fb378..658c046a 100755 --- a/configure.sh +++ b/configure.sh @@ -72,7 +72,7 @@ install() { appsettings echo "Installing CGAL dependencies" - sudo apt-get install libgmp-dev libmpfr-dev + sudo apt-get install -y -qq libgmp-dev libmpfr-dev echo "Installing Ecto Dependencies" sudo pip install -U catkin-pkg @@ -92,17 +92,8 @@ install() { libboost-log-dev \ libxslt-dev - echo "Updating and initializing git submodules" - git submodule update --init + sudo pip install -U https://github.com/pierotofy/gippy/archive/v0.3.9.tar.gz - echo "Installing lidar2dems" - cd ${RUNPATH}/modules/lidar2dems - CPLUS_INCLUDE_PATH=/usr/include/gdal C_INCLUDE_PATH=/usr/include/gdal ./setup.py install - - if [ ! -f /usr/bin/pdal ]; then - ln -s ${RUNPATH}/SuperBuild/build/pdal/bin/pdal /usr/bin/pdal - fi - echo "Compiling SuperBuild" cd ${RUNPATH}/SuperBuild mkdir -p build && cd build diff --git a/modules/lidar2dems b/modules/lidar2dems deleted file mode 160000 index fe0710bd..00000000 --- a/modules/lidar2dems +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fe0710bd68e6add3be5621e94f20f56c1e99fd00 diff --git a/opendm/types.py b/opendm/types.py index 8c0dfd57..27751d60 100644 --- a/opendm/types.py +++ b/opendm/types.py @@ -196,7 +196,7 @@ class ODM_GeoRef(object): system.run('{bin}/pdal pipeline -i {json} --readers.ply.filename={f_in} ' '--writers.las.filename={f_out}'.format(**kwargs)) - def convert_to_dem(self, _file, _file_out, pdalJSON, sample_radius, gdal_res, gdal_radius): + def convert_to_dem(self, _file, _file_out, sample_radius, gdal_res, gdal_radius): # Check if exists f_in if not io.file_exists(_file): log.ODM_ERROR('LAS file does not exist') @@ -208,36 +208,9 @@ class ODM_GeoRef(object): 'sample_radius': sample_radius, 'gdal_res': gdal_res, 'gdal_radius': gdal_radius, - 'f_out': _file_out, - 'json': pdalJSON + 'f_out': _file_out } - pipelineJSON = '{{' \ - ' "pipeline":[' \ - ' "input.las",' \ - ' {{' \ - ' "type":"filters.sample",' \ - ' "radius":"{sample_radius}"' \ - ' }},' \ - ' {{' \ - ' "type":"filters.pmf"' \ - ' }},' \ - ' {{' \ - ' "type":"filters.range",' \ - ' "limits":"Classification[2:2]"' \ - ' }},' \ - ' {{' \ - ' "resolution": {gdal_res},' \ - ' "radius": {gdal_radius},' \ - ' "output_type":"idw",' \ - ' "filename":"outputfile.tif"' \ - ' }}' \ - ' ]' \ - '}}'.format(**kwargs) - - with open(pdalJSON, 'w') as f: - f.write(pipelineJSON) - system.run('{bin}/pdal pipeline {json} --readers.las.filename={f_in} ' '--writers.gdal.filename={f_out}'.format(**kwargs)) @@ -454,8 +427,6 @@ class ODM_Tree(object): self.odm_georeferencing, 'odm_georeferenced_model.las') self.odm_georeferencing_dem = io.join_paths( self.odm_georeferencing, 'odm_georeferencing_model_dem.tif') - self.odm_georeferencing_dem_json = io.join_paths( - self.odm_georeferencing, 'dem.json') # odm_orthophoto self.odm_orthophoto_file = io.join_paths(self.odm_orthophoto, 'odm_orthophoto.png') diff --git a/scripts/odm_georeferencing.py b/scripts/odm_georeferencing.py index acecedba..b5d03cc4 100644 --- a/scripts/odm_georeferencing.py +++ b/scripts/odm_georeferencing.py @@ -179,7 +179,6 @@ class ODMGeoreferencingCell(ecto.Cell): if args.dem: demcreated = geo_ref.convert_to_dem(tree.odm_georeferencing_model_las, tree.odm_georeferencing_dem, - tree.odm_georeferencing_dem_json, self.params.sample_radius, self.params.gdal_res, self.params.gdal_radius)