Exemple #1
0
        private RecognitionOptions ConfigureRecognitionOptionsBeforeComputing()
        {
            RecognitionOptions ro = null;

            if (checkBoxBicolor.Checked)
            {
                ro = new OptionsOfBicolorRecognition();
            }

            if (checkBoxSharpBorders.Checked)
            {
                ro = new OptionsOfRecognitionWithSharpBorder();
            }

            if (checkBoxRgbCoord.Checked)
            {
                ro = new OptionsOfRecognitionWithRgbCoord()
                {
                    MaxLen = trackBarMaxLen.Value
                };
            }

            if (checkBoxRgbChannels.Checked)
            {
                ro = new OptionsOfRecognitionWithRgbChannels()
                {
                    MaxDifR = trackBarR.Value,
                    MaxDifG = trackBarG.Value,
                    MaxDifB = trackBarB.Value,

                    MinCountOfChannels = trackBarRgbChannels.Value,
                };
            }

            if (checkBoxHsv.Checked)
            {
                ro = new OptionsOfRecognitionWithHsv()
                {
                    MaxDifH = (decimal)trackBarH.Value / 100,
                    MaxDifS = (decimal)trackBarS.Value / 100,
                    MaxDifV = (decimal)trackBarV.Value / 100,

                    MinCountOfChannels = trackBarHsvChannels.Value,
                };
            }

            if (ro != null)
            {
                ro.CountOfNoiseSuppression = checkBoxNoiseSuppression.Checked ? (int)numericUpDownNoiseSuppression.Value : 0;
                ro.isContourRecognition    = checkBoxContourRecognition.Checked;

                return(ro);
            }

            MessageBox.Show("Не выбраны параметры распознавания фигур", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

            throw new ApplicationException("Recognition options are not selected");
        }
Exemple #2
0
        private void recoginteSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                CheckPicture();
            }
            catch (ApplicationException)
            {
                return;
            }


            ConfigureInterfaceBeforeThreadedComputing();


            RecognitionOptions ro = new OptionsOfBicolorRecognition();


            Task taskOfPatternRecognition = ThreadedCompute(ro);


            ShowResult(taskOfPatternRecognition);
        }