如何在Windows 8 Metro风格的应用程序中获取相机供稿?

如何在Windows 8 Metro风格的应用程序中获取相机供稿?

问题描述:

我正在尝试在Windows 8 Metro风格的应用程序中获取相机供稿,以便我可以对其进行一些更改,例如增强现实.我已经尝试过,但是只能找到如何使用CameraCaptureUI()捕获图像.谁能告诉我如何实现AR的相机供稿?

I am trying to get camera feeds in Windows 8 metro style app so that i can make some changes on it something like augmented reality. I have tried but only able to find how to capture images using CameraCaptureUI(). Can anyone tell me how can i achieve camera feeds for AR?

您需要做的就是传递CameraCaptureUIMode.Video for CaptureFileAsync.这是一个示例

All you need to do is pass in CameraCaptureUIMode.Video for CaptureFileAsync. Here is a sample

CameraCaptureUI dialog = new CameraCaptureUI();
dialog.VideoSettings.Format = CameraCaptureUIVideoFormat.Mp4;

StorageFile file = null;
file = await dialog.CaptureFileAsync(CameraCaptureUIMode.Video);
if (file != null)
{

    IRandomAccessStream fileStream = await   file.OpenAsync(Windows.Storage.FileAccessMode.Read);
    //Do something with the stream
}

例如,要应用效果,可以使用AddEffectAsync方法.

In order to apply effects you can use the AddEffectAsync method, for example.

mediaCaptureMgr.AddEffectAsync(MediaStreamType.VideoPreview, "Microsoft.Samples.GrayscaleEffect", null);

GrayScaleEffect的Microsoft Foundation Transform(MFT)实现在[here]. 1 .该示例应允许您创建自己的效果.

The Microsoft Foundation Transform (MFT) implementation of the GrayScaleEffect is [here]. 1. That example should allow you to create your own effects.