Monday, 17 April 2017

OCR Using Python

1. Download all these-

i. PIL-1.1.7.win32-py2.7.exe
ii. pytesser_v0.0.1.zip
iii. python-2.7.5.msi
iv. tesseract-ocr-setup-3.02.02.exe















2. Install Python-2.7.5















3. tesseract-ocr-setup-3.02.02  &  PIL-1.1.7.win32-py2.7














4. Extract pytesser_v0.0.1.zip at the same directory as Python         (C:\Python27).















5. Go to C:\Python.Open pytesser.py file on notepad.In 6th line replace "import Image" with "from PIL import Image".Save this file by pressing CTRL+S.




 










6. See the below image for better understanding.















7. All Set. Open IDLE (Python GUI).

   See the below image for better understanding.















8. After opening ODLE (Python GUI) open new window by               pressing CTRL+N.
    Type the below code.

    from PIL import Image

    from pytesser import *
    image_file = 'fnord.tif'  # Image Name
    im = Image.open(image_file)
    text = image_to_string(im)
    text = image_file_to_string(image_file)
    text = image_file_to_string(image_file, graceful_errors=True)
    print "=====output=======\n"
    print text

  Save this file at the same location as Python (C:\Python27) by                   pressing CTRL+S.















9. After Saving this file press f5 key(In case of my HP Laptop            fn+f5) to run your code.

    All Done..!!















10. If everything is OK then it will produce output.
      Note : It supports only .tif  & .jpg images.