如何在Silverlight控件上绘制相机流 - Metro& Windows 8

时间:2012-04-03 13:27:28

标签: windows-8 microsoft-metro windows-runtime

我有安装了Windows 8的平板电脑,我想创建一个Metro-Application。 我有一个前置摄像头和一个后置摄像头。我想在Silverlight矩形上绘制任何这些源的相机流。对于Windows Phone 7,我可以使用VideoBrush中的Rectangle执行此操作。 这在Windows 8上如何工作? 而且我不是在谈论用CameraCaptureUI

制作图片

1 个答案:

答案 0 :(得分:0)

对不起,我刚发现了类似的问题/答案here

我的问题的答案是:

<CaptureElement x:Name="captureElement"/>

async private void StartCamPrev()
{
    var mediaCapture = new Windows.Media.Capture.MediaCapture();
    await mediaCapture.InitializeAsync();
    this.captureElement.Source = mediaCapture;
    await mediaCapture.StartPreviewAsync();
}

关于我发现的前脸/背面相机的答案here

DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
var mediaCapture = new Windows.Media.Capture.MediaCapture();
await mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings
{
    // the index of the devices-array is defining the device
    // here I just put a '0' for testing-purposes:
    VideoDeviceId = devices[0].Id
});