Text recognition example

This example uses OpenCV to transform the image and Tesseract by Google to perform OCR on an image

Then image is read into a numpy array using OpenCV:

The goal is to know what the villgers are doing which is displayed in the bottom right corner. To aid the ORC the image needs to be cropped and pre-processed. This processing converts the image to greyscale and applies a filter to remove the background, significantly reducing the noise in the image making OCR much easier.

Finally pytesseract which is a Python wrapper for Tesseract can be used to perform ORC on the image. The ORC has been sucsessful with only one error mistaking the 'r' for a 'c' in Miner. On inspection of the cropped and processed image the r does look like a c to the human eye. Optimising the greyscale, blur and threshold paramiters may help to get a better image. Another option would be to crop the image to only the numbers.

Sample usage:

This process can be written into a handy function for future use. Pyautogui could be used for automatically taking screen shots and feeding them into the function