public MainWindow() { InitializeComponent(); // Initializing the image stream imageStream = new RealSenseImageStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR); // Change here with you want to see other stream types imageStream.InitializeStream(); imageStream.StartStream(); imageStream.NewImageAvailable += imageStream_NewImageAvailable; //next.ConsoleApplication.Manager nextManager = new next.ConsoleApplication.Manager(); this.SizeChanged +=MainWindow_SizeChanged; this.Loaded += MainWindow_Loaded; }
void imageStream_NewImageAvailable(object sender, RealSenseImageStream.NewImageArgs args) { // TODO: improve the way to change the image source and avoid Thread cancelation exception Dispatcher.Invoke(new Action(() => { imageComponent.Source = ImageUtils.ConvertBitmapToWpf(args.Bitmap); })); }