QR code recognition sample

  • 131 Views
  • Last Post 05 September 2017
Mokhtar NEBLI posted this 09 August 2017

Hi,

i'm looking for C# for QR code and BAR code  recognition samples using ABBYY FlexiCapture Engine and ABBYY FlexiLayout Studio

Order By: Standard | Newest | Votes
Nikolay Krivchanskiy posted this 14 August 2017

Hi Mokhtar,

 

If you wish to recognize barcodes, all you have to do is create document definition with barcode fields and apply it to the documents you need to recognize. The recognition will be conducted automatically for all pages that match the document definition. The result of the recognition will be exported correctly, when you decide to export it.

 

If you do not have a document definition for barcode analysis, you should create such document definition first, for more information on that, please refer to Help → Guided Tour → Advanced Techniques → Creating Document Definitions.

 

It you wish to recognize barcodes manually from your code, you should iterate through blocks inside of a document, until you find a block with Type parameter set as “BT_Barcode”.

 

Barcodes can be marked as a field or as a static element. This depends on the barcode meaning in the documents being processed: if it is intended for Document Definition matching or identification, it is created in the static elements mode (anchor barcode). Meanwhile, if a barcode is intended for data capture, it is created in the field marking mode. If you need to access static barcode, please use  “BT_StaticBarcode” to refer to it.

 

 

 

If you have document definition, matching barcodes and you are willing to access them directly from the code, you can achieve that, by iterating through blocks on the page. It can be done like that:

 

IDocument document = processor.RecognizeNextDocument();

pages = document.Pages;

if (pages != null && pages.Count > 0)

{

    //writeDebugLog("7-1");

    foreach (IPage page in pages)

    {

        //writeDebugLog("7-2");

        if (page.Blocks != null && page.Blocks.Count > 0)

        {

            //writeDebugLog("7-3");

            foreach (IBlock block in page.Blocks)

            {

                if (block.Type == BlockTypeEnum.BT_Barcode)

                {

                    //Do something with block

                }

            }

        }

    }

 

}

Mokhtar NEBLI posted this 15 August 2017

Thanks,

How can i get value from block ?

Nikolay Krivchanskiy posted this 22 August 2017

Hi Mokhtar,

There are a few ways to access text from block:

• If you only wish to get text, please use the BarcodeBlock::Text method. It will allow you to get read-only string of barcode content.

• If you wish to access symbols and additional data about them, you should use the BarcodeBlock::BarcodeText method, which will return a BarcodeText collection with access to an each element separately through the BarcodeText::Element field.

• If you are willing to edit barcode text, you can do it via the BarcodeBlock::EditableText method. This method will only be available after you synthesized the document, but will allow you to edit the barcode text as the Text object.

 

Mokhtar NEBLI posted this 30 August 2017

Hi Nikolay,

i only can access IBarcodeBlock where text is always null ,

how can i get text from this block

Nikolay Krivchanskiy posted this 05 September 2017

Hello Mokhtar,

The fact that text is null in BarcodeBlock can be caused by one of the following reasons:

• The block contains null value. Some block types may contain null value at a valid state.

• The block type does not correspond to any AllowedType set at the moment. Please, check that all barcode types you wish to recognize are set in your BarcodeParams:AllowedTypes parameter.

If none of these is the case, please attach examples of your files to the SDK_Support@abbyy.com so that we could help you.

Close