private void CameraView_PictureReceived(FrameHandlerEventArgs e) { if (e.Image != null) { OnPageClosing(e.Image.Clone()); } }
private void LeadCamera_FrameReceived(FrameHandlerEventArgs e) { if (e.Image == null) { return; } if (leadCamera.Camera.FocusMode != FocusMode.Continuous) { leadCamera.Camera.FocusMode = FocusMode.Continuous; } if (firstFrame) { #if __ANDROID__ if (Android.OS.Build.Manufacturer == "samsung") { leadCamera.Camera.Focus(); } #endif // #if __ANDROID__ firstFrame = false; } try { if (!_hold) { _autoCapture.CheckStability(e.Image); } } catch (Exception ex) { Console.WriteLine(ex.Message); } if (_hold && _checkStability) { _checkStability = false; bool holdStable = _autoCapture.CheckHoldStability(e.Image); if (!holdStable) { _captureWatch.Stop(); _captureWatch = null; _hold = false; _autoCapture.Reset(); Device.BeginInvokeOnMainThread(() => { UpdateCardDetectionStatus(); }); } else if (holdStable && _captureWatch.ElapsedMilliseconds > 2000) { leadCamera.FrameReceived -= LeadCamera_FrameReceived; _captureImage = true; leadCamera.Camera.FocusMode = FocusMode.Auto; leadCamera.FocusCompleted += leadCamera_FocusCompleted; leadCamera.Camera.Focus(); } } e.Image.Dispose(); if (_autoCapture.IsStable) { if (CurrentOperation == CameraOperationType.BackImage) { leadCamera.FrameReceived -= LeadCamera_FrameReceived; _captureImage = true; leadCamera.Camera.FocusMode = FocusMode.Auto; leadCamera.FocusCompleted += leadCamera_FocusCompleted; leadCamera.Camera.Focus(); return; } if (_captureWatch == null) { _captureWatch = Stopwatch.StartNew(); _autoCapture.Reset(); _hold = true; _checkHoldTimer = new Timer(); _checkHoldTimer.Interval = 600; _checkHoldTimer.Elapsed += _checkHoldTimer_Elapsed; _checkHoldTimer.Enabled = true; _checkHoldTimer.AutoReset = true; Device.BeginInvokeOnMainThread(() => { autoCaptureLabel.Text = "Please Hold On"; autoCaptureLabel.TextColor = Color.Yellow; }); } } }
private void handleFrames(object sender, FrameHandlerEventArgs e) { _previewRenderer.RenderFrame(_videoManager.GetLatestPreviewFrame()); _processedRenderer.RenderFrame(_videoManager.GetLatestProcessedFrame()); }