From db3d012976424e090e576129abc9eb0e033be989 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Sun, 21 Oct 2018 12:40:16 +0200 Subject: [PATCH] More refactoring --- krpanosteal/__init__.py | 23 +++-------------------- stitching/__init__.py | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/krpanosteal/__init__.py b/krpanosteal/__init__.py index f271630..5dcd2f8 100644 --- a/krpanosteal/__init__.py +++ b/krpanosteal/__init__.py @@ -6,7 +6,7 @@ import subprocess import tempfile import pathlib import os -from stitching import tiles_to_equirectangular_blender, stitch +from stitching import tiles_to_equirectangular_blender, multistitch def krpano_normalize(url): ''' @@ -59,7 +59,7 @@ def krpano_export(schema): lists of lists containing all images fit for passing into stitch(). :param schema: normalized URL format output by krpano_normalize() - :return: list of lists of lists of PIL.Image() objects for krpano_stitch() + :return: list of lists of lists of PIL.Image() objects for multistitch() ''' maxzoom = krpano_getmaxzoom(schema) @@ -114,23 +114,6 @@ def krpano_export_simple(url): return output -def krpano_stitch(tiles): - ''' - Takes a list of lists of lists containing PIL Image objects and stitches - them into one. Each box tile (first-order lists), line (second-order) and - column (third-order) must be equal in height and width. - - :param faces: list of lists of lists containing PIL.Image objects - :return: list of stitched PIL.Image objects - ''' - - output = [] - - for tile in tiles: - output.append(stitch(tile)) - - return output - def krpano_make_tiles(url): ''' Determines the type of processing needed to build the six tiles, then @@ -149,7 +132,7 @@ def krpano_make_tiles(url): else: schema = krpano_normalize(url) images = krpano_export(schema) - return krpano_stitch(images) + return multistitch(images) except: raise diff --git a/stitching/__init__.py b/stitching/__init__.py index ed254c8..6e90147 100644 --- a/stitching/__init__.py +++ b/stitching/__init__.py @@ -46,6 +46,7 @@ def tiles_to_equirectangular_blender(back, right, front, left, top, bottom, pathlib.Path(tmp).mkdir(parents=True, exist_ok=True) except: print("Failed to create temporary directory.") + print(tmp) raise '''If no resolution is passed, assume the original resolution for output.''' @@ -186,6 +187,23 @@ def tiles_to_equirectangular(back, right, front, left, top, bottom): return output +def multistitch(tiles): + ''' + Takes a list of lists of lists containing PIL Image objects and stitches + them into one. Each box tile (first-order lists), line (second-order) and + column (third-order) must be equal in height and width. + + :param faces: list of lists of lists containing PIL.Image objects + :return: list of stitched PIL.Image objects + ''' + + output = [] + + for tile in tiles: + output.append(stitch(tile)) + + return output + def stitch(images): ''' Takes a list of lists containing PIL Image objects and stitches them into