This article takes C# and VB.NET code as an example to introduce how to scan and read the text in the picture. The sample code in the article is introduced in detail, which is helpful for us to learn C#. Interested friends can follow the editor to learn together.
( Reprinted from Script House: https://www.jb51.net/article/232085.htm#_label0 )
Environment configuration
This article takes C# and VB.NET code as an example to introduce how to scan and read the text in the picture.
The program environment is as follows:
- Visual Studio version requirements are not lower than 2017
- Image scanning tool: Spire.OCR for .NET
- Image format: png (the image format here supports JPG, PNG, GIF, BMP, TIFF and other formats)
- Scanned image text: Chinese (English, Japanese, Korean, German, French, etc. can also be supported)
- .NET Framework 4.6.1
The following are the specific steps and operation methods.
Steps
Step 1. Create a .NET Framework console application in Visual Studio.
Step 2. Right-click the program project properties and set the target platform to x64.
This step is necessary because Spire.OCR for .NET only supports 64-bit operating systems.
Step 3. Install Spire.OCR for .NET in the VS program. (★ It is recommended to install through Nuget )
In [Solution Explorer], right-click [References] and select [Manage NuGet Packages]
In the opened interface, click the [Browse] tab, and enter [Spire.OCR] in the search box. Click【Install 】
Step 4. After the installation is complete, find the packages folder generated by default under the installation path, and copy the 6 dll files under the folder path:
F:\VS2017Project\ScanImageAndReadCharacter_OCR\packages\Spire.OCR.1.8.0\runtimes\win-x64\native
Copy it to the running path of the VS program project:
F:\VS2017Project\ScanImageAndReadCharacter_OCR\ScanImageAndReadCharacter_OCR\bin\Debug
Call the API interface to scan and read the text in the picture
After completing the above steps, execute the following program code to read the text on the picture:
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
VB.NET
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Image scanning and reading results:
Precautions
1. Only supports 64-bit platforms and systems
2. Only 1.8.0 and later versions support .NET Framework
Reprinted script house: https://www.jb51.net/article/232085.htm#_label0