1
|
#!/usr/bin/env python
|
2
|
# -*- coding: utf-8 -*-
|
3
|
from distutils.util import strtobool
|
4
|
|
5
|
class Config(object):
|
6
|
def __init__(self, pnd, prd, w, h, p, gamma, overlapWidth, side, isDual, monitorWidth): #self.__overlapWidth = overlapWidth
|
7
|
"""!
|
8
|
Constructor for Config class.
|
9
|
|
10
|
@param pnd: Projection distance.
|
11
|
@param prd: Projector distance.
|
12
|
@param w: Image width.
|
13
|
@param h: Image height.
|
14
|
@param p: Path to the image.
|
15
|
@param gamma: Gamma value for adjustments.
|
16
|
@param overlapWidth: Width of the overlap area.
|
17
|
@param side: Side of projection.
|
18
|
"""
|
19
|
|
20
|
self.__projection_distance = pnd
|
21
|
self.__projector_diatance = prd
|
22
|
self.__img_width = w
|
23
|
self.__img_height = h
|
24
|
self.__img_path = p
|
25
|
self.__gamma = gamma
|
26
|
self.__overlapWidth = overlapWidth
|
27
|
self.__side = side
|
28
|
|
29
|
self.__isDualMonitor = isDual
|
30
|
|
31
|
self.__monitorWidth = monitorWidth
|
32
|
|
33
|
def getProjectionDistance(self):
|
34
|
"""!
|
35
|
Retrieve the projection distance.
|
36
|
|
37
|
@return: Projection distance as an integer.
|
38
|
"""
|
39
|
return int(self.__projection_distance)
|
40
|
|
41
|
def getProjectorDistance(self):
|
42
|
"""!
|
43
|
Retrieve the projector distance.
|
44
|
|
45
|
@return: Projector distance as an integer.
|
46
|
"""
|
47
|
return int(self.__projector_diatance)
|
48
|
|
49
|
def getImgWidth(self):
|
50
|
"""!
|
51
|
Retrieve the image width.
|
52
|
|
53
|
@return: Image width as an integer.
|
54
|
"""
|
55
|
return int(self.__img_width)
|
56
|
|
57
|
def getImgHeight(self):
|
58
|
"""!
|
59
|
Retrieve the image height.
|
60
|
|
61
|
@return: Image height as an integer.
|
62
|
"""
|
63
|
return int(self.__img_height)
|
64
|
|
65
|
def getImgPath(self):
|
66
|
"""!
|
67
|
Retrieve the image path.
|
68
|
|
69
|
@return: Image path as a string.
|
70
|
"""
|
71
|
return str(self.__img_path)
|
72
|
|
73
|
def getGamma(self):
|
74
|
"""!
|
75
|
Retrieve the gamma value.
|
76
|
|
77
|
@return: Gamma value as a float.
|
78
|
"""
|
79
|
return float(self.__gamma)
|
80
|
|
81
|
def getOverlapWidth(self):
|
82
|
"""!
|
83
|
Retrieve the overlap width.
|
84
|
|
85
|
@return: Overlap width as an integer.
|
86
|
"""
|
87
|
return int(self.__overlapWidth)
|
88
|
|
89
|
def getSide(self):
|
90
|
"""!
|
91
|
Retrieve the side of projection.
|
92
|
|
93
|
@return: Side as a string.
|
94
|
"""
|
95
|
return str(self.__side)
|
96
|
|
97
|
def getIsDualMonitor(self):
|
98
|
return bool(strtobool(self.__isDualMonitor))
|
99
|
|
100
|
def getMonitorWidth(self):
|
101
|
return int(self.__monitorWidth)
|
102
|
|
103
|
@staticmethod
|
104
|
def readConfigFile():
|
105
|
"""!
|
106
|
Reads the configuration from a config.ini file and returns a Config object.
|
107
|
|
108
|
@return: Config object with settings loaded from config.ini.
|
109
|
"""
|
110
|
import configparser
|
111
|
config = configparser.ConfigParser()
|
112
|
config.read('config.ini')
|
113
|
|
114
|
__img_path = config["settings"]["imagePath"]
|
115
|
__img_width = config["settings"]["imageWidth"]
|
116
|
__img_height = config["settings"]["imageHeight"]
|
117
|
__projection_distance = config["settings"]["projectionDistance"]
|
118
|
__projector_diatance = config["settings"]["projectorDistance"]
|
119
|
__gamma = config["settings"]["gamma"]
|
120
|
__overlapWidth = config["settings"]["overlapWidth"]
|
121
|
__side = config["settings"]["side"]
|
122
|
__isDualMonitor = config["settings"]["isDualMonitor"]
|
123
|
__monitorWidth= config["settings"]["monitorWidth"]
|
124
|
|
125
|
return Config(__projection_distance, __projector_diatance, __img_width, __img_height, __img_path, __gamma,__overlapWidth, __side, __isDualMonitor, __monitorWidth)
|
126
|
|