Project

General

Profile

Actions

Codes » History » Revision 20

« Previous | Revision 20/33 (diff) | Next »
Kentaro HARATAKE, 01/16/2025 02:02 PM


Codes

Wiki | About_Us | Project_Overview | UML_Diagram | Codes

```
#!/usr/bin/env python
  1. coding: utf-8
    from distutils.util import strtobool

class Config(object):
def init(self, pnd, prd, w, h, p, gamma, overlapWidth, side, isDual, monitorWidth):
"""!
Constructor for Config class.

@param pnd: Projection distance.
@param prd: Projector distance.
@param w: Image width.
@param h: Image height.
@param p: Path to the image.
@param gamma: Gamma value for adjustments.
@param overlapWidth: Width of the overlap area.
@param side: Side of projection.
"""
self.__projection_distance = pnd
self.__projector_diatance = prd
self.__img_width = w
self.__img_height = h
self.__img_path = p
self.__gamma = gamma
self.__overlapWidth = overlapWidth
self.__side = side
self.__isDualMonitor = isDual
self.__monitorWidth = monitorWidth
def getProjectionDistance(self):
"""!
Retrieve the projection distance.
@return: Projection distance as an integer.
"""
return int(self.__projection_distance)
def getProjectorDistance(self):
"""!
Retrieve the projector distance.
@return: Projector distance as an integer.
"""
return int(self.__projector_diatance)
def getImgWidth(self):
"""!
Retrieve the image width.
@return: Image width as an integer.
"""
return int(self.__img_width)
def getImgHeight(self):
"""!
Retrieve the image height.
@return: Image height as an integer.
"""
return int(self.__img_height)
def getImgPath(self):
"""!
Retrieve the image path.
@return: Image path as a string.
"""
return str(self.__img_path)
def getGamma(self):
"""!
Retrieve the gamma value.
@return: Gamma value as a float.
"""
return float(self.__gamma)
def getOverlapWidth(self):
"""!
Retrieve the overlap width.
@return: Overlap width as an integer.
"""
return int(self.__overlapWidth)
def getSide(self):
"""!
Retrieve the side of projection.
@return: Side as a string.
"""
return str(self.__side)
def getIsDualMonitor(self):
return bool(strtobool(self.__isDualMonitor))
def getMonitorWidth(self):
return int(self.__monitorWidth)
@staticmethod
def readConfigFile():
"""!
Reads the configuration from a config.ini file and returns a Config object.
@return: Config object with settings loaded from config.ini.
"""
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
__img_path = config["settings"]["imagePath"]
__img_width = config["settings"]["imageWidth"]
__img_height = config["settings"]["imageHeight"]
__projection_distance = config["settings"]["projectionDistance"]
__projector_diatance = config["settings"]["projectorDistance"]
__gamma = config["settings"]["gamma"]
__overlapWidth = config["settings"]["overlapWidth"]
__side = config["settings"]["side"]
__isDualMonitor = config["settings"]["isDualMonitor"]
__monitorWidth= config["settings"]["monitorWidth"]
return Config(__projection_distance, __projector_diatance, __img_width, __img_height, __img_path, __gamma, __overlapWidth, __side, __isDualMonitor, __monitorWidth)
```

Updated by Kentaro HARATAKE 4 months ago · 20 revisions