. net毛伊岛网络摄像头预览



我是。net世界的新手。我正在尝试在我的毛伊岛屏幕上流式传输网络摄像头(仅限Windows)。问题是默认的MAUI函数来完成这项工作是使用MediaPicker CaptureAyncPhoto方法,该方法在windows机器上不工作,并在github上报告为错误。

所以现在我正在尝试用Aforge视频库在我的屏幕上预览网络摄像头,我不知道如何将流分配给xaml图像。

这里是xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TestWebCam.MainPage">
<ScrollView>
<VerticalStackLayout Spacing="25" VerticalOptions="Center">
<Image  HorizontalOptions="Center"  HeightRequest="300" x:Name="myImage" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>

这里是我的mymainpage . example .cs

using AForge.Video;
using AForge.Video.DirectShow;
using SkiaSharp;
using System.Drawing;
using System.IO;
namespace TestWebCam;

public partial class MainPage : ContentPage
{
private VideoCaptureDevice videoDevice;

public MainPage()
{
InitializeComponent();

// Get the list of available video devices
FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
if (videoDevices.Count == 0)
{
DisplayAlert("Error", "No video devices found", "OK");
return;
}
// Select the first video device
videoDevice = new VideoCaptureDevice(videoDevices[0].MonikerString);

videoDevice.NewFrame += videoDevice_NewFrame;

videoDevice.Start();
}
private void videoDevice_NewFrame(object sender, NewFrameEventArgs eventArgs)
{

using var bitmap = (System.Drawing.Bitmap) eventArgs.Frame.Clone();

//  myImage.Source = ImageSource.FromFile("calendar.png");
}
protected override void OnDisappearing()
{
base.OnDisappearing();
// Stop capturing frames from the video device
videoDevice.SignalToStop();
videoDevice.WaitForStop();
}

}

这个问题我面临的是这个方法videoDevice_NewFrame我怎么把myImage绑定到这个流呢?

. net MAUI Community Toolkit可能会有所帮助。它有一个Windows支持的MediaElement。

相关内容

  • 没有找到相关文章

最新更新