void btn_recog_Click(object sender, EventArgs e) { if (this.pb_formimage.Image != null) { try { this.ag_answers.pb_progress.Value = 0; this.ag_answers.pb_progress.Minimum = 0; this.ag_answers.pb_progress.Step = 1; this.ag_answers.pb_progress.Maximum = this.ag_answers.AnswersCount; this.ag_answers.btn_recog.Text = "Идет распознавание..."; Recognizer r = new Recognizer(_ge, (Bitmap)this.pb_formimage.Image, _testid); r.RecItem += new EventHandler(r_RecItem); r.Prerecognize(); RecogResult rr = r.FindBestRecognize(); r.Recognize(rr.RangeWidth, rr.MinDisp); _canvas = r.Canvas; this.ag_answers.Answers = r.Canvas.Answers; answs = r.Canvas.Answers; r.Canvas.Answers.SelectTrueCell(); this.pb_formimage.Image = r.Canvas.CorrectedImage; this.ag_answers.btn_recog.Text = "Распознавание завершено"; this.ag_answers.pb_progress.Value = this.ag_answers.pb_progress.Maximum; this.ag_answers.btn_recog.Enabled = false; this.btn_scan.Enabled = false; if (r.Canvas.Answers.CountWithEmpty + r.Canvas.Answers.CountWithMiss > 15) { DialogResult dr = MessageBox.Show("Слишком много ошибок при распознавании.\nПричинами может являтся несоответствие бланка и выбранного теста или некорректные настройки яркости-контрастности сканера.\nБолее подробно читайте в справочной информации к программе.\nЖелаете пересканировать этот бланк?", "Проблемы распознавания", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { RForm rf = new RForm(this._testid, this._humanid, _ge, _fe); rf.WindowState = FormWindowState.Maximized; this.Close(); rf.ShowDialog(); } } this.lb_status.Text = "Итоги распознавания: вопросов без ответа: " + r.Canvas.Answers.CountWithEmpty.ToString() + ", ошибочных ответов: " + r.Canvas.Answers.CountWithMiss.ToString() + ", несколько ответов в вопросе: " + r.Canvas.Answers.CountWithDoubleCross.ToString(); this.lb_status.Visible = true; this.chb_onofdesc.Visible = true; } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); } } else { MessageBox.Show("Нет изображения"); } }
public RecogResult FindBestRecognize() { List <RecogResult> rlist = new List <RecogResult>(); for (double rng = 0; rng < 1; rng += 0.1) //for (double rng = 0.2; rng < 0.5; rng += 0.1) { for (double m = 0; m < 1 - rng; m += 0.01) { rlist.Add(Recognize(rng, m)); OnRecItem(); } } RecogResult rr = FindMinMistake(rlist); return(rr); }
public RecogResult Recognize(double rangewidth, double mindisp) { RecogResult rr = new RecogResult(); rr.MinDisp = double.NaN; rr.RangeWidth = double.NaN; rr.MistakeCount = int.MaxValue; _canvas.Answers.ClearContent(); _canvas.Answers.GetContent(mindisp, rangewidth + mindisp); rr = new RecogResult(); rr.MinDisp = mindisp; rr.RangeWidth = rangewidth; rr.MistakeCount = _canvas.Answers.CountWithDoubleCross + _canvas.Answers.CountWithEmpty + _canvas.Answers.CountWithMiss; return(rr); }
public RecogResult Recognize(double rangewidth, double mindisp) { RecogResult rr = new RecogResult(); rr.MinDisp = double.NaN; rr.RangeWidth = double.NaN; rr.MistakeCount = int.MaxValue; _canvas.Answers.ClearContent(); _canvas.Answers.GetContent(mindisp, rangewidth + mindisp); rr = new RecogResult(); rr.MinDisp = mindisp; rr.RangeWidth = rangewidth; rr.MistakeCount = _canvas.Answers.CountWithDoubleCross+_canvas.Answers.CountWithEmpty+_canvas.Answers.CountWithMiss; return rr; }