Beispiel #1
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);
            }
        }
Beispiel #2
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();
 }