static CharacterDataSet()
        {
            CharacterDataSet space = new CharacterDataSet(' ');
            space.CharacterDatas.Add(new CharacterData(' ', new Bitmap(3, 8)));

            SpaceCharacterDataSet = space;
        }
Exemple #2
0
        private IEnumerable<FoundCharacterData> InternalFindCharacterDataSet(CharacterDataSet characterDataSet, float tolerance, FoundCharacterData previousCharacterData = null)
        {
            int startX = 0;
            int startY = 0;
            int maxX = neighborDifferences.GetLength(1);
            int maxY = neighborDifferences.GetLength(0);

            if (previousCharacterData != null)
            {
                startY = Math.Max(0, previousCharacterData.Point.Y + previousCharacterData.CharacterData.HeightFromWritingLine - characterDataSet.MaxHeight);
                startX = Math.Min(bitmap.Width, previousCharacterData.Point.X + previousCharacterData.CharacterData.Width - 2);

                maxX = startX + characterDataSet.MaxWidth+3;
                maxY = startY + characterDataSet.MaxHeight * 2;
            }

            List<FoundCharacterData> foundCharacterDatas = new List<FoundCharacterData>();

            for (int y = startY; y < maxY; y++)
            {
                for (int x = startX; x < maxX; x++)
                {
                    CharacterData characterData = CharacterMatchAtPoint(x, y, characterDataSet, tolerance);

                    if (characterData != null)
                    {
                        FoundCharacterData foundCharacterData = new FoundCharacterData
                        {
                            Point = new Point(x, y),
                            CharacterData = characterData
                        };

                        if(!foundCharacterDatas.Any(f => f.Bounds.IntersectsWith(foundCharacterData.Bounds)))
                            yield return foundCharacterData;

                    }
                }
            }
        }
Exemple #3
0
        private FoundCharacterData FindCharacterDataSet(CharacterDataSet characterDataSet, float tolerance, FoundCharacterData previousCharacterData)
        {
            int startY = Math.Max(0, previousCharacterData.Point.Y + previousCharacterData.CharacterData.HeightFromWritingLine - characterDataSet.MaxHeight - 2);
            int startX = Math.Min(bitmap.Width, previousCharacterData.Point.X + previousCharacterData.CharacterData.Width - 2);

            int maxX = startX + characterDataSet.MaxWidth+3;
            int maxY = startY + characterDataSet.MaxHeight * 2;

            for (int y = startY; y < maxY; y++)
            {
                for (int x = startX; x < maxX; x++)
                {
                    CharacterData characterData = CharacterMatchAtPoint(x, y, characterDataSet, tolerance);

                    if (characterData != null)
                    {
                        return new FoundCharacterData
                        {
                            Point = new Point(x, y),
                            CharacterData = characterData
                        };
                    }
                }
            }
            return null;
        }
Exemple #4
0
        private CharacterData CharacterMatchAtPoint(int x, int y, CharacterDataSet characterDataSet, float tolerance)
        {
            if (characterDataSet == CharacterDataSet.SpaceCharacterDataSet)
            {
                return CharacterDataSet.SpaceCharacterDataSet.CharacterDatas[0];
            }

            foreach (CharacterData characterData in characterDataSet.CharacterDatas)
            {
                if (IsCharacterMatchAtPoint(x, y, neighborDifferences, characterData, tolerance))
                {
                    return characterData;
                }
            }

            return null;
        }
Exemple #5
0
 public IEnumerable<FoundTextData> FindCharacterDataSet(CharacterDataSet characterDataSet, float tolerance)
 {
     return InternalFindCharacterDataSet(characterDataSet, tolerance)
         .Select(f =>
         {
             return new FoundTextData
             {
                 Bounds = new Rectangle(f.Point, new Size(f.CharacterData.Width, f.CharacterData.Height)),
                 Text = characterDataSet.Letter.ToString()
             };
         });
 }