捕获的条纹照片

Rom*_*asz 4 c# windows-runtime windows-phone-8.1

我正在使用MediaCapture类用Windows Phone 8.1 Runtime拍照.我拍照的代码看起来像这样:

// create a file
StorageFile photoFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("myFirstPhoto.jpg", CreationCollisionOption.ReplaceExisting);

// take a photo with choosen Encoding
await captureManager.CapturePhotoToStorageFileAsync(ImageEncodingProperties.CreateJpeg(), photoFile);
Run Code Online (Sandbox Code Playgroud)

代码工作得很好,因为我得到一张照片,但左右两侧有奇怪的条纹:

在此输入图像描述

我正试图找到解决这个问题的方法,但没有成功.我错过了什么吗?

编辑 - 从内置应用程序拍摄的照片没有条纹,所以这似乎不是硬件的问题.

Rom*_*asz 7

好吧我自己已经弄明白了 - 这是一个分辨率的问题,在使用时设置为默认值MediaCapture.如果在初始化MediaCapture之后设置最大分辨率,那么将没有条纹:

// just after initialization
var maxResolution = captureManager.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo).Aggregate(
                    (i1, i2) => (i1 as VideoEncodingProperties).Width > (i2 as VideoEncodingProperties).Width ? i1 : i2);
await captureManager.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo, maxResolution);
Run Code Online (Sandbox Code Playgroud)

  • 这会在我的情况下生成一个`NullReferenceException`,因为返回的IEnumerable包含两个`PhotoEncodingProperties`,其中转换返回null.这适用于我:`var maxResolution = takePhotoManager.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo).Aggregate((i1,i2)=>(i1是VideoEncodingProperties?(i1 as VideoEncodingProperties).Width:0)>(i2是VideoEncodingProperties? (i2作为VideoEncodingProperties).宽度:0)?i1:i2);` (4认同)