Search

Atalasoft Knowledge Base

HOWTO: Deploy a project using OCR

Administrator
DotImage

NOTE

This information is specific to DotImage at the time it was written and may change slightly in future versions.

Every OcrEngine has different requirements in terms of how it is deployed. Atalasoft has tried to formalize this process as much as possible as well as to provide guidelines on the mechanism for deployment. Licensing is covered in another topic. This topic covers how to ensure that an OcrEngine will be able to start and will be able to find its own resources.

In your SDK installation, you will find a folder named "OcrResources". This folder is the general folder for all supported OCR engines. Within it you will see a structure like this:

EngineManufacturer1
    

EngineManufacturer2
    
...
EngineManufacturerN
...

In general, most of the handling of loading and locating resources is managed by Atalasoft or by the engine itself and does not require work by the client, but in custom situations, there may be work to be done by the client to handle this.

To sort this out, let's start with a few definitions:

Definitions

  • engine resources folder - this is the folder which contains the OCR Engine's resource files
  • OCR resources folder - the top level folder of all OCR Engine resources, called "OcrResources"
  • application folder - the folder where your application is installed
  • assembly folder - the folder which contains the dotImage assembly files (ie, Atalasoft.dotImage.Ocr.dll), this may be the same as the application folder
  • SDK folder - the folder which contains all the dotImage assembly files as installed as part of the dotImage SDK. This folder is typically C:\Program Files (x86)\Atalasoft\DotImage \bin
  • engine module - an engine supplied dll that provides engine functionality

In order to run, some engines have two requirements: an engine module for some portion of OCR functionality and resource files that are used to configure the engine or otherwise provide necessary data or services. This may include such things as dictionaries, grammar rules, glyph shapes, neural networks and so on.

Engines that require engine modules typically need to have those modules loaded before attempting to construct a class that requires them. This presents an interesting issue in that the assembly that uses the engine module should contain the knowledge of how to find the engine module, but the engine module needs to be loaded before the module that should be able to find it is loaded.

Atalasoft tries to handle this for you when possible so you don't have to worry about it, but there are some cases where this simply isn't possible.

Options for the Developer

The developer can choose to leave the engine module in the ocr resources folder as shipped. If this is the case, then the developer must put the OCR resources folder within the assembly folder. Alternately, the developer can put the OcrResources folder in any location, but it is the developer's responsibility to load the dll. If the OCR resources folder is not in the assembly folder, the developer is required to pass its location in to the ExperVisionEngine constructor.

The developer can choose to move the engine module out of the ocr resources folder. In this case, if the engine module is put into the application folder or the assembly folder, then it should be located automatically. If the engine module is located somewhere else it is the developer's responsibility to locate it and load it. If the OCR resources folder is within the assembly folder, the developer can pass in null to the engine constructor for the path, otherwise the developer must pass the location in.

AbbyyEngine (DotImage 10.7 and newer)

AbbyyEngine OCR resources must be downloaded separately. We don't ship them with the SDK because the resources are rather large (about 3/4 of a GiB). In order to deploy an app with AbbyyEngine, you must also deploy our AbbyyResources

  1. Download the appropriate AbbyyResources zip file Atalasoft.ABBYY.Resources.zip:
    Download Abbyy 11.1 Resources here
    Download Abbyy 11.0 Resources here
    Download Abbyy 10.7 Resources here
  2. Create a folder where you will store the Abbyy Resources
    NOTE: the Atalasoft.ABBYY.Resources.zip does not create a container directory when you unzip, so make the folder you want to use such as:
    C:\Program Files (x86)\Atalasoft\DotImage 11.1\bin\OcrResources\ABBYY
  3. Copy the Atalasoft.ABBYY.Resources.zip folder into that directory and unzip
  4. Ensure that in your application code, your AbbyyLoader is pointing at the folder where you have unzipped the Abbyy Resources
    EX:
    string ocrResourcePath= @"C:\Program Files (x86)\Atalasoft\DotImage 11.0\bin\OcrResources\Abbyy";
    AbbyyLoader loader = new AbbyyLoader(ocrResourcePath);
    

    Please see INFO: AbbyyEngine - Overview for more details on the AbbyyEngine

GlyphReaderEngine (v4.0 for DotImage 10.3.1 and newer)

NOTE:: this section is referring to GlyphReader v4.0 which is found in DotImage 10.3.1 and newer. Please see the section on GlyphReader Engine v3.0 for older versions

The 4.0 GlyphReader engine requires an OcrResources folder with a GlyphReader sub-directory which itself has a v4.0 sub-directory containing the following 3 files and two folders:

  • TOCR40.gar
  • TOCR40.gnp
  • TOCR40.teh
  • \x64
  • \x86

the x86 and x64 folders each contain the following files (of the correct "bitness")

  • GlyphReader.dll
  • GlyphReader.ini
  • GlyphReaderEngine.exe

You will need to create a folder called OcrResources in your bin directory of your application, and copy the GlyphReader folder from

C:\Program Files (x86)\Atalasoft\DotImage 10.x\bin\OCRResources\

into it (where x is the version of DotImage such as 10.3, 10.4, 10.5 and so on)

You will also need to have a reference in your project to Atalasoft.dotImage.Ocr.GlyphReader.dll, but set the CopyLocal property to false, you then will need to physically place a copy of the correct version (x86/x64 and 2.0/4.0 for bitness and .NET framework respectively) of Atalasoft.dotImage.Ocr.GlyphReader.dll in the OCRResources folder

So, your application's bin folder will have

  • bin\OCRResources\Atalasoft.dotImage.Ocr.GlyphReader.dll
  • bin\OCRResources\GlyphReader\
  • bin\OCRResources\GlyphReader\\OCRResources\GlyphReader\v4.0\
  • bin\OCRResources\GlyphReader\v4.0\TOCR40.gar
  • bin\OCRResources\GlyphReader\v4.0\TOCR40.gnp
  • bin\OCRResources\GlyphReader\v4.0\TOCR40.teh
  • bin\OCRResources\GlyphReader\v4.0\x64\
  • bin\OCRResources\GlyphReader\v4.0\x64\GlyphReader.dll
  • bin\OCRResources\GlyphReader\v4.0\x64\GlyphReader.ini
  • bin\OCRResources\GlyphReader\v4.0\x64\GlyphReaderEngine.exe
  • bin\OCRResources\GlyphReader\v4.0\x86\
  • bin\OCRResources\GlyphReader\v4.0\x86\GlyphReader.dll
  • bin\OCRResources\GlyphReader\v4.0\x86\GlyphReader.ini
  • bin\OCRResources\GlyphReader\v4.0\x86\GlyphReaderEngine.exe

GlyphReaderEngine (v3.0 for DotImage 10.3.0 and lower)

NOTE:: This section is referring to GlyphReader v3.0 which is found in DotImage 10.3.0 and older... as of 10.3.1 and newer, we use GlyphReader 4.0 which has a significantly different deployment profile.

The GlyphReaderEngine requires the following resource files:

  • GlyphReader.dll
  • GlyphReader.ini
  • GlyphReaderEngine.exe
  • TOCR32.gar
  • TOCR32.n3s
  • TOCR32.qnp
  • TOCR32.teh

They are located by default in:

SDK folder\OcrResources\GlyphReader\v3.0\

Due to the architecture of the GlyphReader engine, to specify a location other than a default search path such as System32, you'll need to create an instance of the OcrResourceLoader or GlyphReaderLoader in a static constructor before any OCR code is loaded. This is the case even if the resources are in the assembly folder. There you can specify an alternate location of the resources if desired.

GlyphReaderLoader loader = new GlyphReaderLoader( "PathToFolderContainingGlyphReaderResources" );

NOTE: When deploying GlyphReader to a Web Application, Web Service, or WCF service you need to load by Reflection.

Please see HOWTO: Load GlyphReaderEngine by Reflection

Tesseract3Engine

The Tesseract3Engine replaces TesseractEngine

More inf soon - in the meantime plea contact support for assistance with this engine

TesseractEngine (OBSOLETE)

NOTE: TesseracEngine was completely removed from our SDK in 11.1 - please move to Tesseract3Engine if you wish to continue using Tesseract

The TesseractEngine requires its resource files to be pointed at by an environment variable "TESSDATA_PREFIX". Install the "tessdata" folder to a location on the deployment machine and then in your project set the environment variable to the absolute path of "tessdata's" parent folder. You can use this call to accomplish this:

System.Environment.SetEnvironmentVariable("TESSDATA_PREFIX", absolutepath,EnvironmentVariableTarget.User);

RecoStarEngine (OBSOLETE)

NOTE: RecoStarEngine was retired in 10.7 - this information provided for legacy support only

The RecoStar engine requires RecoStar Resources which are not distributed with DotImage by default, but which may be downloaded from here:

10.6.1 and newer:
http://www.atalasoft.com/download/Atalasoft.RecoStarResources.zip

10.6.0 and older:
http://www.atalasoft.com/download/DotImage-RecoStarResources.zip

Once downloaded, you can unzip (it will create a folder called RecoStar with a 7.2 (new as of 10.6.1 and newer... for older versions it will be 5.0) sub-directory and place several files and folders under there) and place the entire RecoStar folder into the default location ( C:\Program Files (x86)\Atalasoft\DotImage 10.x\bin\OCRResources\ )

You'll need a RecoStar Loader as well:

RecoStarLoader loader = new RecoStarLoader( "PathToFolderContainingRecoStar" );

Original Article:
Q10141 - HOWTO: Deploy a project using OCR

Details
Last Modified: Last Week
Last Modified By: Administrator
Type: HOWTO
Article not rated yet.
Article has been viewed 12 times.
Options
Also In This Category