public async Task TakeAsync() { GC.Collect(); Stopwatch sw = new Stopwatch(); System.Console.WriteLine("take"); sw.Start(); camera.ExposureTime = 400; var raw = await camera.TakeImageAsync(); var frame = (Ncer.Camera.Frame)(raw.Clone()); System.Console.WriteLine("take frame:" + sw.ElapsedMilliseconds + "ms"); if (frame == null) { MessageBox.Show("no frame"); return; } MatImage image = MatImage.CreateFromPtr(frame.Width, frame.Height, MatType.CV_16SC1, frame.Data); System.Console.WriteLine("create mat:" + sw.ElapsedMilliseconds + "ms"); var img = Utils.MatToImageSource(image.Mat); System.Console.WriteLine("take img:" + sw.ElapsedMilliseconds + "ms"); this.imageMain.Source = img.Clone(); System.Console.WriteLine("show img:" + sw.ElapsedMilliseconds + "ms"); }
private void Camera_OnCameraPreviewEvent(object sender, Ncer.Camera.Frame frame) { this.Dispatcher.Invoke(() => { MatImage image = MatImage.CreateFromPtr(frame.Width, frame.Height, MatType.CV_16UC1, frame.Data); var img = Utils.MatToImageSource(image.Mat); this.imageMain.Source = img.Clone(); }); }