2016年1月6日 星期三

2015 python final hw _image detect


  1. Purpose:USing pytesseractan and OCRsoftware with GUI tkinter to recognize text picture to string.
  2. Using software: python
  3. Need to import and installed software

    • python3.4
    • pytesseract(If run in python27 will have some problem)
    •  tkinter
    • pip os
    • PIL
    • easygui
    • cv2
    •  numpy
  1. Context explain:
  • GUI button set:







  •  Reading file absolute address:
  • IF no choosen ITEM:

  • IF  choosen ITEM,convert it as 300*300 and show on carve:

    • resize image:
    • show on carve

  • Use pytesseract to convert img to string


  • Save result as txt file


  • Transform colored img to black and white image and save it.

  1. Export to exe:

    • downloads py2exe and install
    • notice:if run in window the last one should write
      • from distutils.core import setup
      • import py2exe
      • setup(windows=["final.py"]) #final.py is your file name
    • setup file:
  1. exe file:(解壓縮後執行 final.exe)
  1. python file:
  1. PPT:PPT
  2. pytesseract source code

    https://github.com/madmaze/pytesseract
  3. PIL image形式:
    • <PIL.Image.Image image mode=RGB size=200x60 at 0xC025D0>
    • array;
      • array([[[255, 191, 219],
      •         [253, 180, 209],
      •         [253, 188, 218],
      •         ..., 
      •         [251, 190, 224],
      •         [251, 190, 224],
      •         [253, 189, 224]],

      •        [[255, 197, 219],
      •         [249, 195, 218],
      •         [244, 199, 222],
      •         ..., 
      •         [250, 190, 224],
      •         [251, 190, 224],
      •         [253, 189, 224]],

      •        [[135,  97, 110],
      •         [155, 118, 135],
      •         [154, 123, 141],
      •         ..., 
      •         [250, 190, 224],
      •         [250, 190, 224],
      •         [251, 190, 224]],

      •        ..., 
      •        [[248, 191, 224],
      •         [248, 191, 224],
      •         [248, 191, 224],
      •         ..., 
      •         [248, 191, 224],
      •         [248, 191, 224],
      •         [248, 191, 224]],

      •        [[248, 191, 224],
      •         [248, 191, 224],
      •         [248, 191, 224],
      •         ..., 
      •         [248, 191, 224],
      •         [248, 191, 224],
      •         [248, 191, 224]],

      •        [[248, 191, 224],
      •         [248, 191, 224],
      •         [248, 191, 224],
      •         ..., 
      •         [248, 191, 224],
      •         [248, 191, 224],
      •         [248, 191, 224]]], dtype=uint8)
  • reference:
    • https://saxenarajat99.wordpress.com/2014/10/04/optical-character-recognition-in-python/
    • http://www.apkapps.link/questions/212476/convert-rgb-to-black-or-white
    • http://www.pythonforbeginners.com/files/reading-and-writing-files-in-python
    • https://www.youtube.com/watch?v=kyoGfnLm4LA
    • http://okfnlabs.org/blog/2013/10/17/python-guide-for-file-formats.html
    • http://stackoverflow.com/questions/51520/how-to-get-an-absolute-file-path-in-python
    • http://stackoverflow.com/questions/18950668/os-path-split-changing-file-name-with-out-compromising-the-path

沒有留言:

張貼留言