Tutorial: Create Your First OCR Project for a Console Application
In this tutorial, you will configure a C# or VB.NET project for a console application and use ImageGear .NET OCR capabilities to load an image, OCR and export the data to the console.
The following tutorial refers specifically to 64-bit installations; for 32-bit installations:
- Your project should already be set to compile to target Debug and x86, and you should have the directory: $YOURLOCALPROJ\bin\x86\Debug\.
- Throughout these instructions, replace x64 with x86.
- The 32-bit ImageGear binaries are found in $INSTALLDIR\Bin\x86
Using the desired version of Visual Studio (2010 or later):
- Create a new "Console App (.NET Framework)" project, using C# or VB.NET, and name the project: my_first_OCR_project
- If you downloaded ImageGear .NET 64-bit, using the Configuration Manager, create a new project platform (if you don't have one already) for x64. Make sure your project is set to compile targeting Debug and x64. Confirm you now have $YOURLOCALPROJ\bin\x64\Debug\, and if it's not there, create it.
- Add references and required resources into your projects in one of the following ways:
- Copy all files (and folders) inside $INSTALLDIR\Bin\x64 to your local output bin directory in your project (i.e., $YOURLOCALPROJ\bin\x64\Debug\ ).
- Add the following references to your project from $YOURLOCALPROJ\bin\x64\Debug\:
- ImageGear.Formats.Common.dll
- ImageGear.Formats.SimplifiedMetadata.dll
Your output target directory (output path) should be set to $YOURLOCALPROJ\bin\x64\Debug\
- At this point all necessary assembly references and resources have been added to the project.
Add the following using statements to the top of the file.
- Add the following code to create a private method to OCR, and export the data to the console. This code sets up licensing, initializes the ImageGear Formats assembly and initializes the OCR engine.
- Add the following code to load the image, and set the ImGearRecPage.
- Add the following code to output the data to the console.
- Add the following code to dispose the igOCR and page object.
- Finally, add in the Main function, the OCRFile method passing in your image, and output to the console. Replace "C:\PATHTOOCR\FILENAME.tif" with the path to your image file to recognize.