mirror of
https://code.it4i.cz/sccs/easyconfigs-it4i.git
synced 2025-04-07 23:42:12 +01:00

new file: i/IRODS/IRODS-0.7.3.eb new file: l/libxc/libxc-5.1.5-intel-2020a.eb new file: n/NodeODM/NodeODM-2.2.0-GCCcore-11.3.0.eb new file: o/ODM/ODM-2.8.7/.dockerignore new file: o/ODM/ODM-2.8.7/.github/workflows/publish-docker-and-wsl.yaml new file: o/ODM/ODM-2.8.7/.github/workflows/publish-docker-gpu.yaml new file: o/ODM/ODM-2.8.7/.github/workflows/publish-snap.yml new file: o/ODM/ODM-2.8.7/.github/workflows/publish-windows.yml new file: o/ODM/ODM-2.8.7/.github/workflows/test-build-prs.yaml new file: o/ODM/ODM-2.8.7/.gitignore new file: o/ODM/ODM-2.8.7/.gitmodules new file: o/ODM/ODM-2.8.7/CNAME new file: o/ODM/ODM-2.8.7/CONTRIBUTING.md new file: o/ODM/ODM-2.8.7/Dockerfile new file: o/ODM/ODM-2.8.7/LICENSE new file: o/ODM/ODM-2.8.7/README.md new file: o/ODM/ODM-2.8.7/SuperBuild/CMakeLists.txt new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-Ceres.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-Entwine.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-FPCFilter.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-GFlags.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-Hexer.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-LASzip.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-MvsTexturing.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-Obj2Tiles.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-OpenCV.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-OpenMVS.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-OpenSfM.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-PCL.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-PDAL.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-PyPopsift.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-Untwine.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/ExternalProject-Setup.cmake new file: o/ODM/ODM-2.8.7/VERSION new file: o/ODM/ODM-2.8.7/code_of_conduct.md new file: o/ODM/ODM-2.8.7/configure.py new file: o/ODM/ODM-2.8.7/configure.sh new file: o/ODM/ODM-2.8.7/console.bat new file: o/ODM/ODM-2.8.7/contrib/blender/README.md new file: o/ODM/ODM-2.8.7/contrib/blender/common.py new file: o/ODM/ODM-2.8.7/contrib/blender/odm_photo.py new file: o/ODM/ODM-2.8.7/contrib/blender/odm_video.py new file: o/ODM/ODM-2.8.7/contrib/blender/photo_360.blend new file: o/ODM/ODM-2.8.7/contrib/blender/photo_vr.blend new file: o/ODM/ODM-2.8.7/contrib/grass/README.md new file: o/ODM/ODM-2.8.7/contrib/grass/odm_grass.py new file: o/ODM/ODM-2.8.7/contrib/mergepreview/README.md new file: o/ODM/ODM-2.8.7/contrib/mergepreview/mergepreview.py new file: o/ODM/ODM-2.8.7/contrib/ndvi/README.md new file: o/ODM/ODM-2.8.7/contrib/ndvi/agricultural_indices.py new file: o/ODM/ODM-2.8.7/contrib/ndvi/ndvi.py new file: o/ODM/ODM-2.8.7/contrib/ndvi/rename_sentera_agx710_multispectral_tif.py new file: o/ODM/ODM-2.8.7/contrib/orthorectify/README.md new file: o/ODM/ODM-2.8.7/contrib/orthorectify/orthorectify.py new file: o/ODM/ODM-2.8.7/contrib/orthorectify/run.sh new file: o/ODM/ODM-2.8.7/contrib/pc2dem/README.md new file: o/ODM/ODM-2.8.7/contrib/pc2dem/pc2dem.py new file: o/ODM/ODM-2.8.7/contrib/resize/README.md new file: o/ODM/ODM-2.8.7/contrib/resize/requirements.txt new file: o/ODM/ODM-2.8.7/contrib/resize/resize.py new file: o/ODM/ODM-2.8.7/contrib/shell/odm_exif2utm.sh new file: o/ODM/ODM-2.8.7/contrib/visveg/readme.md new file: o/ODM/ODM-2.8.7/contrib/visveg/vegind.py new file: o/ODM/ODM-2.8.7/docker/README new file: o/ODM/ODM-2.8.7/docker/g++ new file: o/ODM/ODM-2.8.7/docker/gcc new file: o/ODM/ODM-2.8.7/docs/issue_template.md new file: o/ODM/ODM-2.8.7/gpu.Dockerfile new file: o/ODM/ODM-2.8.7/innosetup.iss new file: o/ODM/ODM-2.8.7/licenses/libext_copyright.txt new file: o/ODM/ODM-2.8.7/licenses/libx11_copyright.txt new file: o/ODM/ODM-2.8.7/licenses/license.md new file: o/ODM/ODM-2.8.7/odm_docker_readme.txt new file: o/ODM/ODM-2.8.7/opendm/__init__.py new file: o/ODM/ODM-2.8.7/opendm/boundary.py new file: o/ODM/ODM-2.8.7/opendm/camera.py new file: o/ODM/ODM-2.8.7/opendm/cogeo.py new file: o/ODM/ODM-2.8.7/opendm/concurrency.py new file: o/ODM/ODM-2.8.7/opendm/config.py new file: o/ODM/ODM-2.8.7/opendm/context.py new file: o/ODM/ODM-2.8.7/opendm/cropper.py new file: o/ODM/ODM-2.8.7/opendm/cutline.py new file: o/ODM/ODM-2.8.7/opendm/dem/__init__.py new file: o/ODM/ODM-2.8.7/opendm/dem/commands.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/__init__.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/bounds/__init__.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/bounds/types.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/bounds/utils.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/extra_dimensions/__init__.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/extra_dimensions/dimension.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/extra_dimensions/distance_dimension.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/extra_dimensions/extended_dimension.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/extra_dimensions/partition_dimension.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/grid/__init__.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/grid/builder.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/io/__init__.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/io/las_io.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/partition/__init__.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/partition/one_partition.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/partition/partition_plan.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/partition/quad_partitions.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/partition/selector.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/partition/surrounding_partitions.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/point_cloud.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/rectify.py new file: o/ODM/ODM-2.8.7/opendm/dem/merge.py new file: o/ODM/ODM-2.8.7/opendm/dem/pdal.py new file: o/ODM/ODM-2.8.7/opendm/dem/utils.py new file: o/ODM/ODM-2.8.7/opendm/dls.py new file: o/ODM/ODM-2.8.7/opendm/entwine.py new file: o/ODM/ODM-2.8.7/opendm/gcp.py new file: o/ODM/ODM-2.8.7/opendm/geo.py new file: o/ODM/ODM-2.8.7/opendm/get_image_size.py new file: o/ODM/ODM-2.8.7/opendm/gpu.py new file: o/ODM/ODM-2.8.7/opendm/gsd.py new file: o/ODM/ODM-2.8.7/opendm/io.py new file: o/ODM/ODM-2.8.7/opendm/location.py new file: o/ODM/ODM-2.8.7/opendm/log.py new file: o/ODM/ODM-2.8.7/opendm/loghelpers.py new file: o/ODM/ODM-2.8.7/opendm/mesh.py new file: o/ODM/ODM-2.8.7/opendm/multispectral.py new file: o/ODM/ODM-2.8.7/opendm/nvm.py new file: o/ODM/ODM-2.8.7/opendm/ogctiles.py new file: o/ODM/ODM-2.8.7/opendm/orthophoto.py new file: o/ODM/ODM-2.8.7/opendm/osfm.py new file: o/ODM/ODM-2.8.7/opendm/photo.py new file: o/ODM/ODM-2.8.7/opendm/point_cloud.py new file: o/ODM/ODM-2.8.7/opendm/progress.py new file: o/ODM/ODM-2.8.7/opendm/pseudogeo.py new file: o/ODM/ODM-2.8.7/opendm/remote.py new file: o/ODM/ODM-2.8.7/opendm/report/dsm_gradient.png new file: o/ODM/ODM-2.8.7/opendm/report/overlap_color_map.txt new file: o/ODM/ODM-2.8.7/opendm/report/overlap_diagram_legend.png new file: o/ODM/ODM-2.8.7/opendm/rollingshutter.py new file: o/ODM/ODM-2.8.7/opendm/shots.py new file: o/ODM/ODM-2.8.7/opendm/system.py new file: o/ODM/ODM-2.8.7/opendm/thermal.py new file: o/ODM/ODM-2.8.7/opendm/thermal_tools/__init__.py new file: o/ODM/ODM-2.8.7/opendm/thermal_tools/dji_unpack.py new file: o/ODM/ODM-2.8.7/opendm/thermal_tools/flir_unpack.py new file: o/ODM/ODM-2.8.7/opendm/thermal_tools/thermal_utils.py new file: o/ODM/ODM-2.8.7/opendm/tiles/color_relief.txt new file: o/ODM/ODM-2.8.7/opendm/tiles/gdal2tiles.py new file: o/ODM/ODM-2.8.7/opendm/tiles/hsv_merge.py new file: o/ODM/ODM-2.8.7/opendm/tiles/tiler.py new file: o/ODM/ODM-2.8.7/opendm/types.py new file: o/ODM/ODM-2.8.7/opendm/utils.py new file: o/ODM/ODM-2.8.7/opendm/vendor/__init__.py new file: o/ODM/ODM-2.8.7/opendm/vendor/gdal_fillnodata.py new file: o/ODM/ODM-2.8.7/portable.Dockerfile new file: o/ODM/ODM-2.8.7/requirements.txt new file: o/ODM/ODM-2.8.7/run.bat new file: o/ODM/ODM-2.8.7/run.py new file: o/ODM/ODM-2.8.7/run.sh new file: o/ODM/ODM-2.8.7/snap/snapcraft.yaml new file: o/ODM/ODM-2.8.7/snap/snapcraft21.yaml new file: o/ODM/ODM-2.8.7/stages/__init__.py new file: o/ODM/ODM-2.8.7/stages/dataset.py new file: o/ODM/ODM-2.8.7/stages/mvstex.py new file: o/ODM/ODM-2.8.7/stages/odm_app.py new file: o/ODM/ODM-2.8.7/stages/odm_dem.py new file: o/ODM/ODM-2.8.7/stages/odm_filterpoints.py new file: o/ODM/ODM-2.8.7/stages/odm_georeferencing.py new file: o/ODM/ODM-2.8.7/stages/odm_meshing.py new file: o/ODM/ODM-2.8.7/stages/odm_orthophoto.py new file: o/ODM/ODM-2.8.7/stages/odm_postprocess.py new file: o/ODM/ODM-2.8.7/stages/odm_report.py new file: o/ODM/ODM-2.8.7/stages/openmvs.py new file: o/ODM/ODM-2.8.7/stages/run_opensfm.py new file: o/ODM/ODM-2.8.7/stages/splitmerge.py new file: o/ODM/ODM-2.8.7/start-dev-env.sh new file: o/ODM/ODM-2.8.7/test.sh new file: o/ODM/ODM-2.8.7/tests/assets/.gitignore new file: o/ODM/ODM-2.8.7/tests/assets/gcp_extras.txt new file: o/ODM/ODM-2.8.7/tests/assets/gcp_latlon_south.txt new file: o/ODM/ODM-2.8.7/tests/assets/gcp_latlon_valid.txt new file: o/ODM/ODM-2.8.7/tests/assets/gcp_michigan_feet_valid.txt new file: o/ODM/ODM-2.8.7/tests/assets/gcp_utm_north_valid.txt new file: o/ODM/ODM-2.8.7/tests/assets/images/DJI_0002.JPG new file: o/ODM/ODM-2.8.7/tests/assets/reconstruction.json new file: o/ODM/ODM-2.8.7/tests/assets/sample.json new file: o/ODM/ODM-2.8.7/tests/test_camera.py new file: o/ODM/ODM-2.8.7/tests/test_gcp.py new file: o/ODM/ODM-2.8.7/tests/test_osfm.py new file: o/ODM/ODM-2.8.7/tests/test_remote.py new file: o/ODM/ODM-2.8.7/tests/test_types.py new file: o/ODM/ODM-2.8.7/vcpkg-requirements.txt new file: o/ODM/ODM-2.8.7/win32env.bat new file: o/ODM/ODM-2.8.7/winrun.bat new file: o/ODM/v2.8.7.tar.gz new file: y/Yambo/Yambo-5.1.0-intel-2020a.eb new file: y/Yambo/Yambo-5.1.0-intel-2020a.eb.bak_20220715124556_61837 new file: y/Yambo/Yambo-5.1.0-intel-2021a.eb.old deleted: y/Yambo/Yambo-5.1.0-intel-2021a.eb
189 lines
6.6 KiB
Python
189 lines
6.6 KiB
Python
import os
|
|
import shutil
|
|
import rasterio
|
|
import fiona
|
|
import numpy as np
|
|
import math
|
|
import sys
|
|
from opendm import log
|
|
from opendm import io
|
|
from opendm import concurrency
|
|
from opendm import get_image_size
|
|
from opendm import system
|
|
|
|
from skimage.feature import canny
|
|
from skimage.draw import line
|
|
from skimage.graph import route_through_array
|
|
import shapely
|
|
from shapely.geometry import LineString, mapping, shape
|
|
from shapely.ops import polygonize, unary_union
|
|
|
|
if sys.platform == 'win32':
|
|
# Temporary fix for: ValueError: GEOSGeom_createLinearRing_r returned a NULL pointer
|
|
# https://github.com/Toblerity/Shapely/issues/1005
|
|
shapely.speedups.disable()
|
|
|
|
def write_raster(data, file):
|
|
profile = {
|
|
'driver': 'GTiff',
|
|
'width': data.shape[1],
|
|
'height': data.shape[0],
|
|
'count': 1,
|
|
'dtype': 'float32',
|
|
'transform': None,
|
|
'nodata': None,
|
|
'crs': None
|
|
}
|
|
|
|
with rasterio.open(file, 'w', BIGTIFF="IF_SAFER", **profile) as wout:
|
|
wout.write(data, 1)
|
|
|
|
def compute_cutline(orthophoto_file, crop_area_file, destination, max_concurrency=1, scale=1):
|
|
if io.file_exists(orthophoto_file) and io.file_exists(crop_area_file):
|
|
log.ODM_INFO("Computing cutline")
|
|
|
|
scale = max(0.0001, min(1, scale))
|
|
scaled_orthophoto = None
|
|
if scale < 1:
|
|
log.ODM_INFO("Scaling orthophoto to %s%% to compute cutline" % (scale * 100))
|
|
|
|
scaled_orthophoto = io.related_file_path(orthophoto_file, postfix=".scaled")
|
|
# Scale orthophoto before computing cutline
|
|
system.run("gdal_translate -outsize {}% 0 "
|
|
"-co NUM_THREADS={} "
|
|
"--config GDAL_CACHEMAX {}% "
|
|
'"{}" "{}"'.format(
|
|
scale * 100,
|
|
max_concurrency,
|
|
concurrency.get_max_memory(),
|
|
orthophoto_file,
|
|
scaled_orthophoto
|
|
))
|
|
|
|
orthophoto_file = scaled_orthophoto
|
|
|
|
# open raster
|
|
f = rasterio.open(orthophoto_file)
|
|
rast = f.read(1) # First band only
|
|
height, width = rast.shape
|
|
number_lines = int(max(8, math.ceil(min(width, height) / 256.0)))
|
|
line_hor_offset = int(width / number_lines)
|
|
line_ver_offset = int(height / number_lines)
|
|
|
|
if line_hor_offset <= 2 or line_ver_offset <= 2:
|
|
log.ODM_WARNING("Cannot compute cutline, orthophoto is too small (%sx%spx)" % (width, height))
|
|
return
|
|
|
|
crop_f = fiona.open(crop_area_file, 'r')
|
|
if len(crop_f) == 0:
|
|
log.ODM_WARNING("Crop area is empty, cannot compute cutline")
|
|
return
|
|
|
|
crop_poly = shape(crop_f[1]['geometry'])
|
|
crop_f.close()
|
|
|
|
linestrings = []
|
|
|
|
# Compute canny edges on first band
|
|
edges = canny(rast)
|
|
|
|
def compute_linestrings(direction):
|
|
log.ODM_INFO("Computing %s cutlines" % direction)
|
|
# Initialize cost map
|
|
cost_map = np.full((height, width), 1, dtype=np.float32)
|
|
|
|
# Write edges to cost map
|
|
cost_map[edges==True] = 0 # Low cost
|
|
|
|
# Write "barrier, floor is lava" costs
|
|
if direction == 'vertical':
|
|
lines = [((i, 0), (i, height - 1)) for i in range(line_hor_offset, width - line_hor_offset, line_hor_offset)]
|
|
points = []
|
|
pad_x = int(line_hor_offset / 2.0)
|
|
for i in range(0, len(lines)):
|
|
a,b = lines[i]
|
|
points.append(((a[0] - pad_x , a[1]), (b[0] - pad_x, b[1])))
|
|
a,b = lines[-1]
|
|
points.append(((a[0] + pad_x , a[1]), (b[0] + pad_x, b[1])))
|
|
else:
|
|
lines = [((0, j), (width - 1, j)) for j in range(line_ver_offset, height - line_ver_offset, line_ver_offset)]
|
|
points = []
|
|
pad_y = int(line_ver_offset / 2.0)
|
|
for i in range(0, len(lines)):
|
|
a,b = lines[i]
|
|
points.append(((a[0] , a[1] - pad_y), (b[0], b[1] - pad_y)))
|
|
a,b = lines[-1]
|
|
points.append(((a[0] , a[1] + pad_y), (b[0], b[1] + pad_y)))
|
|
|
|
for a, b in lines:
|
|
rr,cc = line(*a, *b)
|
|
cost_map[cc, rr] = 9999 # Lava
|
|
|
|
# Calculate route
|
|
for a, b in points:
|
|
line_coords, cost = route_through_array(cost_map, (a[1], a[0]), (b[1], b[0]), fully_connected=True, geometric=True)
|
|
|
|
# Convert to geographic
|
|
geo_line_coords = [f.xy(*c) for c in line_coords]
|
|
|
|
# Simplify
|
|
ls = LineString(geo_line_coords)
|
|
linestrings.append(ls.simplify(0.05, preserve_topology=False))
|
|
|
|
compute_linestrings('vertical')
|
|
compute_linestrings('horizontal')
|
|
|
|
|
|
# Generate polygons and keep only those inside the crop area
|
|
log.ODM_INFO("Generating polygons... this could take a bit.")
|
|
polygons = []
|
|
for p in polygonize(unary_union(linestrings)):
|
|
if crop_poly.contains(p):
|
|
polygons.append(p)
|
|
|
|
# This should never happen
|
|
if len(polygons) == 0:
|
|
log.ODM_WARNING("No polygons, cannot compute cutline")
|
|
return
|
|
|
|
log.ODM_INFO("Merging polygons")
|
|
cutline_polygons = unary_union(polygons)
|
|
if not hasattr(cutline_polygons, '__getitem__'):
|
|
cutline_polygons = [cutline_polygons]
|
|
|
|
largest_cutline = cutline_polygons[0]
|
|
max_area = largest_cutline.area
|
|
for p in cutline_polygons:
|
|
if p.area > max_area:
|
|
max_area = p.area
|
|
largest_cutline = p
|
|
|
|
log.ODM_INFO("Largest cutline found: %s m^2" % max_area)
|
|
|
|
meta = {
|
|
'crs': {'init': str(f.crs).lower() },
|
|
'driver': 'GPKG',
|
|
'schema': {
|
|
'properties': {},
|
|
'geometry': 'Polygon'
|
|
}
|
|
}
|
|
|
|
# Remove previous
|
|
if os.path.exists(destination):
|
|
os.remove(destination)
|
|
|
|
with fiona.open(destination, 'w', **meta) as sink:
|
|
sink.write({
|
|
'geometry': mapping(largest_cutline),
|
|
'properties': {}
|
|
})
|
|
f.close()
|
|
log.ODM_INFO("Wrote %s" % destination)
|
|
|
|
# Cleanup
|
|
if scaled_orthophoto is not None and os.path.exists(scaled_orthophoto):
|
|
os.remove(scaled_orthophoto)
|
|
else:
|
|
log.ODM_WARNING("We've been asked to compute cutline, but either %s or %s is missing. Skipping..." % (orthophoto_file, crop_area_file))
|