Barcode Reader OCR .NET

The .NET OCR SDK supports the Barcode Reader API.

Using the sample below, we are going to illustrate how to extract the data that we want using the OCR SDK.
Barcode Reader sample

Quick-Start

using Mindee;
using Mindee.Input;
using Mindee.Product.BarcodeReader;

string apiKey = "my-api-key";
string filePath = "/path/to/the/file.ext";

// Construct a new client
MindeeClient mindeeClient = new MindeeClient(apiKey);

// Load an input source as a path string
// Other input types can be used, as mentioned in the docs
var inputSource = new LocalInputSource(filePath);

// Call the API and parse the input
var response = await mindeeClient
    .ParseAsync<BarcodeReaderV1>(inputSource);

// Print a summary of all the predictions
System.Console.WriteLine(response.Document.ToString());

// Print only the document-level predictions
// System.Console.WriteLine(response.Document.Inference.Prediction.ToString());

Output (RST):

########
Document
########
:Mindee ID: f9c48da1-a306-4805-8da8-f7231fda2d88
:Filename: default_sample.jpg

Inference
#########
:Product: mindee/barcode_reader v1.0
:Rotation applied: Yes

Prediction
==========
:Barcodes 1D: Mindee
:Barcodes 2D: https://developers.mindee.com/docs/barcode-reader-ocr
              I love paperwork! - Said no one ever

Page Predictions
================

Page 0
------
:Barcodes 1D: Mindee
:Barcodes 2D: https://developers.mindee.com/docs/barcode-reader-ocr
              I love paperwork! - Said no one ever

Field Types

Standard Fields

These fields are generic and used in several products.

BaseField

Each prediction object contains a set of fields that inherit from the generic BaseField class.
A typical BaseField object will have the following attributes:

  • Confidence (double?): the confidence score of the field prediction.
  • BoundingBox (BoundingBox): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
  • Polygon (Polygon): contains the relative vertices coordinates (Polygon extends List<Point>) of a polygon containing the field in the image.
  • PageId (int?): the ID of the page, always null when at document-level.

Note: A Point simply refers to a List of double.

Aside from the previous attributes, all basic fields have access to a custom ToString method that can be used to print their value as a string.

StringField

The text field StringField extends BaseField, but also implements:

  • Value (string): corresponds to the field value.
  • RawValue (string): corresponds to the raw value as it appears on the document.

Attributes

The following fields are extracted for Barcode Reader V1:

Barcodes 1D

Codes1D: List of decoded 1D barcodes.

foreach (var Codes1DElem in result.Document.Inference.Prediction.Codes1D)
{
    System.Console.WriteLine(Codes1DElem.Value);
}

Barcodes 2D

Codes2D: List of decoded 2D barcodes.

foreach (var Codes2DElem in result.Document.Inference.Prediction.Codes2D)
{
    System.Console.WriteLine(Codes2DElem.Value);
}

Questions?

Join our Slack