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