I have almost completed a sucessfull program as the code works with a sample file, but I can't get to edit the photograph of my meter in order for OCR to work.
I find my output image to be quite near a working mode, however I don't know what else I can do to the image to get it working.
This is my code:
import pytesseract
import Image
import sys
from PIL import Image
from PIL import ImageFilter
import PIL
import PIL.ImageOps
image_file_ocr = 'ocr_output.jpg'
image_file = 'image_original.jpg'
#image_file = 'ocr2.jpg'
#image_file = 'sample1.jpg'
#image_file = 'sample2.jpg'
#image_file = 'sample3.jpg'
#image_file = 'sample4.jpg' # texto largo
#image_file = 'sample5.jpg' #image_text = "1234567890"
print image_file
# LOAD THE IMAGE
#image = Image.open('sample5.jpg')
image = Image.open(image_file) # open colour image
image = image.convert('L') # convert image to monochrome - this works
#image = image.convert('1') # convert image to black and white
image = image.rotate(-90)
# EDIT THE IMAGE
w, h = image.size
#image = image.crop((0, 30, w, h-30))
image = image.crop((350, 680, 1100, 770))
image.filter(ImageFilter.SHARPEN)
image = PIL.ImageOps.invert(image)
image.save(image_file_ocr,'jpeg')
# PROCESS THE IMAGE
print "\n\nProcessing image: " + image_file_ocr
image = Image.open(image_file_ocr)
print "Process method 1:"
text = pytesseract.image_to_string(image, config='outputbase digits')
print text
print "Process method 2:"
text = pytesseract.image_to_string(image)
print text
This is my progress so far to process the image
The following image works correctly