예제 #1
0
        private void FindText(OcrData ocrData, float tolerance, FoundCharacterData previousCharacterData, List<char> foundChars)
        {
            foreach (CharacterDataSet characterDataSet in ocrData.TrainedCharacterDataSets)
            {
                List<FoundCharacterData> foundCharacterDatas = InternalFindCharacterDataSet(characterDataSet, tolerance, previousCharacterData).ToList();

                if (foundCharacterDatas.Any())
                {
                    foundChars.Add(foundCharacterDatas[0].CharacterData.Letter);
                    FindText(ocrData, tolerance, foundCharacterDatas[0], foundChars);
                }

            }
        }
예제 #2
0
        public IEnumerable<FoundTextData> FindText(OcrData ocrData, float tolerance = 0.05f)
        {
            List<char> foundChars = new List<char>();

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

            foreach (CharacterDataSet characterDataSet in ocrData.TrainedCharacterDataSets)
            {
                foreach (FoundCharacterData foundCharacterData in InternalFindCharacterDataSet(characterDataSet, tolerance))
                {
                    foundDatas.Add(foundCharacterData);
                    //foundChars.Add(foundCharacterData.CharacterData.Letter);
                    //FindText(ocrData, tolerance, foundCharacterData, foundChars);
                }

            }

            return OrganizeCharacters(foundDatas);
        }
예제 #3
0
        private void FindText(string searchText, OcrData ocrData, float tolerance, List<FoundCharacterData> previousCharacterDatas)
        {
            if (string.IsNullOrEmpty(searchText))
                return;

            FoundCharacterData foundCharacterData = FindCharacterDataSet(ocrData[searchText[0]], tolerance, previousCharacterDatas.Last());

            if (foundCharacterData == null)
                return;

            previousCharacterDatas.Add(foundCharacterData);

            FindText(searchText.Substring(1), ocrData, tolerance, previousCharacterDatas);
        }
예제 #4
0
        public IEnumerable<FoundTextData> FindText(string searchText, OcrData ocrData, float tolerance = 0.05f)
        {
            IEnumerable<FoundCharacterData> findCharacterDataSet = InternalFindCharacterDataSet(ocrData[searchText[0]], tolerance);

            List<FoundTextData> foundText = new List<FoundTextData>();

            foreach (FoundCharacterData foundCharacterData in findCharacterDataSet)
            {
                List<FoundCharacterData> foundCharacterDatas = new List<FoundCharacterData>();
                foundCharacterDatas.Add(foundCharacterData);

                FindText(searchText.Substring(1), ocrData, tolerance, foundCharacterDatas);

                if (foundCharacterDatas.Count < searchText.Length)
                    continue;

                Size wordSize = new Size(foundCharacterDatas.Max(f => f.Bounds.Right)-foundCharacterDatas[0].Bounds.Left,
                    foundCharacterDatas.Max(f => f.CharacterData.Height));

                Point wordStartPoint = new Point(foundCharacterDatas.Min(f => f.Point.X),
                    foundCharacterDatas.Min(f => f.Point.Y));

                Rectangle wordRectangle = new Rectangle(wordStartPoint, wordSize);
                FoundTextData foundTextData = new FoundTextData
                {
                    Bounds = wordRectangle,
                    Text = searchText
                };

                if (foundText.Any(ft => ft.Bounds.IntersectsWith(foundTextData.Bounds)))
                    continue;

                foundText.Add(foundTextData);

                yield return foundTextData;
            }
        }