Example #1
0
        public void ReadCorrectClearTime()
        {
            string[] filePaths = Directory.GetFiles("./Test/testdata/frames/1080/clears", "*.png", SearchOption.TopDirectoryOnly);
            string   ocrErrors = "";

            foreach (var file in filePaths)
            {
                // Grab expected time which should be in filename (ex: clear_time_usa_0109645.png)
                int    timeIdx      = file.LastIndexOf("_") + 1;
                string expectedTime = file.Substring(timeIdx, 7);
                expectedTime = $"{expectedTime.Substring(0, 2)}'{expectedTime.Substring(2, 2)}\"{expectedTime.Substring(4, 3)}";

                using (var testFrame = new Image <Bgr, byte>(file))
                {
                    string ocrClearTime = OCRLibrary.GetClearTimeFromFrame(testFrame, false);
                    if (expectedTime != ocrClearTime)
                    {
                        ocrErrors += $"\r\nClear time OCR: ({ocrClearTime}) does not match expected: ({expectedTime})";
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(ocrErrors))
            {
                Assert.Fail(ocrErrors);
            }
        }
Example #2
0
        private string runOCRTestsForResolution(Size resolution)
        {
            string[] filePaths = Directory.GetFiles("./Test/testdata/frames/720/levels", "*.png", SearchOption.TopDirectoryOnly);
            string   ocrErrors = "";

            foreach (var file in filePaths)
            {
                int    levelIdx        = file.LastIndexOf("level.") + 6;
                string actualLevelCode = file.Substring(levelIdx, 11);

                using (var testFrame = new Image <Bgr, byte>(file))
                {
                    Level level = OCRLibrary.GetLevelFromFrame(testFrame.Resize(resolution.Width, resolution.Height, Inter.Cubic));
                    if (level.code != actualLevelCode)
                    {
                        ocrErrors += $"\r\nLevel code OCR ({level.code}) does not match actual code ({actualLevelCode})";
                    }
                }
            }

            return(ocrErrors);
        }