kopia lustrzana https://github.com/OpenDroneMap/ODM
rodzic
43d9201987
commit
afc5fb89c5
|
@ -4,13 +4,17 @@ 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
|
from opendm import get_image_size
|
||||||
|
from opendm import system
|
||||||
import math
|
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, tmpdir=None):
|
||||||
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")
|
||||||
|
|
||||||
|
if not io.dir_exists(tmpdir):
|
||||||
|
system.mkdir_p(tmpdir)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ortho_width,ortho_height = get_image_size.get_image_size(orthophoto_file)
|
ortho_width,ortho_height = get_image_size.get_image_size(orthophoto_file)
|
||||||
log.ODM_DEBUG("Orthophoto dimensions are %sx%s" % (ortho_width, ortho_height))
|
log.ODM_DEBUG("Orthophoto dimensions are %sx%s" % (ortho_width, ortho_height))
|
||||||
|
@ -21,7 +25,7 @@ def compute_cutline(orthophoto_file, crop_area_file, destination, max_concurrenc
|
||||||
|
|
||||||
log.ODM_DEBUG("Number of lines: %s" % number_lines)
|
log.ODM_DEBUG("Number of lines: %s" % number_lines)
|
||||||
|
|
||||||
gctx = grass.create_context({'auto_cleanup' : False})
|
gctx = grass.create_context({'auto_cleanup' : False, 'tmpdir': tmpdir})
|
||||||
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('number_lines', number_lines)
|
||||||
|
|
|
@ -115,7 +115,8 @@ class ODMOrthoPhotoStage(types.ODM_Stage):
|
||||||
compute_cutline(tree.odm_orthophoto_tif,
|
compute_cutline(tree.odm_orthophoto_tif,
|
||||||
bounds_file_path,
|
bounds_file_path,
|
||||||
os.path.join(tree.odm_orthophoto, "cutline.gpkg"),
|
os.path.join(tree.odm_orthophoto, "cutline.gpkg"),
|
||||||
args.max_concurrency)
|
args.max_concurrency,
|
||||||
|
tmpdir=os.path.join(tree.odm_orthophoto, "grass_cutline_tmpdir"))
|
||||||
|
|
||||||
if args.crop > 0:
|
if args.crop > 0:
|
||||||
Cropper.crop(bounds_file_path, tree.odm_orthophoto_tif, orthophoto_vars)
|
Cropper.crop(bounds_file_path, tree.odm_orthophoto_tif, orthophoto_vars)
|
||||||
|
|
Ładowanie…
Reference in New Issue