How to get camera feeds in Windows 8 Metro style app?

前端 未结 2 469
误落风尘
误落风尘 2021-01-15 12:51

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 t

相关标签:
2条回答
  • 2021-01-15 13:31

    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
    }
    

    EDIT:

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

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

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

    0 讨论(0)
  • 2021-01-15 13:36

    I blogged about it before.

    You need to use a CaptureElement and a MediaCapture object:

    var mediaCapture = new MediaCapture(); 
    await mediaCapture.InitializeAsync(); 
    this.captureElement.Source = mediaCapture; 
    await mediaCapture.StartPreviewAsync(); 
    
    0 讨论(0)
提交回复
热议问题