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