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