Created
December 7, 2020 08:36
-
-
Save rolux/7a8cf3216ba4da3b2627a6d43efcff3a to your computer and use it in GitHub Desktop.
python script, unedited, used to create https://youtu.be/X2ryBq31pHs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division, print_function | |
import math | |
from oxmaps import Line, Pano, PanoImage, PanoTile, Point, db | |
from PIL import Image | |
ids = [ | |
'eGYyAlN9kvBEg6AYtJV60A', | |
'CCQWTbDqYokwHNwBWnl8wQ', | |
'_UBAlMtHNb7hUYpxXkmcCA', | |
'tBMPwhLVH4Kk8EdQc15-3w', | |
'a7FV_PDjY6_l7U3MsB0vZA', | |
'jwv33kC4RsNRr0CEQwasvQ', | |
'WeNjOs000ZPHHyiEWnZHWQ', | |
'E_WuJjCvBEnn_p8xr67EJw', | |
'Vz9DadTOrPL4X27obcD28A', | |
'5_v-SDJH7w4_BVHgoa0Pvw', | |
'KGJrXFcWtWYh4XKVoAdU2w', | |
'xymM955pJtbqfjyCwODLsA', | |
'JqkDHJJ0tmpaXoqX2Vv9Vg' | |
] | |
''' | |
points = [] | |
for id in enumerate(ids): | |
pano = Pano(id) | |
points.append(Point(pano.lat, pano.lng)) | |
target = points[11].point(45, 10) | |
for i, id in enumerate(ids): | |
yaw = Line(points[i], target).bearing | |
PanoImage(Pano(id), (1920, 1080), yaw, fov=60).save( | |
'godard_mieville_{0:02}'.format(i + 1) | |
) | |
''' | |
''' | |
image = Image.new('RGB', (13312, 6656)) | |
pano = Pano('xymM955pJtbqfjyCwODLsA') | |
db.commit() | |
for y in range(13): | |
for x in range(26): | |
tile = PanoTile(pano, 5, y, x) | |
tile.download() | |
tile_image = Image.open(tile.path) | |
tile_image = tile_image.resize((512, 512), Image.ANTIALIAS) | |
image.paste(tile_image, (x * 512, y * 512)) | |
image.save('godard_mieville.png') | |
''' | |
image = Image.open('godard_mieville.png') | |
w, h = 1280, 720 | |
xys = [ | |
(4059, 3747), | |
(3874, 2970), | |
(6175, 3043), | |
(10404, 3169), | |
(12053, 2858), | |
(13247, 3075), | |
(2404, 3212), | |
(2219, 622) | |
] | |
x_max = 13312 | |
n = 3750 | |
n_ = n - sum([375 if i == 6 else 125 for i in range(len(xys))]) | |
ds = [] | |
for i, xy in enumerate(xys): | |
if i == 0: | |
continue | |
x0, y0 = xys[i - 1] | |
x1, y1 = xy | |
if x1 - x0 < -10000: | |
x1 += x_max | |
dx = x1 - x0 | |
dy = y1 - y0 | |
d = math.sqrt(pow(dx, 2) + pow(dy, 2)) | |
ds.append((dx, dy, d)) | |
print(ds) | |
ns = [] | |
for d in ds: | |
print(d[2] / sum([d_[2] for d_ in ds]) * n_) | |
ns.append(int(round((d[2] / sum([d_[2] for d_ in ds]) * n_)))) | |
print(ns, sum(ns), n_, n - sum(ns)) | |
def get_positions(n): | |
return [(1 - math.cos(i / n * math.pi)) / 2 for i in range(n)] | |
def read_frame(x_, y_): | |
frame = image.crop((x_, y_, x_ + w, y_ + h)) | |
if x_ + w > x_max: | |
frame.paste(image.crop((0, y_, w, y_ + h)), (x_max - x_, 0)) | |
return frame | |
def write_frame(frame, i): | |
path = 'godard_mieville/godard_mieville_{0:04}.jpg'.format(i) | |
print('writing', path) | |
frame.save(path) | |
f = 0 | |
for i, xy in enumerate(xys): | |
x, y = xy | |
frame = read_frame(x, y) | |
for i_ in range(375 if i == 6 else 125): | |
f += 1 | |
write_frame(frame, f) | |
if i == len(xys): | |
continue | |
dx, dy, d = ds[i] | |
positions = get_positions(ns[i] + 1)[1:] | |
print(len(positions), ns[i]) | |
for i_ in range(ns[i]): | |
frame = read_frame( | |
int(round(x + dx * positions[i_])) % x_max, | |
int(round(y + dy * positions[i_])) | |
) | |
f += 1 | |
write_frame(frame, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment