예제 #1
0
        public void ReadsRealCharactersWithSideBySideDropCharacters()
        {
            var ocr    = new OCRReader(new OCRSplitter());
            var colors = new[] { new byte[] { 0, 0, 0 } };

            Assert.AreEqual("ManageShipyards", ocr.ReadTableRow(Read(Properties.Resources.ocr_ManageShipyards, colors), OCRReader.Alphabet));
            Assert.AreEqual("lnstallationType", ocr.ReadTableRow(Read(Properties.Resources.ocr_InstallationType, colors), OCRReader.Alphabet));
        }
예제 #2
0
        public void ReadsRealCharactersWithDropCharacters()
        {
            var ocr    = new OCRReader(new OCRSplitter());
            var colors = new[] { new byte[] { 0, 0, 0 } };

            Assert.AreEqual("CivilianMiningColonies", ocr.ReadTableRow(Read(Properties.Resources.ocr_CivilianMiningColonies, colors), OCRReader.Alphabet));
            Assert.AreEqual("Terraforminglnstallations", ocr.ReadTableRow(Read(Properties.Resources.ocr_TerraformingInstallations, colors), OCRReader.Alphabet));
        }
예제 #3
0
        public void ReadsUncomplicatedRealCharacters()
        {
            var ocr    = new OCRReader(new OCRSplitter());
            var colors = new[] { new byte[] { 0, 0, 0 } };

            Assert.AreEqual("Demand", ocr.ReadTableRow(Read(Properties.Resources.ocr_Demand, colors), OCRReader.Alphabet));
            Assert.AreEqual("MannedMines", ocr.ReadTableRow(Read(Properties.Resources.ocr_MannedMines, colors), OCRReader.Alphabet));
        }
예제 #4
0
        public void ReadsUncomplicatedCharacters()
        {
            var ocr      = new OCRReader(new OCRSplitter());
            var alphabet = new Dictionary <string, byte[, ]>
            {
                { "1", new byte[, ] {
                      { 1, 1, 0 }, { 0, 1, 0 }, { 1, 1, 1 }
                  } }
            };
            var colors = new[] { new byte[] { 0, 0, 0 } };

            Assert.AreEqual("", ocr.ReadTableRow(Read(Properties.Resources.ocr_ones, colors), alphabet));
            Assert.AreEqual("11111", ocr.ReadTableRow(Read(Properties.Resources.ocr_onesclean, colors), alphabet));
        }
        public void ReadsCharactersWithLotsOfWhitespaceAbove()
        {
            var ocr = new OCRReader(new OCRSplitter());

            var alphabet = new Dictionary <string, byte[, ]>
            {
                { ".", new byte[, ] {
                      { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 1 }
                  } }
            };

            var text = new byte[, ] {
                { 0, 0 },
                { 0, 0 },
                { 0, 0 },
                { 0, 0 },
                { 0, 0 },
                { 0, 0 },
                { 0, 0 },
                { 0, 0 },
                { 0, 0 },
                { 1, 0 }
            };

            Assert.AreEqual(".", ocr.ReadTableRow(text, alphabet));
        }
        public void ReadsTwoOfSameCharacter()
        {
            var ocr      = new OCRReader(new OCRSplitter());
            var alphabet = new Dictionary <string, byte[, ]>
            {
                { "1", new byte[, ] {
                      { 1, 1, 0 }, { 0, 1, 0 }, { 1, 1, 1 }
                  } }
            };

            var text = new byte[, ] {
                { 1, 1, 0, 0, 1, 1, 0, 0 }, { 0, 1, 0, 0, 0, 1, 0, 0 }, { 1, 1, 1, 0, 1, 1, 1, 0 }
            };

            Assert.AreEqual("11", ocr.ReadTableRow(text, alphabet));
        }
        public void DoesNotReadForcedWhitespace()
        {
            var ocr      = new OCRReader(new OCRSplitter());
            var alphabet = new Dictionary <string, byte[, ]>
            {
                { ".", new byte[, ] {
                      { 0, 0, 0 }, { 0, 0, 0 }, { 1, 0, 0 }
                  } }
            };

            var text = new byte[, ] {
                { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 1, 0, 0, 0, 1, 0, 0, 0, 0 }
            };

            Assert.AreEqual("", ocr.ReadTableRow(text, alphabet));
        }
        public void ReadsTheWordGenomeWithExtraneousSpaces()
        {
            var ocr    = new OCRReader(new OCRSplitter());
            var pixels = new byte[, ] {
                { 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0 },
                { 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0 },
                { 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0 },
                { 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0 },
                { 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0 },
                { 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
            };

            Assert.AreEqual("Genome", ocr.ReadTableRow(pixels, OCRReader.Alphabet));
        }
        public void ReadsVeryLongLines()
        {
            var ocr = new OCRReader(new OCRSplitter());

            var alphabet = new Dictionary <string, byte[, ]>
            {
                { "_", new byte[, ] {
                      { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
                  } }
            };

            var text = new byte[, ] {
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }
            };

            Assert.AreEqual("_", ocr.ReadTableRow(text, alphabet));
        }
        public void ReadsDifferentDotsWithoutTrailingWhitespaceAtTheEnd()
        {
            var ocr      = new OCRReader(new OCRSplitter());
            var alphabet = new Dictionary <string, byte[, ]>
            {
                { ":", new byte[, ] {
                      { 1 }, { 0 }, { 1 }
                  } },
                { "-", new byte[, ] {
                      { 0 }, { 1 }, { 0 }
                  } },
                { ".", new byte[, ] {
                      { 0 }, { 0 }, { 1 }
                  } }
            };

            var text = new byte[, ] {
                { 0, 0, 0, 0, 0, 0, 1 }, { 0, 0, 0, 0, 1, 0, 0 }, { 1, 0, 1, 0, 0, 0, 1 }
            };

            Assert.AreEqual("..-:", ocr.ReadTableRow(text, alphabet));
        }
        public void DifferentiatesBetweenDifferentDots()
        {
            var ocr      = new OCRReader(new OCRSplitter());
            var alphabet = new Dictionary <string, byte[, ]>
            {
                { ":", new byte[, ] {
                      { 1 }, { 0 }, { 1 }
                  } },
                { "-", new byte[, ] {
                      { 0 }, { 1 }, { 0 }
                  } },
                { ".", new byte[, ] {
                      { 0 }, { 0 }, { 1 }
                  } }
            };

            var text = new byte[, ] {
                { 0, 0, 0, 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 1, 0, 0, 0 }, { 1, 0, 1, 0, 0, 0, 1, 0 }
            };

            Assert.AreEqual("..-:", ocr.ReadTableRow(text, alphabet));
        }
        public void ReadsTheLetterG()
        {
            var ocr      = new OCRReader(new OCRSplitter());
            var alphabet = new Dictionary <string, byte[, ]>
            {
                { "G", new byte[, ] {
                      { 0, 1, 1, 1, 1, 0 },
                      { 1, 0, 0, 0, 0, 1 },
                      { 1, 0, 0, 0, 0, 0 },
                      { 1, 0, 0, 0, 0, 0 },
                      { 1, 0, 0, 1, 1, 1 },
                      { 1, 0, 0, 0, 0, 1 },
                      { 1, 0, 0, 0, 0, 1 },
                      { 1, 0, 0, 0, 1, 1 },
                      { 0, 1, 1, 1, 0, 1 },
                      { 0, 0, 0, 0, 0, 0 },
                      { 0, 0, 0, 0, 0, 0 }
                  } }
            };

            var pixels = new byte[, ] {
                { 0, 1, 1, 1, 1, 0, 0 },
                { 1, 0, 0, 0, 0, 1, 0 },
                { 1, 0, 0, 0, 0, 0, 0 },
                { 1, 0, 0, 0, 0, 0, 0 },
                { 1, 0, 0, 1, 1, 1, 0 },
                { 1, 0, 0, 0, 0, 1, 0 },
                { 1, 0, 0, 0, 0, 1, 0 },
                { 1, 0, 0, 0, 1, 1, 0 },
                { 0, 1, 1, 1, 0, 1, 0 },
                { 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0 }
            };

            Assert.AreEqual("G", ocr.ReadTableRow(pixels, alphabet));
        }