我的Windows UWP项目从USB网络摄像头读取并显示每个帧,然后通过TCP套接字将其发送到运行Xamarin.IOS应用程序的IPAD。
但是它们不会显示在iPAD UIImage控件中。 (如果我以编程方式将UIImage设置为.jpg,则显示确定)
这是从USB相机读取每个相机框架的代码...
*main.Error <nil> false true
Found error <nil>
*main.Error <nil> false true
No Errors
这是应该在Xamarin.IOS UIKit.UIImage控件中显示每一帧的代码...
void FrameReader_FrameArrived(MediaFrameReader sender, MediaFrameArrivedEventArgs args)
{
// TryAcquireLatestFrame will return the latest frame that has not yet been acquired.
// This can return null if there is no such frame, or if the reader is not in the
// "Started" state. The latter can occur if a FrameArrived event was in flight
// when the reader was stopped.
using (var frame = sender.TryAcquireLatestFrame())
{
if (frame != null)
{
var renderer = _frameRenderers[frame.SourceKind];
renderer.ProcessFrame(frame);
…
public void ProcessFrame( MediaFrameReference frame){
softwareBitmap = FrameRenderer.ConvertToDisplayableImage(frame?.VideoMediaFrame);
SoftwareBitmap latest_frame_SoftwareBitmap;
var imageSource = (SoftwareBitmapSource)_imageElement.Source;
await imageSource.SetBitmapAsync( latest_frame_SoftwareBitmap);
latest_frame_SoftwareBitmap.CopyToBuffer( Frames_To_iPad.buffer_to_IOS.AsBuffer
buffer_to_IOS sent by socket to Xamarin.IOS app running on iPad.
}
}
}
}