Export (0) Print
Expand All

ErrorCode Enumeration (Bing.Ocr)

Deprecated. The ErrorCode Enumeration lists the error codes for The Bing Optical Character Recognition (OCR) Control. The error codes are surfaced in the event arguments of the OcrControl.Failed Event.

Published date: March 4, 2014

Dn261728.Warning(en-us,MSDN.10).gifCaution:
The Bing OCR Control is deprecated as of March 12, 2014.

public enum ErrorCode

The ErrorCode Enumeration has the following members.

Members

Name Description

CameraBusy

Another application is using the camera.

CameraLowQuality

The rear facing camera does not support 1280x720 or 640x480 resolution in photo mode. For more information, see Bing OCR Requirements.

CameraNotAvailable

There is no rear-facing camera on this device, or the rear camera is not recognized by the system.

CameraPermissionDenied

The application does not have permission to access the camera in the current user profile. To prevent this error, open the Package.appmanifest file, and under Capabilities, check Webcam. This causes the application to prompt for camera access when it opens. The user choosing not to allow camera access at startup can also cause this error. The user can correct this by typing

[Windows] + C from your application, clicking Settings, then Permissions, and sliding Webcam to On.

InputInvalid

Either the language code is unsupported or there is a problem with the image, depending on the error message returned by the OCR service.

InternalError

There was an internal error in the OCR Service.

NetworkUnavailable

The user’s system was unable to reach the OCR Service.

SubscriptionIssue

There is a problem with the application developer’s subscription to the OCR Control.

Success

The attempt succeeded.

TransactionQuotaReached

The application has reached the maximum number of OCR Service requests allowed by the developer’s monthly subscription to the control.

Unauthorized

The ClientID or ClientSecret is expired or invalid.

The following example handles the OcrControl.Failed Event of OcrControlOCR by writing text to TextBlocktbResult, and then either continuing or cancelling preview depending on the error.


<Ocr:OcrControl x:Name="OCR" .../>
<TextBlock x:Name="tbResults" .../>


public MainPage()
{
    this.InitializeComponent();

    // Assign event handlers
    OCR.FrameCaptured += OCR_FrameCaptured;
    OCR.Completed += OCR_OcrCompleted;
    OCR.Failed += OCR_ErrorOccurred;
    …
}

private async void OCR_ErrorOccurred(object sender, OcrErrorEventArgs e)
{
    // Display error message.
    tbResults.Text = e.ErrorMessage;
            
    // Give guidance on specific errors.
    switch (e.ErrorCode) 
    {
        case ErrorCode.CameraBusy:
            tbResults.Text += "\nClose any other applications that may be using the camera and try again.";
            break;
        case ErrorCode.CameraLowQuality:
            tbResults.Text += "\nThe rear facing camera does not meet the resolution requirements of OCR.";
            break;
        case ErrorCode.CameraNotAvailable:
            tbResults.Text += "\nA rear facing camera was not found.";
            break;
        case ErrorCode.CameraPermissionDenied:
            tbResults.Text += "\nTurn camera permissions on in your application settings.";
            break;
        case ErrorCode.InputInvalid:
        case ErrorCode.Unauthorized:
        case ErrorCode.TransactionQuotaReached:
        case ErrorCode.SubscriptionIssue:
        case ErrorCode.InternalError:
            tbResults.Text += "\nNotify your application provider.";
            break;
    }

    // Continue or cancel, depending on the error.
    if (e.ErrorCode == ErrorCode.Success) await OCR.StartPreviewAsync();
    else await OCR.ResetAsync();
}

Minimum Supported Client

Windows 8.1

Required Extensions

Bing OCR

Namespace

Bing.Ocr

Show:
© 2014 Microsoft