static void UploadImage(Image img, VideoFrame frame) { var bytes = new byte[frame.Stride * frame.Height]; frame.CopyTo(bytes); var bs = BitmapSource.Create(frame.Width, frame.Height, 300, 300, PixelFormats.Rgb24, null, bytes, frame.Stride); var imgSrc = bs as ImageSource; img.Source = imgSrc; }
private void UploadImage(System.Windows.Controls.Image img, VideoFrame frame) { Dispatcher.Invoke(new Action(() => { if (frame.Width == 0) { return; } var bytes = new byte[frame.Stride * frame.Height]; frame.CopyTo(bytes); var bs = BitmapSource.Create(frame.Width, frame.Height, 300, 300, PixelFormats.Bgr24, null, bytes, frame.Stride); var imgSrc = bs as ImageSource; img.Source = imgSrc; })); }