【问题标题】:Captured photo with stripes拍摄的带有条纹的照片
【发布时间】:2014-05-17 09:06:44
【问题描述】:

我正在使用MediaCapture class 使用 Windows Phone 8.1 运行时拍照。我拍照的代码如下所示:

// 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);

当我得到一张图片时,代码运行良好,但左右两侧有奇怪的条纹:

我正在尝试找到解决此问题的方法,但没有成功。我错过了什么吗?

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

【问题讨论】:

  • 嗨,罗马兹。我让你对 Windows Phone 有广泛的了解。我被困在我的应用程序中。问题是,为了创建配置文件,我使用 fileopenpicker 从用户那里获取一个文件,并将该选择图像转换为字节并将该字节保存在 SQLite 数据库中......当我获取所有配置文件的数据时,我无法将我的图像字节转换为列表中的图像。 stackoverflow.com/questions/32748330/…

标签: c# windows-runtime windows-phone-8.1


【解决方案1】:

好的,我自己想通了 - 这是使用 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);

【讨论】:

  • 在我的例子中,这会生成一个NullReferenceException,因为返回的 IEnumerable 包含两个 PhotoEncodingProperties,其中强制转换返回 null。这对我有用:var maxResolution = takePhotoManager.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo).Aggregate( (i1, i2) => (i1 is VideoEncodingProperties ? (i1 as VideoEncodingProperties).Width : 0) > (i2 is VideoEncodingProperties ? (i2 as VideoEncodingProperties).Width : 0) ? i1 : i2);
  • @CedricReichenbach 我没有遇到过这样的问题,但老实说,我已经在一台设备上测试过了 = 所以感谢您的评论和代码。另请注意,最大宽度可能并不意味着最大分辨率,因此根据您的情况,您可以使用不同的方法来选择最佳分辨率 - 只是一个备注。
  • 谢谢!这对我有用,但我必须同时为 MediaStreamType.Photo 和 MediaStreamType.VideoPreview 设置它!
  • @MahnikLassdas 你是用它来拍照还是录视频?我已经有一段时间没有尝试过了,谢谢你的提示。
  • 我展示了一个带有快门按钮的相机预览流来拍照。
【解决方案2】:

我尝试使用最低分辨率得到相同的条纹。 在 MS Advance Camera 示例中,他们使用 MediaCapture 进行预览,但使用 SilverLight API 进行捕获!

每次调用 CapturePhotoToXXX API 时,MediaCapture 也会出现内存泄漏问题。

我想知道他们是否已经知道 MediaCapture 在 WindowsPhone 8.1 上管理不善,这就是他们不提供带有 RT API 的 Camera MediaCapture 示例的原因。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多