Example #1
0
        private void Run90Criteria(object sender, EventArgs e)
        {
            var orientation = new Dictionary<string, bool>();
            try {
                foreach (var file in files) {
                    orientation[file] = new MainFormState(file).Criteria90();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }

            dataGridView1.Visible = true;
            dataGridView1.DataSource = new BindingSource(orientation, null);
            Text = orientation.Count.ToString() + '/' + files.Count();
        }
Example #2
0
 public bool Criteria90()
 {
     /*var skew = new double[4];
     for (int i = 0; i < 4; i++)
     {
         double angle = GetAvgAngleOfLongLines();
         skew[i] = angle;
         RotateButtonClick(null, null);
     }
     return skew[1] < skew[0] || skew[1] < skew[2] ||
            skew[3] < skew[0] || skew[3] < skew[2];*/
     //            var current = state.Lines.Count(IsLine);
     var current = FilteredLines.Count();
     //            var rotate = state.Lines.Count(IsLine);
     var rotate = new MainFormState(RotateImage(90), analyser, segmentation, binarizaton).FilteredLines.Count();
     return current > rotate;
 }
Example #3
0
        private static void Run180Criteria2(string[] files)
        {
            try
            {
                var writer = new StreamWriter(Output, false);
                int count = 0, wrong = 0;
                foreach (var file in files)
                {
                    var state = new MainFormState(file);
                    var orient = new AlgorithmExecutor(state);
                    var punctOk = orient.CountPattern(orient.HasPunctuation);
                    var upperOk = orient.CountPattern(orient.HasUpperCase);
                    var quatOk = orient.CountPattern(orient.HasQuotations);
                    state = new MainFormState(file);
                    state.Rotate(180);
                    orient = new AlgorithmExecutor(state);
                    var punctBad = orient.CountPattern(orient.HasPunctuation);
                    var upperBad = orient.CountPattern(orient.HasUpperCase);
                    var quatBad = orient.CountPattern(orient.HasQuotations);

                    var sumOk =  (punctOk + quatOk) + upperOk;
                    var sumBad =  (punctBad + quatBad) + upperBad;
                    var result = string.Format("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9}",
                        punctOk, punctBad,
                        upperOk, upperBad,
                        quatOk, quatBad,
                        sumOk, sumBad,
                        sumBad > sumOk ? 1 : 0, file);
                    count++;
                    if (sumBad > sumOk) wrong++;
                    writer.WriteLine(result);
                    Console.WriteLine(result);
                }
                writer.Flush();
                Console.WriteLine("{0}/{1}", wrong, count);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #4
0
        private void Run180Criteria(object sender, EventArgs e)
        {
            var orientation = new Dictionary<string, bool>();
            try {
                foreach (var file in files) {
                    var state = new MainFormState(file);
            //                    state.Rotate(180);
                    orientation[file] = state.Criteria180();
            //                    orientation[file] = new Orient.AlgorithmExecutor(file).CountPatterns();
                }
            }
            catch (Exception ex) {
            //                MessageBox.Show(ex.Message);
            }

            dataGridView1.Visible = true;
            dataGridView1.DataSource = new BindingSource(orientation, null);
            foreach (var b in orientation) {

            }
            Text = orientation.Values.Count(value => value).ToString() + '/' + orientation.Count + '/' + files.Count();
        }
Example #5
0
 private static void Run180Criteria(string[] files)
 {
     int ok = 0;
     int wrong = 0;
     try {
         foreach (var file in files)
         {
             Console.Write(file.PadRight(60, ' ') + "  ");
             var state = new MainFormState(file);
             if (state.Criteria180()) ok++;
             else wrong++;
             state = new MainFormState(file);
             state.Rotate(180);
             if (state.Criteria180()) wrong++;
             else ok++;
             Console.WriteLine("OK {0}; WRONG {1}", ok, wrong);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Example #6
0
 private void OpenNext()
 {
     try
     {
         file = GetFile();
         form.OpenFile(file);
         Text = file;
         var rotate = new Random().Next(4);
         for (var i = 0; i < rotate; i++)
             form.RotateButtonClick(null, null);
         state = form.state;
         if (data[file].Count == state.Lines.Length) OpenNext();
         line = GetLine();
         if (line == null) OpenNext();
         else imageBox.Image = state.OriginalImg.Copy(line.MBR);
     }
     catch (OutOfMemoryException)
     {
         MessageBox.Show("Примеры закончились");
     }
 }
Example #7
0
 private void UpdateSettings(Image<Bgr, byte> image = null)
 {
     if (state == null && image == null) return;
     var img = image != null ? image.Clone() : state.OriginalImg.Clone();
     if (state != null) state.Dispose();
     state = new MainFormState(img, (int) maxWordDistance.Value, (int) maxCharSize.Value,
                               (int) minPunctuationSize.Value, (int) minCharSize.Value,
                               (int) binarizationThreshold.Value, smoothMedianCheckbox.Checked);
     algorithm = new AlgorithmExecutor(state);
     UpdateImage();
     UpdateHistogram();
 }
Example #8
0
 public AlgorithmExecutor(MainFormState state)
 {
     State = state;
 }