-
Notifications
You must be signed in to change notification settings - Fork 0
/
digi_zoom_convert.py
executable file
·106 lines (89 loc) · 4.07 KB
/
digi_zoom_convert.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
#!/usr/bin/python
from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
def convert_to_full_frame_focal_length(sensor_focal_length, sensor_type="apsc", is_canon=False):
if(sensor_type == "apsc"):
if(is_canon):
full_frame_focal_length = sensor_focal_length * 1.6
else:
full_frame_focal_length = sensor_focal_length * 1.5
elif(sensor_type == "apsh"):
if(is_canon):
full_frame_focal_length = sensor_focal_length * 1.3
else:
full_frame_focal_length = sensor_focal_length * 1.35
elif(sensor_type == "mft"):
full_frame_focal_length = sensor_focal_length * 2.0
elif(sensor_type == "cxf"):
full_frame_focal_length = sensor_focal_length * 2.7
elif(sensor_type == "q7f"):
full_frame_focal_length = sensor_focal_length * 4.55
else:
full_frame_focal_length = sensor_focal_length * 1.0
full_frame_focal_length = '{0:g}'.format(full_frame_focal_length)
if isinstance(full_frame_focal_length, int):
full_frame_focal_length = int(full_frame_focal_length)
elif isinstance(full_frame_focal_length, float):
full_frame_focal_length = float(full_frame_focal_length)
else:
full_frame_focal_length = str(full_frame_focal_length)
return full_frame_focal_length
def convert_from_full_frame_focal_length(full_frame_focal_length, sensor_type="apsc", is_canon=False):
if(sensor_type == "apsc"):
if(is_canon):
sensor_focal_length = full_frame_focal_length / 1.6
else:
sensor_focal_length = full_frame_focal_length / 1.5
elif(sensor_type == "apsh"):
if(is_canon):
sensor_focal_length = full_frame_focal_length / 1.3
else:
sensor_focal_length = full_frame_focal_length / 1.35
elif(sensor_type == "mft"):
sensor_focal_length = full_frame_focal_length / 2.0
elif(sensor_type == "cxf"):
sensor_focal_length = full_frame_focal_length / 2.7
elif(sensor_type == "q7f"):
sensor_focal_length = full_frame_focal_length / 4.55
else:
sensor_focal_length = full_frame_focal_length / 1.0
sensor_focal_length = '{0:g}'.format(sensor_focal_length)
if isinstance(sensor_focal_length, int):
sensor_focal_length = int(sensor_focal_length)
elif isinstance(sensor_focal_length, float):
sensor_focal_length = float(sensor_focal_length)
else:
sensor_focal_length = str(sensor_focal_length)
return sensor_focal_length
def get_optical_zoom(maximum_focal_length, minimum_focal_length):
optical_zoom = maximum_focal_length / minimum_focal_length
optical_zoom = '{0:g}'.format(optical_zoom)
if isinstance(optical_zoom, int):
optical_zoom = int(optical_zoom)
elif isinstance(optical_zoom, float):
optical_zoom = float(optical_zoom)
else:
optical_zoom = str(optical_zoom)
return optical_zoom
print(str(get_optical_zoom(247, 3.8)))
def get_minimum_focal_length(maximum_focal_length, optical_zoom):
minimum_focal_length = maximum_focal_length / optical_zoom
minimum_focal_length = '{0:g}'.format(minimum_focal_length)
if isinstance(minimum_focal_length, int):
minimum_focal_length = int(minimum_focal_length)
elif isinstance(minimum_focal_length, float):
minimum_focal_length = float(minimum_focal_length)
else:
minimum_focal_length = str(minimum_focal_length)
return minimum_focal_length
print(str(get_minimum_focal_length(247, 65)))
def get_maximum_focal_length(minimum_focal_length, optical_zoom):
maximum_focal_length = minimum_focal_length * optical_zoom
maximum_focal_length = '{0:g}'.format(maximum_focal_length)
if isinstance(maximum_focal_length, int):
maximum_focal_length = int(maximum_focal_length)
elif isinstance(maximum_focal_length, float):
maximum_focal_length = float(maximum_focal_length)
else:
maximum_focal_length = str(maximum_focal_length)
return maximum_focal_length
print(str(get_maximum_focal_length(3.8, 65)))