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