More refactoring

This commit is contained in:
Kumi 2018-10-21 12:40:16 +02:00
parent 7df03657ad
commit db3d012976
2 changed files with 21 additions and 20 deletions

View file

@ -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

View file

@ -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