Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display Camera Stream with Xamarin.Forms. Is it possible?

So I have created an interface and implemented this interface currently in my Windows Phone 8 application to start a camera stream. Like so:

public void StartCamera()
{
      var cam = new Microsoft.Devices.PhotoCamera(Microsoft.Devices.CameraType.Primary);
      System.Windows.Controls.Canvas canvas = new System.Windows.Controls.Canvas();
      var videobrush = new System.Windows.Media.VideoBrush();
      canvas.Background = videobrush;
      videobrush.SetSource(cam);
}

so now the canvas object is holding a camera stream. But how Do I then pass this back to Xamarin forms and display it.

In Xamarin Forms I have:

IOperations camera = DependencyService.Get<IOperations>();
if (camera != null)
{
    camera.StartCamera();
}

and this works apart from obviously I have no control to display the camera stream. How would I display this stream in Xamarin forms?

like image 605
User1 Avatar asked Aug 08 '14 11:08

User1


1 Answers

There is now a new Custom Renderer example project available here:

http://developer.xamarin.com/samples/xamarin-forms/CustomRenderers/ContentPage/

With a walkthrough of this sample available here:

https://developer.xamarin.com/guides/cross-platform/xamarin-forms/custom-renderer/contentpage/

I know this is a link only answer but due to the complexity of the question it would be too time consuming to repost the links contents

There is also now a control by the Xamarin Community toolkit called CameraView

Xamarin Community Toolkit Camera View

like image 102
User1 Avatar answered Oct 21 '22 04:10

User1