Python image recognition

Source: Internet
Author: User

This is one of the simplest image recognition, and the image is loaded directly using a Python recognition engine to identify Pass the numbers in the picturePytesseract.image_to_string (image) after recognition, the results are stored in a local TXT file
1 #-*-encoding:utf-8-*-2 Import pytesseract 3 from PIL import Image 4  5 class Getimagedate (object): 6     def m (self) : 7         image = Image.open (u "a.png") 8         Text = pytesseract.image_to_string (image) 9         return text10     def Saveresulttodocument (self):         text = SELF.M ()         f = open (U "Verification.txt", "W")         print text15         f.write (str (text))         F.close () + G = getimagedate () g.saveresulttodocument ()
specifically want to implement the above code needs to install two packages and an engine Install PYTHON,PIP and configure environment variables prior to installation .All packages are installed via Pip and need to be done in Windows PowerShell and are in the C:\Python27\Scripts directory 1. First Package: PytesseractPip Install Pytesseract If there is an installation error, you can change the command to Pip.exe install when the installation is not possible. Pytesseract to install if the PIP is modified to pip.exe the installation succeeds, then all pips below will need to be changed to Pip.exe 2. Second package: PIL installationPip install PIL If it fails, you can modify PIP install PILLOW as follows 3. Install the recognition engine TESSERACT-OCR https://github.com/tesseract-ocr/tesseractDownload TESSERACT-OCR, install the default installation after installation, you need to configure environment variables, add TESSERACT-OCR installation address after system variable path C:\Program Files (x86) \TESSERACT-OCR ; Run the above code after the installation is complete, you will find an error, at this time need This concludes

Python image recognition

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.