From 1bdc4783298ca8389308a752543f0d576731cae0 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Wed, 17 Oct 2018 13:14:03 -0400 Subject: [PATCH] Cleanup, logger output setup --- modules/odm_dem2mesh/CMakeLists.txt.user | 4 ++-- modules/odm_dem2mesh/src/Logger.h | 2 +- modules/odm_dem2mesh/src/main.cpp | 11 ++++++++--- opendm/mesh.py | 4 ++-- scripts/odm_meshing.py | 4 ++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/modules/odm_dem2mesh/CMakeLists.txt.user b/modules/odm_dem2mesh/CMakeLists.txt.user index 91466fb2..700a5abd 100644 --- a/modules/odm_dem2mesh/CMakeLists.txt.user +++ b/modules/odm_dem2mesh/CMakeLists.txt.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -452,7 +452,7 @@ 13 14 - -inputFile /data/drone/cmparks/mesh_dsm_12.tif -outputFile /data/drone/cmparks/mesh_dsm.ply -verbose + -inputFile /data/drone/cmparks/mesh_dsm.tif -outputFile /data/drone/cmparks/mesh_dsm.ply -verbose /data/OpenDroneMap/modules/build-odm_dem2mesh-Desktop-Default 2 diff --git a/modules/odm_dem2mesh/src/Logger.h b/modules/odm_dem2mesh/src/Logger.h index 6e3a6e08..246d6519 100644 --- a/modules/odm_dem2mesh/src/Logger.h +++ b/modules/odm_dem2mesh/src/Logger.h @@ -26,7 +26,7 @@ struct Logger{ { va_list args; va_start( args , format ); - vfprintf( stderr, format , args ); + vfprintf( stdout, format , args ); va_end( args ); } } diff --git a/modules/odm_dem2mesh/src/main.cpp b/modules/odm_dem2mesh/src/main.cpp index 206aa68e..9df9e222 100644 --- a/modules/odm_dem2mesh/src/main.cpp +++ b/modules/odm_dem2mesh/src/main.cpp @@ -273,8 +273,8 @@ void transform(const BoundingBox &extent){ double ext_height = extent.max.y - extent.min.y; for(Simplify::Vertex &v : Simplify::vertices){ - v.p.x = extent.min.x + (static_cast(v.p.x) / static_cast(arr_width)) * ext_width; - v.p.y = extent.max.y - (static_cast(v.p.y) / static_cast(arr_height)) * ext_height;; + v.p.x = extent.min.x + (static_cast(v.p.x) / static_cast(arr_width)) * ext_width; + v.p.y = extent.max.y - (static_cast(v.p.y) / static_cast(arr_height)) * ext_height;; } } @@ -284,6 +284,7 @@ int main(int argc, char **argv) { if ( !MaxVertexCount.set ) MaxVertexCount.value = 100000; logWriter.verbose = Verbose.set; + logWriter.outputFile = "odm_dem2mesh.txt"; logArgs(params, logWriter); GDALDataset *dataset; @@ -307,7 +308,7 @@ int main(int argc, char **argv) { GDALRasterBand *band = dataset->GetRasterBand(1); - int qtreeLevels = 2; + int qtreeLevels = 1; subdivisions = (int)pow(2, qtreeLevels); int numBlocks = subdivisions * subdivisions; blockSizeX = arr_width / subdivisions; @@ -427,6 +428,10 @@ int main(int argc, char **argv) { ss << OutputFile.value << "." << blockX << "-" << blockY << ".bin"; logWriter("Reading %s\n", ss.str().c_str()); readBin(ss.str(), blockX, blockY); + + if (std::remove(ss.str().c_str()) != 0){ + logWriter("Error while deleting intermediate file: %s\n", ss.str().c_str()); + } } } diff --git a/opendm/mesh.py b/opendm/mesh.py index 97452f5d..1b9617f9 100644 --- a/opendm/mesh.py +++ b/opendm/mesh.py @@ -38,8 +38,8 @@ def create_25dmesh(inPointCloud, outMesh, dsm_radius=0.07, dsm_resolution=0.05, mesh = dem_to_mesh(os.path.join(tmp_directory, 'mesh_dsm.tif'), outMesh, maxVertexCount, verbose) # Cleanup tmp - # if os.path.exists(tmp_directory): - # shutil.rmtree(tmp_directory) + if os.path.exists(tmp_directory): + shutil.rmtree(tmp_directory) return mesh diff --git a/scripts/odm_meshing.py b/scripts/odm_meshing.py index fca1db47..29cd3a72 100644 --- a/scripts/odm_meshing.py +++ b/scripts/odm_meshing.py @@ -88,8 +88,8 @@ class ODMeshingCell(ecto.Cell): if args.fast_orthophoto: dsm_radius *= 2 - # A good DSM size is 1/8 of the target orthophoto resolution - dsm_resolution = ortho_resolution * 8 + # A good DSM size is 1/4 of the target orthophoto resolution + dsm_resolution = ortho_resolution * 4 mesh.create_25dmesh(infile, tree.odm_25dmesh, dsm_radius=dsm_radius,