The atalasoft OCR engine

Source: Internet
Author: User
Introduction

At Atalasoft, we're excited to unveil the newest addition to our product line, Atalasoft OCR. this suite of objects, now available, provides interfacing to OCR engines in a way that makes integration into your. NET application a snap.

In the classes provided, we offer the best of all possible worlds: a multilayered approach to exposing engine capabilities that gets up and running quickly, yet also allows you to get down to the nitty gritty details that are most important to you.

When using Atalasoft OCR engine in its most basic way, most of the work is in managing the user interface and not the OCR engine.

The following snippet of C # code demonstrates how to convert a set of image files into a single plain text file.

static void Main(string[] args)
{
    // create and initialize the engine
    ExperVisionEngine engine = new ExperVisionEngine(null, null);
    engine.Initialize();
     
    // select a file or set of files
    OpenImageFileDialog openDialog = new OpenImageFileDialog();
    openDialog.Multiselect = true;
    if (openDialog.ShowDialog() == DialogResult.OK) 
    {
        SaveFileDialog saveFileDialog = new SaveFileDialog();
        saveFileDialog.Filter = "Text (*.txt)|*.txt";
        if (saveFileDialog.ShowDialog() != DialogResult.OK)
            return;
        try 
        {
            // translate into a plain text file
            engine.Translate(
                new FileSystemImageSource(openDialog.FileNames, true),
                "text/plain", saveFileDialog.FileName);
        }
        catch (OcrException err) 
        {
            System.Console.WriteLine("Error in OCR: " + err.Message);
        }
    }
    engine.ShutDown();
}

As you can see, the interfacing is simple. you may also notice that the main use of the engine is the Translate method, which will takes a set of images and writes them to a file (or stream) using the given MIME type as the output format. by using the MIME standard to describe output file types, it is easy to ask the engine what output types it can support as well as to augment or replace them!

The OcrEngine maintains a collection of objects that implement an interface called ITranslator. when you request that a set of images are to be translated to an output file format, the engine will select a translator that matches the mime type.

If your task requires you to generate output in a participant format, it is short work to create your own object to translate the recognized text and images into the format that you need. you can add your new translator or take away from the engine's translator collection as you see fit. you can even bypass the translator selection process entirely and simply supply the translator that you want to use.

OCR Engine Events

Through the familiar. NET event mechanic, you can get hooked into every step of document processing, allowing you to finely control how your images are handled. for example, you can request notification during the stage when an image is preprocessed to make it more palatable for the OCR engine, leader you alter what the engine will use for recognition.

In the following C # code snippet, you can see how to hook in your own code to do image preprocessing:

static void Main(string[] args)
{
    // create and initialize the engine
    ExperVisionEngine engine = new ExperVisionEngine(null, null);
    engine.Initialize();

    engine.PagePreprocessing +=
        new OcrPagePreprocessingEventHandler(engine_PagePreprocessing);
}

private static void engine_PagePreprocessing(
    object sender, OcrPagePreprocessingEventArgs e)
{
    // override all options
    e.OptionsOut = 0;

    AtalaImage imageBW;
    // convert to black and white, if needed
    if (e.ImageIn.PixelFormat != PixelFormat.Pixel1bppIndexed)
        imageBW = e.ImageIn.GetChangedPixelFormat(
                                 PixelFormat.Pixel1bppIndexed);
    else
        imageBW = e.ImageIn;

    // Deskew the image
    AutoDeskewCommand deskew = new AutoDeskewCommand();
    AtalaImage imageDeskewed = deskew.ApplyToImage(imageBW);
    if (imageBW != imageDeskewed && imageBW != e.ImageIn)
        imageBW.Dispose();

    // Hand back to the engine
    e.ImageOut = imageDeskewed;
}

As you can see, the amount of work to get hooked in is small, leader you concentrate on the task: processing the image in the way that you want.

The atalasoft OCR objects let you hook into image processing, image segmentation, and output page construction. there are also events to let you track progress of the engine on a page as well as throughout an entire document. this lets you show your users what they need to know.

Contact atalasoft directly for more details, or download a 30-day trial of our OCR engine today.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.