Support #464 » ConfigureReader.py
| 1 | 
      #!/usr/bin/env python
     | 
  
|---|---|
| 2 | 
      # -*- coding: utf-8 -*-
     | 
  
| 3 | 
      # ˅
     | 
  
| 4 | 
      import configparser  | 
  
| 5 | 
      # ˄
     | 
  
| 6 | 
       | 
  
| 7 | 
      config = configparser.ConfigParser()  | 
  
| 8 | 
      config.read('config.ini')  | 
  
| 9 | 
       | 
  
| 10 | 
      ##
     | 
  
| 11 | 
      # @brief
     | 
  
| 12 | 
      # This function takes image parameter, gets width of image 
     | 
  
| 13 | 
      # and returns the value of the width
     | 
  
| 14 | 
      def getImageWidth(img):  | 
  
| 15 | 
          # ˅
     | 
  
| 16 | 
      return img.shape[1]  | 
  
| 17 | 
          # ˄
     | 
  
| 18 | 
       | 
  
| 19 | 
      ##
     | 
  
| 20 | 
      # @brief
     | 
  
| 21 | 
      # This function takes image parameter, gets height of image 
     | 
  
| 22 | 
      # and returns the value of the height
     | 
  
| 23 | 
      def getImageHeight(img):  | 
  
| 24 | 
          # ˅
     | 
  
| 25 | 
      return img.shape[0]  | 
  
| 26 | 
          # ˄
     | 
  
| 27 | 
       | 
  
| 28 | 
      ##
     | 
  
| 29 | 
      # @brief
     | 
  
| 30 | 
      # This function reads config.ini and returns the value of distance between projecters
     | 
  
| 31 | 
      def getProjectorDistance():  | 
  
| 32 | 
          # ˅
     | 
  
| 33 | 
      return float(config['DEFAULT']['projector_distance'])  | 
  
| 34 | 
          # ˄
     | 
  
| 35 | 
       | 
  
| 36 | 
      ##
     | 
  
| 37 | 
      # @brief
     | 
  
| 38 | 
      # This function reads config.ini and returns the value of width of the projected image
     | 
  
| 39 | 
      def getProjectorImageWidth():  | 
  
| 40 | 
          # ˅
     | 
  
| 41 | 
      return float(config['DEFAULT']['projector_image_width'])  | 
  
| 42 | 
          # ˄
     | 
  
| 43 | 
       | 
  
| 44 | 
      ##
     | 
  
| 45 | 
      # @brief
     | 
  
| 46 | 
      # This function reads config.ini and returns the value of gamma
     | 
  
| 47 | 
      def getGamma():  | 
  
| 48 | 
          # ˅
     | 
  
| 49 | 
      return float(config['DEFAULT']['gamma'])  | 
  
| 50 | 
          # ˄
     | 
  
| 51 | 
       | 
  
| 52 | 
      ##
     | 
  
| 53 | 
      # @brief
     | 
  
| 54 | 
      # This function takes image parameter, reads the image name and returns it
     | 
  
| 55 | 
      def getImageName(img):  | 
  
| 56 | 
          # ˅
     | 
  
| 57 | 
      return img.split('/')[1].split('.')[0]  | 
  
| 58 | 
          # ˄
     | 
  
| 59 | 
       | 
  
| 60 | 
      ##
     | 
  
| 61 | 
      # @brief
     | 
  
| 62 | 
      # This fucntion takes image parameter, compare the name of the image 
     | 
  
| 63 | 
      # and returns boolean depending on the name
     | 
  
| 64 | 
      def isImageLeft(img):  | 
  
| 65 | 
          # ˅
     | 
  
| 66 | 
      if img == 'Left.jpg':  | 
  
| 67 | 
      return True  | 
  
| 68 | 
      elif img == 'Right.jpg':  | 
  
| 69 | 
      return False  | 
  
| 70 | 
          # ˄
     |