-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStreet-View-Capture.py
129 lines (88 loc) · 2.66 KB
/
Street-View-Capture.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
from selenium import webdriver
from selenium.webdriver.common.by import By
import ctypes
import time
import math
HEADING_ADD = 1
PITCH_ADD = 2
heading = 0
pitch = 10
heading_max = 180
pitch_max = -60
heading_step = 10
browser = webdriver.Firefox()
def init():
url = "http://www.earthol.org/city-319.html"
browser.set_window_size(1920, 1080)
browser.get(url)
print('Ready?')
if input() != '1':
print('Not ready')
#exit()
return 1
'''
global heading, pitch
r = browser.execute_script('return pano.getPov()')
print(r['heading'], r['pitch'])
heading = r['heading']
pitch = r['pitch']
'''
def rotate(dir):
global heading, pitch
if dir == HEADING_ADD:
heading += heading_step
pitch = 10
if dir == PITCH_ADD:
pitch -= 10
browser.execute_script('pano.setPov({heading:' + str(heading%360) + ', pitch:' + str(pitch) +'})')
def sort(a, b):
if a > b:
return b, a
else:
return a, b
def initOnce():
global heading_max, heading
r = browser.execute_script('return pano.getPov()')
start = r['heading']
print(start)
input('结束?')
r = browser.execute_script('return pano.getPov()')
end = r['heading']
print(end)
if math.fabs(end-start) < 180:
heading, heading_max = sort(start, end)
else:
heading_max, heading = sort(start, end)
heading_max += 360
print(heading, heading_max)
browser.execute_script('pano.setPov({heading:' + str(heading) + ', pitch:10})')
def main():
if init() == 1:
return
a = browser.find_element(by=By.ID, value="panomap")
s = ''
while True:
if s != '2':
ctypes.windll.user32.MessageBoxA(0,u"是否继续?".encode('gb2312'),u' 信息'.encode('gb2312'),0)
s = input()
if s == '0':
break
elif s == '2':
r = browser.execute_script('return pano.getPov()')
print(r['heading'], r['pitch'])
continue
elif s == 's':
initOnce()
else:
continue
pos = browser.execute_script('return pano.getPosition().toUrlValue()')
while heading <= heading_max:
while pitch >= pitch_max:
time.sleep(1)
print('I:\\Ubuntu\\data\\raw\\' + pos + '_' + str(heading) + '_' + str(pitch) + '.png\n')
a.screenshot('I:\\Ubuntu\\data\\raw\\' + pos + '_' + str(heading) + '_' + str(pitch) + '.png')
rotate(PITCH_ADD)
rotate(HEADING_ADD)
browser.close()
if __name__ == '__main__':
main()