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