Good Morning, Im trying to enhancelocalcontrast to an image in my program BEFORE the image is passed through the OCR engine. Im having some issues with this however, Please see code below & in answer provide example of how to implement this method or similar methods. Where would i include this method & how would i include this method? All code written in C#

Thank you!

private void processImage()
    {
        string imagePath = Path.Combine(Freconfig.GetSamplesFolder(), "mart.jpg");

        // Create recognizer
        ReceiptCapture.IReceiptRecognizer recognizer = engineLoader.Engine.CreateReceiptRecognizer();

        try
        {
            // Add image file to recognizer
            displayMessage("Loading image...");
            recognizer.AddImageFile(imagePath, null);

            // Recognize document
            displayMessage("Recognizing...");
            recognizer.Process(null);

            // Save results
            displayMessage("Saving results...");

            // Export the first recognized receipt
            if (recognizer.Receipts.Count > 0)
            {
                string exportPath = Path.Combine(Freconfig.GetSamplesFolder(), "ReceiptCapture.xml");
                recognizer.Receipts[0].ExportToXml(exportPath, null);

                // Open it in an external program
                System.Diagnostics.Process.Start(exportPath);
            }
        }
        catch (Exception error)
        {
            MessageBox.Show(this, error.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        finally
        {
            // Close recognizer
            recognizer.Close();
        }
    }

asked 29 Jun '16, 16:06

persaudJon's gravatar image

persaudJon
216


Please add the following lines after adding the image to recognizer and before the receipt processing:

// Add image file to recognizer
...

ReceiptCapture.IImageDocument imageDoc = recognizer.Receipts.Item(0).ImageDocument;
imageDoc.EnhanceLocalContrast();

// Recognize document
...
link

answered 30 Jun '16, 13:39

Oksana%20Serdyuk's gravatar image

Oksana Serdyuk ♦♦
1.5k16

Thank you!, Can you please elaborate on the ".Item(0)" ?

(30 Jun '16, 17:08) persaudJon

Well, if you are processing a miltu-page document, then you can modify the code a little, for example:

ReceiptCapture.IReceipts receipts = recognizer.Receipts;
int receiptsCount = recognizer.Receipts.Count;

for (int i = 0; i < receiptsCount; i++)
{
    ReceiptCapture.IImageDocument imageDoc = receipts.Item(i).ImageDocument;
    imageDoc.EnhanceLocalContrast();
}
link

answered 30 Jun '16, 17:24

Oksana%20Serdyuk's gravatar image

Oksana Serdyuk ♦♦
1.5k16

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×42
×36
×9
×2

Asked: 29 Jun '16, 16:06

Seen: 1,049 times

Last updated: 30 Jun '16, 17:24

© 2016 ABBYY. All rights Reserved. www.ABBYY.com | Privacy Policy | Legal