OCR (Optical Character Recognition): Optical Character Recognition refers to the process of analyzing, recognizing, and obtaining texts in image files.
Tesseract: an open-source OCR recognition engine. In the early stage, the Tesseract engine was developed by the HP lab. Later, it was contributed to the open-source software industry. Then it was improved through Google to eliminate bugs, optimize and re-release it. This version is 3.01.
Project address: http://code.google.com/p/tesseract-ocr
The Windows command line uses the Tesseract-OCR engine to identify the verification code:
1. download and install the Tesseract-OCR engine (Version 3.0 + supports Chinese recognition)
Tesseract-ocr-setup-3.01-1.exe
After the download, install the tool. By default, the installer configures the system environment variables to point to the installation directory (you can run tesseract in any directory on the DOS interface ). After the installation is complete, the directory is as follows:
Appendix:
The tessdata directory stores the language font file, which corresponds to the parameters that may be used in the command line interface. This installer contains the English font by default.
To recognize Chinese characters, go to http://code.google.com/p/tesseract-ocr/downloads/listto download the library file of the corresponding language.
Simplified Chinese font file: http://tesseract-ocr.googlecode.com/files/chi_sim.traineddata.gz download after decompression, and then cut the file to the tessdata directory on it.
2. Use the tessract-OCR engine to identify the verification code
Open the DOS interface and enter tesseract:
If the above output is displayed, the installation is normal.
I copied a verification code code.jpg to the root directory of drive D ,:
Result:
Appendix:
Usage: Tesseract imagename outputbase [-l Lang] [-SMS pagesegmode] [configfile...]
Pagesegmode values are:
0 = orientation and script detection (OSD) only.
1 = automatic page segmentation with OSD.
2 = automatic page segmentation, but no OSD, or OCR
3 = fully automatic page segmentation, but no OSD. (default)
4 = assume a single column of text of variable sizes.
5 = assume a single uniform block of vertically aligned text.
6 = assume a single uniform block of text.
7 = treat the image as a single text line.
8 = treat the image as a single word.
9 = treat the image as a single word in a circle.
10 = treat the image as a single character.
-L Lang and/or-PSM pagesegmode must occur before anyconfigfile.
Tesseract imagename outputbase [-l Lang] [-SMS pagesegmode] [configfile...]
Tesseract image name output file name-l font file-SMS pagesegmode configuration file
For example:
Tesseract code.jpg result-l chi_sim-PSM 7 nobatch
-L chi_sim indicates that the simplified Chinese font is used (you need to download the Chinese font file, decompress it, and store it in the tessdata directory. The extension of the font file is. raineddata. The simplified Chinese font file name is: chi_sim.traineddata)
-PSD 7 indicates that the Tesseract code.jpg image is a line of text. This parameter can reduce the recognition error rate. The default value is 3.
The configfile value is the file name under the tessdata \ configs and tessdata \ tessconfigs directories.
PS: in the original text of the Red-Sm, it is-PSD.