Search code examples
c#windows-phone-8cameramediaimage-capture

Windows Phone 8.1 app MediaCapture under exposed


I am trying to capture pictures directly from the camera in my Windows Phone 8.1 Store App.

I have succeeded in initializing a MediaCapture for the device and it take photographs but they are always black or way way under exposed.

Can someone point me in the direction of how I get the camera to auto expose and if possible trigger a focus too as I get catastrophic failure when I call photoManager.VideoDeviceController.FocusControl.FocusAsync()?


Solution

  • For auto-focus I use this code:

    mediaCapture = new MediaCapture();
    var settings = new MediaCaptureInitializationSettings();
    settings.StreamingCaptureMode = StreamingCaptureMode.Video;
    settings.PhotoCaptureSource = PhotoCaptureSource.VideoPreview;
    
    await mediaCapture.InitializeAsync(settings);
    
    var focusSettings = new FocusSettings();
    focusSettings.AutoFocusRange = AutoFocusRange.FullRange;
    focusSettings.Mode = FocusMode.Auto;
    focusSettings.WaitForFocus = true;
    focusSettings.DisableDriverFallback = false;
    
    mediaCapture.VideoDeviceController.FocusControl.Configure(focusSettings);
    

    for exposure, try this:

    await mediaCapture.VideoDeviceController.ExposureControl.SetAutoAsync(true);