OcrControl.CameraDeviceId Property

Thie CameraDeviceId Property returns the ID of the last camera used by the current OcrControl instance. By default, the OcrControl will select the back facing camera. If no camera has been started in the current session, this property will return null.

Published date: June 26, 2013

public String CameraDeviceId { get; }
<Ocr:OcrControl CameraDeviceId="MyDeviceId" .../>

Type: System.String

The device ID of the currently selected camera, or null if no camera is available.

Users can switch between cameras in the control UI on systems that have multiple cameras by clicking the Camera Change button. The OcrControl does not cache this property, so each time the control is instantiated, it will return to the default camera unless a camera ID is specified in the StartPreviewAsync(String) Method.

To retain camera preferences between sessions

  1. In the handler for the OcrControl.CameraChanged Event, save the new camera ID to your local application settings.

    using Windows.Storage;
    
    private void OCR_CameraChanged(object sender, CameraIdChangedEventArgs e)
    {
        ApplicationData.Current.LocalSettings.Values["LastCamera"] = OCR.CameraDeviceId;
    }
    
  2. Pass the stored camera ID to the StartPreviewAsync(String) method.

    // Get the last selected camera.
    string cameraId = ApplicationData.Current.LocalSettings.Values["LastCamera"] as string;
                
    // Start the camera.
    await OCR.StartPreviewAsync(cameraId);
    

Minimum Supported Client

Windows 8, Windows 8.1, Windows RT

Assemblies

Bing.Ocr.winmd, Bing.Controls.AuthenticationAccessToken.winmd

Namespace

Bing.Ocr

Show: