OCR: How to C#
Using OCR SDK for C#.NET
Sample C#.NET Codes
Basic SDK Concept
  |  
Home ›› XImage.OCR ›› C# OCR: Basic SDK Concept

C#: Basic OCR SDK Concept


Introduce C# Developers Three Basic Concepts of RasterEdge OCR SDK for .NET




To help C# developers have better understanding of of our XImage.OCR for .NET, we provide more details for basic OCR SDK concepts on this page. In all, three C# OCR classes will be talked, including OCRHandle, OCRRecSetting, and OCRPage. For each class, we explain all designed public methods and properties.




C# OCRHandle Class



This C# class is the utility class.


Public Methods


Import(override +5)

Create an OCRDocument/OCRPage instance in C# programming by inputting image.

Reset

Reset recognizing setting and output setting to default values.

SetTrainResourcePath

Change the path of those training resource files. The resource path should be the path of folder that include those trained data files (with file extension ".traineddata"). Default: all trained data files should be put in a folder called "Source", and this "Source" folder MUST BE put in the same dictionary as the assemblies.

Translate(override +3)

Recognize all characters in images, and save the results into PDF/SVG/TXT file/stream.


Public Property


Settings

Set/get the settings applying in C# OCR recognition process.




C# OCRRecSetting Class



C# users can set OCR recognition setting of OCR entities in any level, namely OCRHandler, OCRDocument, OCRPage and OCRZone. The setting in the lower level entity overrides that in the higher one. Below is a table to describe all the methods in OCRRecSetting class.


Public Methods


Enabled

Specify if this setting is valid or not. Default is false for all OCR entities except for OCRHandler.

LanguagesEnabled

Specify the languages used in C# OCR recognition.

Tradeoff

The value could be Default/Fast/Accurate.

Fast: spend the least time to scan source image.

Accurate: get the most accurate OCR result.

Default: balance between time consuming and accuracy.

DefaultFilter


These properties would define a set of valid characters. The result characters MUST BE in this set.

AdditionalFilters

DefaultUnkownChar

If a character is not a valid character, it would be replaced by this DefaultUnkownChar.




C# OCRPage Class




OCRPage may contain a collection of OCRZone, which will not recognize unless the property RecognizeZoneOnly is true. C# developers can get an instance by invoking OCRHanle.Import or OCRDocument.GetPage.


Public Methods


CreateZone

Create a zone in the page.

GetZoneText

Get C# OCR recognition result of the zone by its index.

Recognize

Recognize the page. Return 0 if recognition is success.

SaveTo(override +2)

Convert recognized results to PDF/SVG/TXT format and save into a file/stream. You MUST invoke Recognize before calling this method.


Public Properties


RecSettings

Set/get settings in page recognition process.

If this setting is disabled (property Enabled is false), it would use the settings defined in OCRHanle.setting during page recognition process.

OutputSettings

Set/get the settings of the output (Not Implemented Yet).

Width

Page width.

Height

Page height.

RecognizeZoneOnly

If this property is true, only the zones in the page will be recognized during page recognizing process. Otherwise, the whole page will be processed.

Zones

Return the zones in the page.



OCRZone will use OCRPage.RecSetting in C# OCR recognition process if RecSetting.Enabled of themselves is false.