Share via


OcrResult class

 

 

Deprecated. The OcrResult object contains the contents of the response returned to The Bing Optical Character Recognition (OCR) Control by the Ocr Service.

Published date: March 4, 2014

Warning

The Bing OCR Control is deprecated as of March 12, 2014.

Syntax

public sealed class OcrResult

The OcrResult class has the following members.

Properties

Name

Description

Lines

Returns an IReadOnlyList collection of Ocr.Line objects that contain lines of text recognized by the OCR service.

Rotation

Specifies the rotation, in radians, of the captured image relative to the position of the camera.

Example

The following code example enumerates through the text of an OCR result and writes to a string, preserving line breaks. It then writes the string to a TextBlock named tbResults. In this case, the OcrResult object is never declared, but is accessed through the OcrCompletedEventArgs.Result Property.

private void OCR_Completed(object sender, OcrCompletedEventArgs e)
{
    // Make sure there is text.
    if (e.Result.Lines.Count == 0)
    {
        tbResults.Text = "No text found.";
        return;
    }

    // Read the text and print it to a TextBlock.
    var sb = new System.Text.StringBuilder();
    foreach (Line l in e.Result.Lines)
    {
        foreach (Word w in l.Words)
        {
            sb.AppendFormat("{0} ", w.Value);
        }
        sb.AppendLine();
    }
    tbResults.Text = sb.ToString();
}

Requirements

Minimum Supported Client

Windows 8.1

Required Extensions

Bing OCR

Namespace

Bing.Ocr