OCR (Optical Character recognition): Optical character recognition refers to the process of analyzing and identifying the text in a picture file and acquiring it.
Tesseract: Open source OCR recognition engine, the initial tesseract engine was developed by HP Labs, later contributed to the open source software industry, and then improved by Google, eliminating bugs, optimizing, republishing. The current version is 3.02.
The project address is: HTTPS://GITHUB.COM/TESSERACT-OCR
The Windows command line uses the TESSERACT-OCR engine to identify the verification code:
1, download install TESSERACT-OCR engine (3.0 version + only support Chinese recognition)
Tesseract-ocr-setup-3.01-1.exe
After download, install, by default, the installer will give you to configure the system environment variables to point to the installation directory (then you can run tesseract in any directory through the DOS interface). After the installation is complete, the directory is as follows:
Appendix:
The Tessdata directory contains the language font files, and the files that correspond to the parameters that may be used in the command line interface. This installer contains the English font by default.
If you want to be able to identify Chinese, you can download the corresponding language font file to Http://code.google.com/p/tesseract-ocr/downloads/list.
Simplified Chinese font file is: http://tesseract-ocr.googlecode.com/files/chi_sim.traineddata.gz after the download is complete, and then cut the file to the Tessdata directory to go down.
2. Using the TESSRACT-OCR engine to identify the verification code
Open the DOS interface and enter tesseract:
If the output appears as above, the installation is normal.
I have prepared a verification code code.jpg placed in the D packing directory,:
The result is:
Appendix:
Usage:tesseract imagename outputbase [-L lang] [-PSM 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.
Ten = Treat the image as a single character.
-L lang AND/OR-PSM pagesegmode must occur before anyconfigfile.
Tesseract imagename outputbase [-L lang] [-PSM pagesegmode] [configfile ...]
Tesseract Picture name output file name-L font file-PSM Pagesegmode profile
For example:
Tesseract code.jpg result-l CHI_SIM-PSM 7 Nobatch
-L Chi_sim means to use the Simplified Chinese font (need to download the Chinese font file, extracted, stored in the Tessdata directory, the font file name extension. raineddata Simplified Chinese font file name: chi_sim.traineddata)
-PSM 7 tells Tesseract that the code.jpg picture is a line of text This parameter can reduce the recognition error rate. Default is 3
The ConfigFile parameter value is the file name under the Tessdata\configs and Tessdata\tessconfigs directories
TESSERACT-OCR Engine Installation