示例#1
0
        private void btnReconstruct_Click(object sender, EventArgs e)
        {
            string folder = Path.GetFullPath(tbxInputFolder.Text);

            if (Directory.Exists(folder))
            {
                TestCaseHelper.RebuildImageSequence(folder);
            }
        }
示例#2
0
        private void btnReload_Click(object sender, EventArgs e)
        {
            m_CurrentIndex = -1;
            m_InputFiles.Clear();
            m_InputFiles.AddRange(TestCaseHelper.LoadTestImages(tbxInputFolder.Text, cbxReverseEvenOdd.Checked));

            m_Processor = new IotaVtiOcrProcessor(cbxIsTvSafe.Checked);

            if (m_InputFiles.Count > 0)
            {
                m_CurrentIndex = 0;
            }
            ProcessCurrentImage();
        }
示例#3
0
        private void RunOCRTestCases(string[] testCases)
        {
            lbErrors.Items.Clear();

            foreach (string folder in testCases)
            {
                string folderNameOnly  = Path.GetFileName(folder);
                bool   isTvSafeGuess   = folderNameOnly.EndsWith("_tvsafe");
                bool[] REVERSE_OPTIONS = new bool[] { false, true };

                for (int option = 0; option <= 1; option++)
                {
                    lvlTestCaseDescription.Text = string.Format("Test case {0} {1}", folderNameOnly, (option == 0 ? "" : " (Reversed)"));
                    lvlTestCaseDescription.Update();

                    List <string> testFiles = TestCaseHelper.LoadTestImages(folder, REVERSE_OPTIONS[option]);

                    var  ocrEngine     = new IotaVtiOrcManaged();
                    bool isSuccess     = false;
                    bool calibrated    = false;
                    bool digitsPlotted = false;

                    for (int i = 0; i < testFiles.Count; i++)
                    {
                        Bitmap bmpOdd = (Bitmap)Bitmap.FromFile(testFiles[i]);
                        i++;
                        Bitmap bmpEven = (Bitmap)Bitmap.FromFile(testFiles[i]);

                        Pixelmap pixelmapOdd  = Pixelmap.ConstructFromBitmap(bmpOdd, TangraConfig.ColourChannel.Red);
                        Pixelmap pixelmapEven = Pixelmap.ConstructFromBitmap(bmpEven, TangraConfig.ColourChannel.Red);

                        if (!calibrated)
                        {
                            calibrated = ocrEngine.ProcessCalibrationFrame(i / 2, pixelmapOdd.Pixels, pixelmapEven.Pixels, bmpOdd.Width, bmpOdd.Height, isTvSafeGuess);
                        }

                        if (calibrated)
                        {
                            if (!digitsPlotted)
                            {
                                PlotDigitPatterns(ocrEngine);
                                digitsPlotted = true;
                            }

                            DateTime dt;
                            isSuccess = ocrEngine.ExtractTime(i / 2, 1, pixelmapOdd.Pixels, pixelmapEven.Pixels, bmpOdd.Width, bmpOdd.Height, out dt);
                            if (!isSuccess)
                            {
                                break;
                            }
                        }
                    }

                    pbar.Value++;

                    if (isSuccess)
                    {
                        pbarSuccess.Value++;
                    }
                    else
                    {
                        pbarError.Value++;
                        lbErrors.Items.Add(string.Format("{0}{1} - {2}", folderNameOnly, (option == 0 ? "" : " (Reversed)"), calibrated ? "Error extracting times" : " Failed to calibrate"));
                    }

                    lblError.Text      = string.Format("Errored {0}/{1}", pbarError.Value, pbar.Value);
                    lblSuccessful.Text = string.Format("Successful {0}/{1}", pbarSuccess.Value, pbar.Value);

                    Application.DoEvents();
                }
            }

            lvlTestCaseDescription.Text = "";
        }