text: # https://www.pyimagesearch.com/2017/07/10/using-tesseract-ocr-python/
  
  # import the necessary packages
  from tools import stdo, getTime    # Terminal Info Print Function
  from inspect import currentframe, getframeinfo
  from imageTools import saveImage, deleteImage
  from PIL import Image
  import pytesseract
  import shared   # For shared area
  
  
  def imageToText(img):
      # write the grayscale image to disk as a temporary file so we can
      # apply OCR to it
      stdo(1, "Starting write Image to temp file for OCR...")
      filename = shared.tempList["tempPath"] + shared.tempList["tempImageName"].format( getTime(), "png" )
      saveImage(img, filename)
      stdo(1, "Write temp file as '{}' succesfull...".format(filename) )
  
      # load the image as a PIL/Pillow image, apply OCR, and then delete
      # the temporary file
      """
          Configs of OCR -> https://github.com/tesseract-ocr/tesseract/wiki/ImproveQuality#page-segmentation-method
            0    Orientation and script detection (OSD) only.
            1    Automatic page segmentation with OSD.
            2    Automatic page segmentation, but no OSD, or OCR.
            3    Fully automatic page segmentation, but no OSD. (Default)
            4    Assume a single column of text of variable sizes.
            5    Assume a single uniform block of vertically aligned text.
            6    Assume a single uniform block of text.
            7    Treat the image as a single text line.
            8    Treat the image as a single word.
            9    Treat the image as a single word in a circle.
           10    Treat the image as a single character.
           11    Sparse text. Find as much text as possible in no particular order.
           12    Sparse text with OSD.
           13    Raw line. Treat the image as a single text line,
                  bypassing hacks that are Tesseract-specific.
      """
      stdo(1, "Starting OCR conversion to extract text from Image...")
  
      text = ""
      try:
          text = pytesseract.image_to_string(Image.open(filename), lang="eng", config="--psm 9 -c tessedit_char_whitelist=defghijklmnoprstuw.%")
      except Exception as error:
          stdo(3, "An error occured while OCR Engine runtime -> {}".format( error.__str__() ), getframeinfo(currentframe()) )
      except FileNotFoundError as error:
          stdo(3, "FileNotFoundError error occured while OCR Engine runtime -> {}".format( error.__str__() ), getframeinfo(currentframe()) )
  
      if text != "":
          stdo(1, "Predicted text: " + "\n---\tSTART\t---\n\n" + text + "\n\n---\tEND\t---\n")
      else:
          stdo(2, "Text empty recognition result. ")
  
      try:
          deleteImage(filename)   # Remove temp file
      except Exception as error:
          stdo(3, "An error occured while OCR Engine runtime -> {}".format( error.__str__() ), getframeinfo(currentframe()) )
      except FileNotFoundError as error:
          stdo(3, "FileNotFoundError error occured while OCR Engine runtime -> {}".format( error.__str__() ), getframeinfo(currentframe()) )
  
      return text
  