From 37886f77c211fb043e47d3b8a55e6dbeefe5f49b Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Wed, 5 Jan 2022 15:44:33 -0500 Subject: [PATCH 1/3] Fix --camera-lens --- opendm/config.py | 4 ++-- opendm/photo.py | 4 ++++ stages/dataset.py | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/opendm/config.py b/opendm/config.py index c61a692c..6cf661b8 100755 --- a/opendm/config.py +++ b/opendm/config.py @@ -180,12 +180,12 @@ def config(argv=None, parser=None): 'Can be specified either as path to a cameras.json file or as a ' 'JSON string representing the contents of a ' 'cameras.json file. Default: %(default)s') - + parser.add_argument('--camera-lens', metavar='', action=StoreValue, default='auto', - choices=['auto', 'perspective', 'brown', 'fisheye', 'spherical'], + choices=['auto', 'perspective', 'brown', 'fisheye', 'spherical', 'equirectangular', 'dual'], help=('Set a camera projection type. Manually setting a value ' 'can help improve geometric undistortion. By default the application ' 'tries to determine a lens type from the images metadata. Can be one of: %(choices)s. Default: ' diff --git a/opendm/photo.py b/opendm/photo.py index 4378c390..dcd48b3d 100644 --- a/opendm/photo.py +++ b/opendm/photo.py @@ -617,6 +617,10 @@ class ODM_Photo: def override_gps_dop(self, dop): self.gps_xy_stddev = self.gps_z_stddev = dop + def override_camera_projection(self, camera_projection): + if camera_projection in projections: + self.camera_projection = camera_projection + def is_thermal(self): #Added for support M2EA camera sensor if(self.camera_make == "DJI"): diff --git a/stages/dataset.py b/stages/dataset.py index 8000c61d..9684a0d1 100644 --- a/stages/dataset.py +++ b/stages/dataset.py @@ -136,6 +136,13 @@ class ODMLoadDatasetStage(types.ODM_Stage): for p in photos: p.override_gps_dop(args.gps_accuracy) + + # Override projection type + if args.camera_lens != "auto": + log.ODM_INFO("Setting camera lens to %s for all images" % args.camera_lens) + + for p in photos: + p.override_camera_projection(args.camera_lens) # Save image database for faster restart save_images_database(photos, images_database_file) From 2c2ac29d4984e315fbb2b4717c041ce0c6ee65d0 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Fri, 7 Jan 2022 12:29:14 -0500 Subject: [PATCH 2/3] Force x64 PoissonRecon --- SuperBuild/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SuperBuild/CMakeLists.txt b/SuperBuild/CMakeLists.txt index 20060152..cb72e6ec 100644 --- a/SuperBuild/CMakeLists.txt +++ b/SuperBuild/CMakeLists.txt @@ -167,8 +167,8 @@ include(ProcessorCount) ProcessorCount(nproc) if (WIN32) - set (POISSON_BUILD_CMD ${CMAKE_MAKE_PROGRAM} ${SB_SOURCE_DIR}/PoissonRecon/PoissonRecon.vcxproj /p:configuration=${CMAKE_BUILD_TYPE} /p:PlatformToolset=${CMAKE_VS_PLATFORM_TOOLSET} /p:WindowsTargetPlatformVersion=${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}) - set (POISSON_BIN_PATH "Win32/${CMAKE_BUILD_TYPE}/PoissonRecon.exe") + set (POISSON_BUILD_CMD ${CMAKE_MAKE_PROGRAM} ${SB_SOURCE_DIR}/PoissonRecon/PoissonRecon.vcxproj /p:configuration=${CMAKE_BUILD_TYPE} /p:Platform=x64 /p:PlatformToolset=${CMAKE_VS_PLATFORM_TOOLSET} /p:WindowsTargetPlatformVersion=${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}) + set (POISSON_BIN_PATH "x64/${CMAKE_BUILD_TYPE}/PoissonRecon.exe") else() set (POISSON_BUILD_CMD make -j${nproc} poissonrecon) set (POISSON_BIN_PATH "Linux/PoissonRecon") From 88326108e9ce284e5269ef3af624e8e215dfc6a1 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Fri, 7 Jan 2022 15:50:22 -0500 Subject: [PATCH 3/3] Fix median filtering nodata handling --- opendm/dem/commands.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/opendm/dem/commands.py b/opendm/dem/commands.py index 0b0bcce0..37ed4456 100755 --- a/opendm/dem/commands.py +++ b/opendm/dem/commands.py @@ -186,7 +186,7 @@ def create_dem(input_point_cloud, dem_type, output_type='max', radiuses=['0.56'] for t in tiles: if not os.path.exists(t['filename']): raise Exception("Error creating %s, %s failed to be created" % (output_file, t['filename'])) - + # Create virtual raster tiles_vrt_path = os.path.abspath(os.path.join(outdir, "tiles.vrt")) tiles_file_list = os.path.abspath(os.path.join(outdir, "tiles_list.txt")) @@ -315,6 +315,8 @@ def median_smoothing(geotiff_path, output_path, smoothing_iterations=1): dtype = img.dtypes[0] arr = img.read()[0] + nodata_locs = numpy.where(arr == nodata) + # Median filter (careful, changing the value 5 might require tweaking) # the lines below. There's another numpy function that takes care of # these edge cases, but it's slower. @@ -330,8 +332,7 @@ def median_smoothing(geotiff_path, output_path, smoothing_iterations=1): arr[-1][-2:] = arr[-2][-1] = arr[-2][-2] # Median filter leaves a bunch of zeros in nodata areas - locs = numpy.where(arr == 0.0) - arr[locs] = nodata + arr[nodata_locs] = nodata # write output with rasterio.open(output_path, 'w', **img.profile) as imgout: