-
Notifications
You must be signed in to change notification settings - Fork 2
/
CreateCameras_Round.py
82 lines (59 loc) · 2.1 KB
/
CreateCameras_Round.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
#=============================================================================#
# Create Cameras Round 24.05.2019 #
#-----------------------------------------------------------------------------#
# #
# Michael Zwick | Topografischer Fachspezialist | VBS / swisstopo #
# #
#=============================================================================#
import os
import math
import time
import pickle
import datetime
import requests
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print(timestamp + ' |START| Create Cameras Round')
# Script parameters
center = [2600000, 1200000] # Bern
elevation = 700
pitch = -20
steps = 4
# Calculating camera positions in WGS84
url = "http://geodesy.geo.admin.ch/reframe/lv95towgs84"
positions = []
headings = []
elevations = []
pitches = []
mode = 'Round'
eLV95 = center[0]
nLV95 = center[1]
parameter = {"easting": eLV95,
"northing": nLV95,
"format": "json"}
response = requests.get(url=url, params=parameter)
result = response.json()
eWGS84 = result["easting"]
nWGS84 = result["northing"]
position = [eWGS84, nWGS84]
for i in range (0, steps):
heading = 360.0 / steps * i
if heading == 0:
alpha = 0
else:
alpha = math.pi/180.0*heading
positions.append(position)
headings.append(heading)
elevations.append(elevation)
pitches.append(pitch)
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print(timestamp + ' |INFO | Calculating camera positions done')
# Save the camera parameters in a file
file = open('cameras.pkl', 'wb')
pickle.dump(positions, file)
pickle.dump(headings, file)
pickle.dump(elevations, file)
pickle.dump(pitches, file)
pickle.dump(mode, file)
file.close()
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print(timestamp + ' |END | Create Cameras Round')