kopia lustrzana https://github.com/OpenDroneMap/ODM
Number of lines computation
rodzic
e5dde492b3
commit
5a8284c5cc
|
@ -3,16 +3,28 @@ import shutil
|
||||||
from opendm import log
|
from opendm import log
|
||||||
from opendm import io
|
from opendm import io
|
||||||
from opendm import concurrency
|
from opendm import concurrency
|
||||||
|
from opendm import get_image_size
|
||||||
|
import math
|
||||||
|
|
||||||
def compute_cutline(orthophoto_file, crop_area_file, destination, max_concurrency=1):
|
def compute_cutline(orthophoto_file, crop_area_file, destination, max_concurrency=1):
|
||||||
if io.file_exists(orthophoto_file) and io.file_exists(crop_area_file):
|
if io.file_exists(orthophoto_file) and io.file_exists(crop_area_file):
|
||||||
from opendm.grass_engine import grass
|
from opendm.grass_engine import grass
|
||||||
log.ODM_DEBUG("Computing cutline")
|
log.ODM_DEBUG("Computing cutline")
|
||||||
|
|
||||||
|
try:
|
||||||
|
ortho_width,ortho_height = get_image_size.get_image_size(orthophoto_file)
|
||||||
|
log.ODM_DEBUG("Orthophoto dimensions are %sx%s" % (ortho_width, ortho_height))
|
||||||
|
number_lines = int(max(8, math.ceil(min(ortho_width, ortho_height) / 256.0)))
|
||||||
|
except get_image_size.UnknownImageFormat:
|
||||||
|
log.ODM_DEBUG("Cannot compute orthophoto dimensions, setting arbitrary number of lines.")
|
||||||
|
number_lines = 32
|
||||||
|
|
||||||
|
log.ODM_DEBUG("Number of lines: %s" % number_lines)
|
||||||
|
|
||||||
gctx = grass.create_context({'auto_cleanup' : False})
|
gctx = grass.create_context({'auto_cleanup' : False})
|
||||||
gctx.add_param('orthophoto_file', orthophoto_file)
|
gctx.add_param('orthophoto_file', orthophoto_file)
|
||||||
gctx.add_param('crop_area_file', crop_area_file)
|
gctx.add_param('crop_area_file', crop_area_file)
|
||||||
|
gctx.add_param('number_lines', number_lines)
|
||||||
gctx.add_param('max_concurrency', max_concurrency)
|
gctx.add_param('max_concurrency', max_concurrency)
|
||||||
gctx.add_param('memory', int(concurrency.get_max_memory_mb(300)))
|
gctx.add_param('memory', int(concurrency.get_max_memory_mb(300)))
|
||||||
gctx.set_location(orthophoto_file)
|
gctx.set_location(orthophoto_file)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# orthophoto_file: input GeoTIFF raster file
|
# orthophoto_file: input GeoTIFF raster file
|
||||||
# crop_area_file: input vector polygon file delimiting the safe area for processing
|
# crop_area_file: input vector polygon file delimiting the safe area for processing
|
||||||
|
# number_lines: number of cutlines on the smallest side of the orthophoto for computing the final cutline
|
||||||
# max_concurrency: maximum number of parallel processes to use
|
# max_concurrency: maximum number of parallel processes to use
|
||||||
# memory: maximum MB of memory to use
|
# memory: maximum MB of memory to use
|
||||||
# ------
|
# ------
|
||||||
|
@ -14,7 +15,7 @@ v.in.ogr input="${crop_area_file}" output=crop_area --overwrite
|
||||||
g.region vector=crop_area
|
g.region vector=crop_area
|
||||||
|
|
||||||
# Generate cutlines
|
# Generate cutlines
|
||||||
i.cutlines.py --overwrite input=ortho output=cutline number_lines=16 edge_detection=zc no_edge_friction=20 lane_border_multiplier=1000000 tile_width=1024 tile_height=1024 overlap=20 processes=${max_concurrency} memory=${memory}
|
i.cutlinesmod.py --overwrite input=ortho output=cutline number_lines=${number_lines} edge_detection=zc no_edge_friction=20 lane_border_multiplier=1000000 tile_width=1024 tile_height=1024 overlap=20 processes=${max_concurrency} memory=${memory}
|
||||||
|
|
||||||
#v.out.ogr input=cutline output="cutline_raw.gpkg" format=GPKG
|
#v.out.ogr input=cutline output="cutline_raw.gpkg" format=GPKG
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
# MODULE: i.cutlines
|
# MODULE: i.cutlines2
|
||||||
# AUTHOR(S): Moritz Lennert, with help of Stefanos Georganos
|
# AUTHOR(S): Moritz Lennert, with help of Stefanos Georganos, modified by
|
||||||
|
# Piero Toffanin
|
||||||
#
|
#
|
||||||
# PURPOSE: Create tiles the borders of which do not cut across semantically
|
# PURPOSE: Create tiles the borders of which do not cut across semantically
|
||||||
# meaningful objects
|
# meaningful objects
|
||||||
|
@ -301,10 +302,10 @@ def main():
|
||||||
|
|
||||||
if nsrange > ewrange:
|
if nsrange > ewrange:
|
||||||
hnumber_lines = number_lines
|
hnumber_lines = number_lines
|
||||||
vnumber_lines = int(number_lines * (ewrange / nsrange))
|
vnumber_lines = int(number_lines * (nsrange / ewrange))
|
||||||
else:
|
else:
|
||||||
vnumber_lines = number_lines
|
vnumber_lines = number_lines
|
||||||
hnumber_lines = int(number_lines * (nsrange / ewrange))
|
hnumber_lines = int(number_lines * (ewrange / nsrange))
|
||||||
|
|
||||||
# Create the lines in horizonal direction
|
# Create the lines in horizonal direction
|
||||||
nsstep = float(region.n - region.s - region.nsres) / hnumber_lines
|
nsstep = float(region.n - region.s - region.nsres) / hnumber_lines
|
Ładowanie…
Reference in New Issue