[英]How to display Camera Stream with Xamarin.Forms. Is it possible?
所以我創建了一個接口並在我的 Windows Phone 8 應用程序中實現了這個接口來啟動相機流。 像這樣:
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);
}
所以現在canvas
對象正在保存一個相機流。 但是我如何將它傳遞回 Xamarin 表單並顯示它。
在 Xamarin 表單中,我有:
IOperations camera = DependencyService.Get<IOperations>();
if (camera != null)
{
camera.StartCamera();
}
除了顯然我無法控制顯示相機流之外,這還有效。 我將如何以 Xamarin 形式顯示此流?
現在這里有一個新的自定義渲染器示例項目:
http://developer.xamarin.com/samples/xamarin-forms/CustomRenderers/ContentPage/
在此處提供此示例的演練:
https://developer.xamarin.com/guides/cross-platform/xamarin-forms/custom-renderer/contentpage/
我知道這是一個僅鏈接的答案,但由於問題的復雜性,重新發布鏈接內容太費時了
現在還有一個由 Xamarin 社區工具包提供的控件,稱為 CameraView
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.