Results 1 to 1 of 1

Thread: [Python] Fast Neo OCR

  1. #1
    Zachafer's Avatar
    Joined
    Dec 2011
    Posts
    1,235
    Userbars
    11
    Thanks
    769
    Thanked
    1,466/678
    DL/UL
    98/0
    Mentioned
    512 times
    Time Online
    24d 13h 9m
    Avg. Time Online
    8m

    [Python] Fast Neo OCR

    Code:
    from PIL import Image
    
    #http://www.gossamer-threads.com/lists/python/python/507073#507073
    def neoOCR(im):
    	im = im.convert("L") # convert to grayscale
    	lo, hi = im.getextrema() # find darkest pixel value
    	lo = im.point(lambda x: x == lo) # highlight darkest pixel value
    	x, y, _, _ = lo.getbbox() # locate uppermost/leftmost dark pixel
    	return x, y
    Code:
    im = Image.open("C:\\cap.jpeg");
    print(neoOCR(im))
    Python 2.x PIL: (you need an account to see links)

    Python 3.x doesn't have PIL... Christoph Gohlke ported it to 3.x, named it pillow, and has a binary for it here: (you need an account to see links)

  2. The Following 4 Users Say Thank You to Zachafer For This Useful Post:

    DarkByte (10-02-2013),j03 (10-10-2013),Rambo (03-13-2014),ritzwin (11-11-2013)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •