XAML Capture Element behind graphics

Currently I am attempting to take a capture element that is capturing the Camera. This runs just fine within the GamePage.xaml.cs but for some reason would not work within the Game1.CS. I found that the reason why is the StartPreviewAsync().

Any Ideas as to how you can go around how the XAML is printed before the graphics?

(This is mainly so I can do a simple augmented reality.)

    private async void StartPreview()
        previewElement.Source = captureManager;
        await captureManager.StartPreviewAsync();
        isPreviewing = true;

I’ve been searching a while and I haven’t seen a thing on how to do this. This would be the only reason I would ask.

I would have thought grab image stream, project to a render target or something, then overlay graphics on top?

I didn’t think about doing this. The only problem I had was with how the camera was being accessed. It was only accessed through the XAML. I will have to try an image stream.

1 Like

Have you tried with a sync method if there is one ?
It may be also related to the time in xaml not being the same as gametime.

So far, I am noticing a PhotoCapture method for Microfsoft.Devices may be a better method than what I have been trying. Now I would just need to convert to Texture or Texture2d.

Synchronizing the XAML should not need to be a factor as this would really only need to move the XAML behind the game graphics or implement some type of capture to texture method.

Changed from the MediaCapture in other words.
Just need to change PhotoCapture to Texture2d.

Please do share your findings as this would likely serve a lot of uses. :pizza: