title: Performing OCR of Seven Segment Display images
body: <p>I'm working on performing OCR of energy meter displays: <a href="https://i.stack.imgur.com/06XnZ.jpg" rel="nofollow noreferrer">example 1</a> <a href="https://i.stack.imgur.com/ENLEY.jpg" rel="nofollow noreferrer">example 2</a> <a href="https://i.stack.imgur.com/YKd56.jpg" rel="nofollow noreferrer">example 3</a></p>
  <p>I tried to use tesseract-ocr with the <a href="https://github.com/arturaugusto/display_ocr/tree/master/letsgodigital" rel="nofollow noreferrer">letsgodigital</a> trained data. But the performance is very poor.</p>
  <p>I'm fairly new to the topic and this is what I've done:</p>
  <pre><code>import numpy as np
  import cv2
  import imutils
  from skimage import exposure
  from pytesseract import image_to_string
  import PIL
  
  
  def process_image(orig_image_arr):
  
    gry_disp_arr = cv2.cvtColor(orig_image_arr, cv2.COLOR_BGR2GRAY)
    gry_disp_arr = exposure.rescale_intensity(gry_disp_arr, out_range= (0,255))
  
    #thresholding
    ret, thresh = cv2.threshold(gry_disp_arr,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
    
    return thresh
  
  def ocr_image(orig_image_arr):
    otsu_thresh_image = process_image(orig_image_arr)
    cv2_imshow(otsu_thresh_image)
    return image_to_string(otsu_thresh_image, lang=&quot;letsgodigital&quot;, config=&quot;--psm 8 -c tessedit_char_whitelist=.0123456789&quot;)
  
  img1 = cv2.imread('test2.jpg')
  cnv = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
  text = ocr_image(cnv)
  </code></pre>
  <p>This gives very poor results with the example images. I have a couple of questions:<br />
  How can I identify the four corners of the display? (Edge detection doesn’t seem to work very well)<br />
  Is there any futher preprocessing that I can do to improve the performance?</p>
  <p>Thanks for any help.</p>