/// <summary> /// Processes current frame /// </summary> private void ProcessFrame() { try { Image <Bgr, byte> tempFrame = null; if (captureFromCam) { captureSetWindow.Frame = CameraManager.GetImage(); } else { captureSetWindow.Frame = captureSetWindow.ImageFrame.Clone(); } // get values of properties from the UI captureSetWindow.Dispatcher.BeginInvoke(new Action(() => { dilatation = captureSetWindow.dilatationSlider.Value; erode = captureSetWindow.erodeSlider.Value; gamma = captureSetWindow.gammaSlider.Value; invert = (bool)captureSetWindow.invertCheck.IsChecked; normalize = (bool)captureSetWindow.normalizeCheck.IsChecked; blackWhite = (bool)captureSetWindow.showBlackWhiteCheck.IsChecked; blur = (bool)captureSetWindow.blurCheck.IsChecked; binary = (bool)captureSetWindow.showBinaryCheck.IsChecked; })); // apply other settings if (dilatation != 0) { captureSetWindow.Frame._Dilate((int)dilatation); } if (erode != 0) { captureSetWindow.Frame._Erode((int)erode); } if (gamma != 1) { captureSetWindow.Frame._GammaCorrect((double)gamma); } if (invert) { captureSetWindow.Frame._Not(); } if (normalize) { captureSetWindow.Frame._EqualizeHist(); } tempFrame = captureSetWindow.Frame.Clone(); if (blackWhite) { tempFrame = tempFrame.Convert <Gray, Byte>().Convert <Bgr, byte>(); } if (blur) { tempFrame = tempFrame.PyrDown().PyrUp(); } captureSetWindow.Processor.ProcessImage(captureSetWindow.Frame); if (binary) { captureSetWindow.captureBox.Image = captureSetWindow.Processor.binarizedFrame; } else { captureSetWindow.captureBox.Image = tempFrame; } } catch (Exception ex) { // no-op here } }