The work done in CAPTURING SPHERICAL SCENES FROM GOOGLE STREETVIEW is done with a python script. I tried to make it.
Please read the Google Street View license carefully before using this script.
python 2.7.10
append.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import shutil
import re
import sys
class Panorama:
def __init__(self, url):
self.path = "./tmp/"
self.panoid = self.parseID(url)
#panorama size = 12*25
self.x = 12
self.y = 25
def parseID(self,url):
dna = "!1s"
m = url.find(dna)
if m != -1:
return url[m+3:m+25]
else:
return ""
def mkdirTmp(self):
if os.path.exists(self.path):
pass
else:
os.mkdir(self.path)
def clean(self):
shutil.rmtree(self.path)
def downloadImage(self):
cmd = 'curl http://cbk0.google.com/cbk?output=tile\&panoid=' + self.panoid + '\&zoom=5\&x=[0-25]\&y=[0-12] -o ' + self.path + '"tile_#1-#2.jpg "'
os.system(cmd)
def appendImage(self):
#Connect to the side
for x in range(0, self.x+1):
cmd = "convert +append "
for y in range(0, self.y+1):
#Input file
inFile = self.path + "tile_%d-%d.jpg "% (y,x)
#Concatenate to command string
cmd += inFile + " "
#Set output file name
cmd += self.path + "%d.jpg "%x
#print cmd
#Run
os.system(cmd)
#Connect vertically
cmd = "convert -append "
for x in range(0,self.x):
cmd += self.path + "%d.jpg "%x + " "
cmd += "append.jpg "
#print cmd
os.system(cmd)
if __name__ == "__main__":
url = "https://www.google.co.jp/maps/@34.7020532,135.5020237,3a,75y,285h,99t/data=!3m7!1e1!3m5!1sBLX3E8R5JxUJnuHlPGg5kw!2e0!6s%2F%2Fgeo3.ggpht.com%2Fcbk%3Fpanoid%3DBLX3E8R5JxUJnuHlPGg5kw%26output%3Dthumbnail%26cb_client%3Dmaps_sv.tactile.gps%26thumb%3D2%26w%3D203%26h%3D100%26yaw%3D285.21%26pitch%3D9.21!7i13312!8i6656?hl=ja&hl=ja"
pano = Panorama(url)
if len(pano.panoid) > 0:
pano.mkdirTmp()
pano.downloadImage()
pano.appendImage()
pano.clean()
Recommended Posts